aeble
(Axel Eble)
October 18, 2018, 12:26pm
1
Hi folks,
I’ve been using the following automation successfully for a while, but one of the last updates seems to have broken something:
- alias: 'Bei offenem Badfenster Heizung aus'
trigger:
platform: state
entity_id: binary_sensor.door_window_sensor_158d00016571fd
from: "off"
to: "on"
for:
minutes: 2
condition:
condition: state
entity_id: binary_sensor.door_window_sensor_158d00016571fd
state: 'off'
action:
- service: input_number.set_value
data:
entity_id: input_number.temp_heating_bathroom_saved
value: "{{ sensor.danfoss_devolo_home_control_radiator_thermostat_temperature_3 }}"
- service: climate.set_temperature
data:
entity_id: climate.danfoss_devolo_home_control_radiator_thermostat_heating_1_3
temperature: 7
- service: notify.Telegram
data:
message: "Badfenster ist auf, Heizung ausgemacht"
If the sensor state turns from off to on for more than two minutes the current temperature should be written to the input_number and the heating turned down to 7°C.
Alas, it doesn’t trigger anymore. Any help out there?
The reverse (setting the thermostat when the window has been closed for 5 minutes) works:
- alias: 'Wenn das Fenster wieder zu ist, dreh die Heizung wieder auf'
trigger:
# Badfenster länger als 5 Minuten geschlossen.
platform: state
entity_id: binary_sensor.door_window_sensor_158d00016571fd
from: 'on'
to: 'off'
for:
minutes: 5
condition:
# Temperatur unter 20 Grad C
condition: numeric_state
entity_id: sensor.temperature_158d00022cc550
below: 20
action:
- service: climate.set_temperature
data_template:
entity_id: climate.danfoss_devolo_home_control_radiator_thermostat_heating_1_3
temperature: "{{ states('input_number.temp_heating_bathroom_saved')}}"
- service: notify.Telegram
data_template:
message: "Badfenster ist zu, Heizung wieder auf {{ states('input_number.temp_heating_bathroom_saved') }}°C gestellt."
Any help out there?
Best,
Axel
lolouk44
(lolouk44)
October 18, 2018, 1:05pm
2
I thinkf this is your issue:
trigger:
platform: state
entity_id: binary_sensor.door_window_sensor_158d00016571fd
from: "off"
to: "on"
for:
minutes: 2
condition:
condition: state
entity_id: binary_sensor.door_window_sensor_158d00016571fd
state: 'off'
you automation triggers when the sensor changes to on, then you have a condition that checks that the sensor value is off. It can’t be on and off at the same time
2 Likes
aeble
(Axel Eble)
October 19, 2018, 9:54am
3
Thanks. I feel so dumb now
It works now.
1 Like
aeble
(Axel Eble)
October 21, 2018, 4:33pm
4
Followup on this - what still doesn’t work ist the saving of the current temperature. I would like to save the current temperature to an input_number and restore it when I close the window.
For some reason the current temperature doesn’t seem to get written to the input_number
. I tried using both data
and data_template
but neither seems to work.
- alias: 'Bei offenem Badfenster Heizung aus'
trigger:
platform: state
entity_id: binary_sensor.door_window_sensor_158d00016571fd
from: "off"
to: "on"
for:
minutes: 2
action:
- service: input_number.set_value
data_template:
entity_id: input_number.temp_heating_bathroom_saved
value_template: "{{ sensor.danfoss_devolo_home_control_radiator_thermostat_temperature_3 }}"
- service: climate.set_temperature
data:
entity_id: climate.danfoss_devolo_home_control_radiator_thermostat_heating_1_3
temperature: 7
- service: notify.Telegram
data:
message: "Badfenster ist auf, Heizung ausgemacht"
1 Like
aeble
(Axel Eble)
October 21, 2018, 4:40pm
5
Final working configuration (in case anybody is interested):
input_number:
temp_heating_bathroom_saved:
name: radiator temperature backup
min: 7
max: 34
step: 0.5
unit_of_measurement: °C
icon: mdi:temperature-celsius
- alias: 'turn off heating if window opens'
trigger:
platform: state
entity_id: binary_sensor.door_window_sensor_158d00016571fd
from: "off"
to: "on"
for:
minutes: 2
action:
- service: input_number.set_value
data_template:
entity_id: input_number.temp_heating_bathroom_saved
value: "{{ ((states('sensor.danfoss_devolo_home_control_radiator_thermostat_temperature_3')|float/0.5|float)|int *0.5|float) }}"
- service: climate.set_temperature
data:
entity_id: climate.danfoss_devolo_home_control_radiator_thermostat_heating_1_3
temperature: 7
- service: notify.Telegram
data:
message: "bathroom window is open, turned off radiator"
- alias: 'turn bathroom heating on if window closed for more than five minutes'
trigger:
# Bathroom window is closed for more than five minutes
platform: state
entity_id: binary_sensor.door_window_sensor_158d00016571fd
from: 'on'
to: 'off'
for:
minutes: 5
condition:
# must be below 20 °C
condition: numeric_state
entity_id: sensor.temperature_158d00022cc550
below: 20
action:
- service: climate.set_temperature
# set radiator to backed up value
data_template:
entity_id: climate.danfoss_devolo_home_control_radiator_thermostat_heating_1_3
temperature: "{{ states('input_number.temp_heating_bathroom_saved')}}"
- service: notify.Telegram
data_template:
message: "bathroom window closed, radiator set to {{ states('input_number.temp_heating_bathroom_saved') }}°C."
- alias: 'recommend venting bathroom'
trigger:
- platform: numeric_state
entity_id: sensor.humidity_158d00022b6a44
above: 60
- platform: numeric_state
entity_id: sensor.dewpoint_difference
above: 3
for:
minutes: 5
condition:
- condition: numeric_state
entity_id: sensor.humidity_158d00022b6a44
above: 60
- condition: numeric_state
entity_id: sensor.dewpoint_difference
above: 3
- condition: state
entity_id: binary_sensor.door_window_sensor_158d00016571fd
state: 'off'
action:
- service: notify.Telegram
# send a notification with the reason (humidity and/or dew point difference)
data_template:
message: 'Vent bathroom ({{trigger.to_state.attributes.friendly_name}} {{ trigger.to_state.state }}/{{trigger.above}})'
- alias: 'end bathroom venting'
# recommend closing the bathroom window again
# if relative humidity is back down to below 45%
# for more than five minutes
# or dewpoint difference between inside and outside is less than 3°C
trigger:
- platform: numeric_state
entity_id: sensor.humidity_158d00022b6a44
below: 45
for:
minutes: 5
- platform: numeric_state
entity_id: sensor.dewpoint_difference
below: 3
for:
minutes: 5
condition:
condition: state
entity_id: binary_sensor.door_window_sensor_158d00016571fd
state: 'on'
action:
- service: notify.Telegram
data_template:
message: "Lüftung im Bad beenden ({{ trigger.to_state.attributes.friendly_name }} {{ trigger.to_state.state }}/{{ sensor.dewpoint_bathroom - sensor.dewpoint_patio }})"
- alias: 'turn bathroom heating on if it's below 20°C outside'
# set radiator to saved temperature when it's below 20°C outside for more than 20 minutes
trigger:
platform: numeric_state
entity_id: sensor.temperature_158d00022cc550
below: 20
for:
minutes: 20
condition:
condition: state
# bathroom window must be closed
entity_id: binary_sensor.door_window_sensor_158d00016571fd
state: 'off'
action:
- service: notify.Telegram
data:
message: 'below 20°C outside, bath radiator set to {{ input_number.temp_heating_bathroom_saved }}°C.'
- service: climate.set_temperature
data_template:
entity_id: climate.danfoss_devolo_home_control_radiator_thermostat_heating_1_3
temperature: "{{ states('input_number.temp_heating_bathroom_saved') }}"
1 Like
Tinkerer
(aka DubhAd on GitHub)
October 21, 2018, 7:20pm
6
That’s never going to return a number, so how it worked before I don’t know. The correct one would be:
value_template: "{{ states('sensor.danfoss_devolo_home_control_radiator_thermostat_temperature_3') }}"
You can test these in the Templates tool under Developer Tools.
aeble
(Axel Eble)
October 21, 2018, 7:41pm
7
Thanks, I found it out myself and updated the post above yours.
What’s the difference between states('…')
and states.…
? From what I read I though it would be synonymous, but apparently it isn’t.
Oh, and it didn’t work with value_template
, I needed to use value
.
Tinkerer
(aka DubhAd on GitHub)
October 22, 2018, 10:19am
8
The difference is explained in the templating docs . In short, states('...')
returns unknown
if the entity doesn’t exist, where states...state
just throws an error.