## -------------------------------------------------------------------------------------------------## ## Sensoren ## -------------------------------------------------------------------------------------------------## sensor: ## -----------------------------------------------------------------------------------------------## ## Berechnung der Temperaturveränderung ## -----------------------------------------------------------------------------------------------## - platform: template sensors: climate_temp_change: friendly_name: Veränderung value_template: > {% set now = states("sensor.aqara_temperature_kai_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) }} ## -----------------------------------------------------------------------------------------------## ## Berechnung der aktuellen Zieltemperatur bzgl Morgen/Nacht, Automatik/Manuell ## -----------------------------------------------------------------------------------------------## - platform: template sensors: climate_temp: friendly_name: akt. Ziel 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 %} ## -----------------------------------------------------------------------------------------------## ## Berechnung von Unterschied zwischen Heizungstemperatur und realer Temperatur ## -----------------------------------------------------------------------------------------------## - platform: template sensors: climate_temp_difference: friendly_name: 'akt. Unterschied' value_template: > {% if states("sensor.aqara_temperature_kai_temperature") == "unknown" %} {{ 0 | float }} {% else %} {{ ( states("sensor.aqara_temperature_kai_temperature") | float - (states.sensor.climate_temp.state | 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: 'Schrittgröße' 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: '-> Heizung' 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'