I wrote the automation below to tells when to close the windows to keep the house cool. Basic premise is to open windows when it’s cooler out and close them when the opposite is true. This automation scripted “worked” until I tried to add the condition that a window is open. The binary sensor is the open sensor on our patio slider. It’s state is ‘on’ when the door is open. Any idea what I’m doing wrong?
If I can get this working I will add a check on any of the windows being open with an or check.
- id: 'XXXXXXXXX899'
alias: Close windows
description: ''
trigger:
- entity_id: binary_sensor.cool_inside
from: 'off'
platform: state
to: 'on'
condition:
- after: sunrise
condition: sun
- condition: template
value_template: "{{is_state('binary_sensor.living_room', 'on')}}"
action:
- data:
message: Time to close the windows to keep the house cool.
service: notify.notify
- data:
message: Time to close the windows to keep the house cool.
service: persistent_notification.create
mode: single
It could be something as simple as that hyphon in the wrong place. You could try this:-
- id: 'XXXXXXXXX899'
alias: Close windows
description: ''
trigger:
- entity_id: binary_sensor.cool_inside
from: 'off'
platform: state
to: 'on'
condition:
- condition: sun
after: sunrise
- condition: template
value_template: "{{is_state('binary_sensor.living_room', 'on')}}"
action:
- data:
message: Time to close the windows to keep the house cool.
service: notify.notify
- data:
message: Time to close the windows to keep the house cool.
service: persistent_notification.create
mode: single
By the time you’ve tried that, one of the veterans will probably come back with a sensible answer
Order shouldn’t matter there, so I don’t think that will help. I don’t see anything obviously wrong with the conditions, so I can only explain what I think that automation will do:
If binary_sensor.cool_inside turns on (presumably indicating that it’s cooler inside?)
AND it’s after sunrise and before midnight
AND a window is open
Notify you
If that’s what you want, it looks like it should work. If not, perhaps you could point out the difference in intent.
Also, make sure that the template gives the expected result in ->Templates.
Thanks both. I can confirm the order in the sunrise condition did not make it work.@rccoleman that is exactly what I want to have happen. I checked the individual conditions and the all toggle appropriately when independent fact the notification happens if I just remove the window on (open) condition. From what I can tell the binary sensor is either “on” or “off”. That said in history it shows “open” or “closed”.
Good news - I think I found my problem. On Sunday, I decided to open the automation file directly in a text editor vs the automation UI. To my surprise there were a couple “\n” end of line characters, I didn’t expect. I think they were added by the automation UI. I removed them on a whim - and it worked today.
I’ll do some more testing. Thanks a ton for the help.