This repository has been archived on 2023-06-10. You can view files and clone it, but cannot push or open issues or pull requests.
homeassistant-config/packages/climate/climate_sensors.yaml
darthsandmann e1825ce91b fixes
2023-02-14 17:12:57 +01:00

215 lines
11 KiB
YAML
Executable File

sensor:
## -----------------------------------------------------------------------------------------------##
## Calculation of temperature change
## -----------------------------------------------------------------------------------------------##
- platform: template
sensors:
climate_temp_change:
friendly_name: change in temperature
value_template: >
{% set now = states("sensor.kai_regal_temperature")|float %}
{% set last = states("input_number.climate_temp_last")|float %}
{% set change = (now | float - last) | float %}
{% if now == ("0.0"|float) %} {% set change = ("0.0"|float) %} {% endif %}
{{ change | round(2) }}
## -----------------------------------------------------------------------------------------------##
## Calculation of the target temperature
## -----------------------------------------------------------------------------------------------##
- platform: template
sensors:
climate_temp:
friendly_name: target temperature
unit_of_measurement: '°C'
value_template: >
{% set auto = states("input_boolean.climate_auto") %}
{% set manual_temp = states("input_number.climate_temp") %}
{% if auto == "off" %} {{ manual_temp }}
{% else %}
{% set time = states("sensor.time") %}
{% set morning = states("input_datetime.climate_morning") %}
{% set night = states("input_datetime.climate_night") %}
{% set morning_temp = states("input_number.climate_temp_day")|float %}
{% set night_temp = states("input_number.climate_temp_night")|float %}
{% if night > morning %}
{% if time > morning and time <= night %} {{ morning_temp|float }}
{% else %} {{ night_temp|float }} {% endif %}
{% else %}
{% if time <= morning and time > night %} {{ morning_temp|float }}
{% else %} {{ night_temp|float }} {% endif %}
{% endif %}
{% endif %}
# Mit Weekday
# - platform: template
# sensors:
# climate_temp:
# friendly_name: target temperature
# unit_of_measurement: '°C'
# value_template: >
# {% set auto = states("input_boolean.climate_auto") %}
# {% set manual_temp = states("input_number.climate_temp") %}
# {% if auto == "off" %} {{ manual_temp }}
# {% else %}
# {% set time = states("sensor.time") %}
# {% set morning = states("sensor.climate_morning") %}
# {% set weekday = states("input_boolean.climate_weekday") %}
# {% if weekday == "on" %} {% set morning = states("input_datetime.climate_morning") %}
# {% else %} {% set morning = states("input_datetime.climate_morning_weekend") %} {% endif %}
# {% set night = states("input_datetime.climate_night") %}
# {% set morning_temp = states("input_number.climate_temp_morning")|float %}
# {% set night_temp = states("input_number.climate_temp_night")|float %}
# {% if night > morning %}
# {% if time > morning and time <= night %} {{ morning_temp|float }}
# {% else %} {{ night_temp|float }} {% endif %}
# {% else %}
# {% if time <= morning and time > night %} {{ morning_temp|float }}
# {% else %} {{ night_temp|float }} {% endif %}
# {% endif %}
# {% endif %}
## -----------------------------------------------------------------------------------------------##
## target min and max temperature
## -----------------------------------------------------------------------------------------------##
- platform: template
sensors:
climate_temp_min:
friendly_name: target min
unit_of_measurement: '°C'
value_template: >
{% set target = states("sensor.climate_temp")|float %}
{% set accuracy = states("input_number.climate_temp_accuracy")|float %}
{{ target-accuracy|float }}
- platform: template
sensors:
climate_temp_max:
friendly_name: target max
unit_of_measurement: '°C'
value_template: >
{% set target = states("sensor.climate_temp")|float %}
{% set accuracy = states("input_number.climate_temp_accuracy")|float %}
{{ target+accuracy|float }}
## -----------------------------------------------------------------------------------------------##
## Recommendation
## -----------------------------------------------------------------------------------------------##
- platform: template
sensors:
climate_temp_recommendation:
friendly_name: temperature recommendation
value_template: >
{% set min = states("sensor.climate_temp_min")|float %}
{% set max = states("sensor.climate_temp_max")|float %}
{% set target = states("sensor.climate_temp")|float %}
{% set temp_inside = states("sensor.kai_regal_temperature")|float %}
{% set temp_outside = states("sensor.garten_huette_temperature")|float %}
{% set inside_max = temp_inside + states("input_number.climate_temp_accuracy")|float %}
{% set accuracy = states("input_number.climate_temp_accuracy") |float %}
{% if temp_inside >= target and temp_inside >= (temp_outside - accuracy) %}
{{ "open the window" }}
{% else %}
{{ "close the window" }}
{% endif %}
## -----------------------------------------------------------------------------------------------##
## difference to target
## -----------------------------------------------------------------------------------------------##
- platform: template
sensors:
climate_temp_difference:
friendly_name: difference to target
value_template: >
{% if states("sensor.kai_regal_temperature") == "unknown" %}
{{ 0 | float }}
{% else %}
{{ (states("sensor.kai_regal_temperature") | float - (states.sensor.climate_temp.state | float) ) | round(2) }}
{% endif %}
unit_of_measurement: '°C'
- platform: template
sensors:
climate_temp_difference_inside_outside:
friendly_name: difference inside to outside
value_template: >
{% if states("sensor.kai_regal_temperature") == "unknown" %}
{{ 0 | float }}
{% else %}
{{ (states("sensor.garten_huette_temperature")|float - states("sensor.kai_regal_temperature")|float) | round(2) }}
{% endif %}
unit_of_measurement: '°C'
## -----------------------------------------------------------------------------------------------##
## Schrittgröße, mit der die Heizung verstellt werden soll, abhängig vom Unterschied zur realen
## Temperatur
## Variable Schrittgröße, bei positiv (zu warm) größer, bei negativ (zu kalt) geringer
## -----------------------------------------------------------------------------------------------##
# - platform: template
# sensors:
# climate_temp_steps:
# friendly_name: increment
# value_template: >
# {% set difference = (states("sensor.climate_temp_difference" ) | float) %}
# {% set zero = ("0.0" | float ) %}
# {% if difference > zero %}
# {% if difference >= ("2.00"|float) %} {% set steps = ( "3.00" | float ) %}
# {% elif difference >= ("1.50"|float) %} {% set steps = ( "1.50" | float ) %}
# {% elif difference >= ("1.00"|float) %} {% set steps = ( "1.00" | float ) %}
# {% elif difference >= ("0.50"|float) %} {% set steps = ( "0.50" | float ) %}
# {% elif difference >= ("0.00"|float) %} {% set steps = ( "0.00" | float ) %}
# {% endif %}
# {% else %}
# {% if difference <= ("-2.00"|float) %} {% set steps = ( "3.00" | float ) %}
# {% elif difference <= ("-1.50"|float) %} {% set steps = ( "1.50" | float ) %}
# {% elif difference <= ("-1.00"|float) %} {% set steps = ( "0.50" | float ) %}
# {% elif difference <= ("-0.50"|float) %} {% set steps = ( "0.50" | float ) %}
# {% elif difference <= ("-0.00"|float) %} {% set steps = ( "0.00" | float ) %}
# {% endif %}
# {% endif %}
# {{ steps }}
## -----------------------------------------------------------------------------------------------##
## Berechnung der Temperatur, auf die die Heizung gestellt werden soll, um Zieltemperatur zu
## erreichen. Berücksichtigung für Genauigkeit, variable Temperaturanpassung und Temperatur-
## anpassung aufgrund von Offset. Berechnung ob Anpassung Positiv oder Negativ
## -----------------------------------------------------------------------------------------------##
# - platform: template
# sensors:
# climate_temp_set:
# friendly_name: '-> climate'
# value_template: >
# {% set difference = (states("sensor.climate_temp_difference" ) | float) %}
# {% set change = (states("sensor.climate_temp_change" ) | float) %}
# {% set goal = (states("sensor.climate_temp" ) | float) %}
# {% set temp = (states("sensor.aqara_temperature_kai_temperature") | float ) %}
# {% set climate = (state_attr("climate.kai", "temperature") | float ) %}
# {% if climate < ("15.0" | float ) %} {% set climate = ("15.0" | float) %} {% endif %}
# {% set max = states("sensor.climate_temp") | float %}
# {% set min = states("sensor.climate_temp") | float - (states.input_number.climate_temp_accuracy.state | float) %}
# {% set zero = ("0.0" | float ) %}
# {% set difference_max = ("1.5" | float ) %}
# {% set difference_min = ("-2.0" | float ) %}
# {% set change_max = ("1.0" | float ) %}
# {% set offset = (states("input_number.climate_temp_offset") | float ) %}
# {% set climate_goal = (goal | float + ("2.0" | float) | float - offset) | float %}
# {% set steps = (states("sensor.climate_temp_steps") | float) %}
# {% if difference == zero %} {% set result = climate %}
# {% elif (difference > difference_max) %} {% set result = ("15.0"|float) %}
# {% elif (difference < difference_min) %} {% set result = goal - offset %}
# {% elif difference > zero %}
# {% if (climate_goal <= climate) or (change >= change_max) %} {% set result = goal - offset %}
# {% elif temp > max %} {% set result = (climate | float - steps) | float %}
# {% else %} {% set result = climate %} {% endif %}
# {% elif difference < zero %}
# {% if temp < min %}
# {% set result = (climate | float + steps) | float %}
# {% else %}
# {% if change >= change_max %}
# {% set result = goal - offset %}
# {% else %}
# {% set result = climate %}
# {% endif %}
# {% endif %}
# {% endif %}
# {% if result < ("15.0"|float) %} {{ ("15.0"|float) }}
# {% elif result > ("29.5"|float) %} {{ ("29.5"|float) }}
# {% else %} {{ result }}
# {% endif %}
# unit_of_measurement: '°C'