I’m wondering what the best solution would be for this use case:
Yesterday, while closing the smart blinds in my living room I inadvertently opened my sun awning. It was open all night, only noticed it this morning.
What I would like to achieve:
Get a notification every x minutes if:
it is after sunset, but before sunrise
the sun awaning is open (down)
(please note, i now only register open/closed using an aqara door sensor)
So not only get a message once at sunset, or once as it opens, but every time it is open for any amount of time after sunset, and keep getting a message every x minutes (only during sun not out) unil the awning is closed.
All I can find now are ways to do this once as a state change (open/closed, sunset), but I’m looking for a more continuous monitoring method.
Make an automation that shuts it at sunset. Then make an automation that messages you if it opens between sunset and sunrise. No reason for a time pattern. If you really want a time pattern you can do that, but it’ll get annoying. Sometimes you should let go of control on a device and have automations do it for you.
Personally, I’d have my system train me and other people. It would shut the awning at sunset, and any time it opens I would notify the house through TTS and a notification that they shouldn’t have done that. Then shut the awning. Over time, I’d never have to touch the awning again and other people would learn not to. Then you wouldn’t have situations where you ‘inadvertently opened the awning’.
alias: Awning Reminder
description: ''
mode: single
trigger:
- platform: state
entity_id: binary_sensor.awning
to: 'on'
for: '00:01:00'
- platform: sun
event: sunset
offset: '+00:01:00'
- platform: homeassistant
event: start
condition:
- condition: sun
before: sunrise
after: sunset
- condition: state
entity_id: binary_sensor.awning
state: 'on'
action:
- repeat:
while:
- condition: state
entity_id: binary_sensor.awning
state: 'on'
sequence:
- service: notify.mobile_app
data:
message: Please close xxxxxx
- delay:
hours: 0
minutes: 2
seconds: 0
milliseconds: 0
Replace binary_sensor.awning and notify.mobile_app to match your entity_id.
Explanation of Triggers
This will trigger the automation if the awning is open for more than 1 minutes-
- platform: state
entity_id: binary_sensor.awning
to: 'on'
for: '00:01:00'
This is to anticipate if the awning is already in open position before the sunset-
- platform: sun
event: sunset
offset: '+00:01:00'
This is to anticipate server reboot/crashes
- platform: homeassistant
event: start
Explanation of Conditions
To make sure automation is executed only if it is between sunset and sunrise and only when the awning is opened
condition:
- condition: sun
before: sunrise
after: sunset
- condition: state
entity_id: binary_sensor.awning
state: 'on'
Explanation of Action
The action uses Repeat While Loop function where the sequence will be run as long as the condition(s) evaluate to true. A delay of 2 minutes is added before the condition is re-checked.
Hi, sorry I was away on a long weekend, now looking at these solutions
This sounds very good; I actually didn’t know I could easily do a while-loop in HA, that would make things easier!
Will try this tonight at home!
FYI: the reason the awning was accidentally opened, is that I’m using an RFXcom to open/close this. When multiple signals als sent, things sometimes go wrong. Since at night my automatic roller curtains are also down, you can’t see it went wrong.
However, I will also add an attempt to close the awning, and only start sending reminders if the binary sensor indicates the closing action failed.