Hi,
I made an automation that controls heating thermostat (zwave danfoss). Following table shows the scenarios it covers (eg. switch off when windows open, away mode, work home mode)
How it works?
I can schedule time of the day, when the heating is on, and off. This saves a lot of evergy vs heating all day. Additionally, whenever I open windows in the room, the heating goes copmpletely off. When I close the windows, the heating adjusts to the temperature which depends if it is heating active time, I am away, or work from home.
When I don’t go on holidays (away mode off) temperater goes from normal temperature to reduced temeprature (i.e. in the night or during the day when I am at work).
Currently, I use following temperature values:
off temp: 8
away temp: 16
reduced temp: 19
normal temp: 22
Here is the automation script based on one room called (“Leona”) with 2 windows. If I want to copy it to other rooms, I just copy paste it and replace the physical devices entity_id with what is there in the room.
# Detect window open/closed
- id: '3003'
alias: Leona window opened input boolean
trigger:
- entity_id: binary_sensor.door_window_sensor_158d000130e59b
platform: state
to: 'on'
- entity_id: binary_sensor.door_window_sensor_158d00014db5e6
platform: state
to: 'on'
condition:
action:
service: input_boolean.turn_on
entity_id: input_boolean.leona_window_shut
- id: '3004'
alias: Leona window input boolean off
trigger:
- entity_id: binary_sensor.door_window_sensor_158d000130e59b
platform: state
to: 'off'
condition:
- condition: state
entity_id: binary_sensor.door_window_sensor_158d00014db5e6
state: 'off'
action:
service: input_boolean.turn_off
entity_id: input_boolean.leona_window_shut
- id: '3005'
alias: Leona window input boolean off
trigger:
- entity_id: binary_sensor.door_window_sensor_158d00014db5e6
platform: state
to: 'off'
condition:
- condition: state
entity_id: binary_sensor.door_window_sensor_158d000130e59b
state: 'off'
action:
service: input_boolean.turn_off
entity_id: input_boolean.leona_window_shut
# Adjust thermostat on current temp change
- id: '3017'
alias: Leona adjust temp on current temp change
trigger:
- platform: state
entity_id: input_number.leona_current_temp
condition:
action:
- service: climate.set_temperature
data_template:
entity_id: climate.danfoss_z_thermostat_014g0013_heating_1_2
temperature: "{{states('input_number.leona_current_temp')|float}}"
# Detect active time
## Morning activite time start
- id: '4021'
alias: Leona morning active time on
trigger:
- platform: time
at: '06:00:00'
condition:
- condition: state
entity_id: input_boolean.away_home_switch
state: 'off'
action:
service: input_boolean.turn_on
entity_id: input_boolean.leona_time_on
## Evening active time start
- id: '4022'
alias: Leona evening activity time on
trigger:
- platform: time
at: '16:00:00'
condition:
- condition: state
entity_id: input_boolean.away_home_switch
state: 'off'
action:
service: input_boolean.turn_on
entity_id: input_boolean.leona_time_on
## Morning active time end
- id: '4023'
alias: Leona morning activity time off
trigger:
- platform: time
at: '09:00:00'
condition:
- condition: state
entity_id: input_boolean.work_home_switch
state: 'off'
action:
- service: input_boolean.turn_off
entity_id: input_boolean.leona_time_on
## Evening active time end
- id: '4024'
alias: Leona evening activity time off
trigger:
- platform: time
at: '23:59:00'
condition:
action:
- service: input_boolean.turn_off
entity_id: input_boolean.leona_time_on
# Adjust current temp
## off temp
- id: '4031'
alias: Leona reduce off temp when window open
trigger:
- entity_id: input_boolean.leona_window_shut
platform: state
to: 'on'
condition:
action:
- service: input_number.set_value
data_template:
entity_id: input_number.leona_current_temp
value: "{{states('input_number.off_temp')|float}}"
## away temp
- id: '4032'
alias: Leona away temp when away mode
trigger:
- entity_id: input_boolean.away_mode_switch
platform: state
to: 'on'
condition:
action:
- service: input_number.set_value
data_template:
entity_id: input_number.leona_current_temp
value: "{{states('input_number.away_temp')|float}}"
## normal temp
### Increase current temp to normal temp when active time
- id: '4033'
alias: Leona increase temp to normal temp when window closed away mode off and active time
trigger:
- entity_id: input_boolean.leona_window_shut
platform: state
to: 'off'
- platform: state
entity_id: input_boolean.away_mode_switch
to: 'off'
condition:
- condition: state
entity_id: input_boolean.leona_time_on
state: 'on'
action:
- service: input_number.set_value
data_template:
entity_id: input_number.leona_current_temp
value: "{{states('input_number.normal_temp')|float}}"
### Adjust current temp to normal temp based on active time on
- id: '4034'
alias: Leona increase temp when active time
trigger:
- entity_id: input_boolean.leona_time_on
platform: state
to: 'on'
condition:
- condition: state
entity_id: input_boolean.away_mode_switch
state: 'off'
action:
- service: input_number.set_value
data_template:
entity_id: input_number.leona_current_temp
value: "{{states('input_number.normal_temp')|float}}"
## reduced temp
### Adjust current temp to reduced temp when window closed away mode off and non active time
- id: '4035'
alias: Leona increase temp when window closed away mode off and non active time
trigger:
- entity_id: input_boolean.leona_window_shut
platform: state
to: 'off'
- platform: state
entity_id: input_boolean.away_mode_switch
to: 'off'
condition:
- condition: state
entity_id: input_boolean.leona_time_on
state: 'off'
action:
- service: input_number.set_value
data_template:
entity_id: input_number.leona_current_temp
value: "{{states('input_number.reduced_temp')|float}}"
### Adjust current temp to reduced when active time off
- id: '4036'
alias: Leona adjust temp when active time off
trigger:
- entity_id: input_boolean.leona_time_on
platform: state
to: 'off'
condition:
- condition: state
entity_id: input_boolean.away_mode_switch
state: 'off'
action:
- service: input_number.set_value
data_template:
entity_id: input_number.leona_current_temp
value: "{{states('input_number.reduced_temp')|float}}"
I bet this is not the most efficient way to achieve similar result so I am open to any suggestions for improvement. I am actually wondering, if anyone knows any good design workflow, that allows to make sure I have covered all the scenarios and there are no potential deadlocks in the conditions.
Based on tests in real life, everything works well, but I don’t have full certainty.
Enjoy or shoot