Last active
September 2, 2022 13:17
-
-
Save Didgeridrew/4bbcbfb708e68660217b36c9b7f766ae to your computer and use it in GitHub Desktop.
HA: Sensors that calculate and compare the Heat Discomfort Index for inside and outside.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template: | |
- sensor: | |
- name: "Outside Discomfort Index" | |
unit_of_measurement: "" | |
state_class: measurement | |
state: >- | |
{% set t = ((states('sensor.outside_temp')|float(0)) - 32) / 1.8 %} | |
{% set h = states('sensor.outside_humidity')|float(0) %} | |
{% set discomfort_index = (t - (0.55*(1 - (0.01*h) ) * (t - 14.5)))|round(2,0) %} | |
{{ discomfort_index}} | |
attributes: | |
comfortable: >- | |
{{ this.state|int(0) < 20 }} | |
- name: "Inside Discomfort Index" | |
unit_of_measurement: "" | |
state_class: measurement | |
state: >- | |
{%- set t = ((states('sensor.inside_temp')|float(0)) - 32) / 1.8 %} | |
{%- set h = states('sensor.inside_humidity')|float(0) %} | |
{%- set discomfort_index = (t - (0.55*(1 - (0.01*h) ) * (t - 14.5)))|round(2,0) %} | |
{{ discomfort_index }} | |
attributes: | |
comfortable: >- | |
{{ this.state|int(0) < 20 }} | |
- binary_sensor: | |
- name: "Nicer Outside" | |
state: >- | |
{% set threshold = 1.5 %} | |
{{ states('sensor.inside_discomfort_index')|float(0)|round(1, default=0) - threshold | |
>= states('sensor.outside_discomfort_index')|float(0)|round(1, default=0) }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Formula for Heat Discomfort from: https://keisan.casio.com/exec/system/1351058230
The two Discomfort Index sensors are setup to convert Fahrenheit temperatures reported by my sensors to metric.
If your sensors report in Celsius, change the first line of the state template as follows:
{% set t = states('sensor.outside_temp')|float(0) %}
The
threshold
variable should be set to personal preference... Basically, "How much nicer does it need to be inside to count?"