This is my solution for a smart generic_thermostat
The configuration provides two temperatures depending on the time.
When a thermostat changes its temperature, the temperature will be reset according to the time band after a period of time configurable by a user.
#input_number.yaml
actual_temperature:
name: "Temperatura attuale"
min: -100
max: 100
step: 0.5
day_temperature:
name: "Temperatura"
min: 10
max: 25
step: 0.5
day_hour_heaters:
name: "Hour"
icon: mdi:timer
min: 0
max: 23
step: 1
day_minutes_heaters:
name: "Minutes"
icon: mdi:timer
min: 0
max: 59
step: 1
night_temperature:
name: "Temperatura"
min: 10
max: 22
step: 0.5
night_hour_heaters:
name: "Hour"
icon: mdi:timer
min: 0
max: 23
step: 1
night_minutes_heaters:
name: "Minutes"
icon: mdi:timer
min: 0
max: 59
step: 1
timer_hour_heaters:
name: "Hour"
icon: mdi:timer
min: 0
max: 23
step: 1
timer_minutes_heaters:
name: "Minutes"
icon: mdi:timer
min: 0
max: 59
step: 1
#sensors.yaml
- platform: template
sensors:
day_time_heaters:
friendly_name: 'Time'
value_template: '{{ "%0.02d:%0.02d" | format(states("input_number.day_hour_heaters") | int, states("input_number.day_minutes_heaters") | int) }}'
night_time_heaters:
friendly_name: 'Time'
value_template: '{{ "%0.02d:%0.02d" | format(states("input_number.night_hour_heaters") | int, states("input_number.night_minutes_heaters") | int) }}'
timer_time_heaters:
friendly_name: 'Time'
value_template: '{{ "%0.02d:%0.02d:00" | format(states("input_number.timer_hour_heaters") | int, states("input_number.timer_minutes_heaters") | int) }}'
#timers.yaml
climate_bagno:
#automations.yaml
- alias: "Timer bagno start"
trigger:
platform: state
entity_id: climate.bagno
condition:
condition: or
conditions:
- condition: template
value_template: >
{{ trigger.to_state.attributes.temperature != trigger.from_state.attributes.temperature }}
action:
- service: timer.cancel
entity_id: timer.climate_bagno
- condition: or
conditions:
- condition: template
value_template: >
{{ trigger.to_state.attributes.temperature | float != states.input_number.actual_temperature.state | float }}
- service: timer.start
entity_id: timer.climate_bagno
data_template:
duration: "{{ states.sensor.timer_time_heaters.state }}"
- alias: "Timer bagno stop"
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.climate_bagno
action:
- service: climate.set_temperature
entity_id: climate.bagno
data_template:
temperature: "{{ states.input_number.actual_temperature.state }}"
- alias: "Temperatura diurna"
trigger:
platform: template
value_template: "{{ states.sensor.time.state == states.sensor.day_time_heaters.state }}"
action:
- service: climate.set_temperature
data_template:
entity_id: climate.camera, climate.camera_sophie, climate.bagno, climate.studio, climate.ingresso, climate.salotto, climate.cucina
temperature: "{{ states.input_number.day_temperature.state | float }}"
operation_mode: Heat
- service: input_number.set_value
data_template:
entity_id: input_number.actual_temperature
value: "{{ states.input_number.day_temperature.state | float }}"
- alias: "Temperatura notturna"
trigger:
platform: template
value_template: "{{ states.sensor.time.state == states.sensor.night_time_heaters.state }}"
action:
- service: climate.set_temperature
data_template:
entity_id: climate.camera, climate.camera_sophie, climate.bagno, climate.studio, climate.ingresso, climate.salotto, climate.cucina
temperature: "{{ states.input_number.night_temperature.state | float }}"
operation_mode: Heat
- service: input_number.set_value
data_template:
entity_id: input_number.actual_temperature
value: "{{ states.input_number.night_temperature.state | float }}"