I have several alerts set up and find them very useful and effective. However, a couple of them do not need to alert during weekdays work hours.
How can I automate this? On the alert card there is a switch to turn it off and I’d like to be able to automate that switch based on time.
Here is an example of an alert that I am using:
garage_door:
name: Garage is open
done_message: Garage door has now closed
entity_id: binary_sensor.garage_door
state: 'on'
repeat: 10
can_acknowledge: True
skip_first: True
notifiers:
- Prowl
I think what I need to do is automate state: ‘on’ to become off at certain times, but my experience so far has not yet come across a way to do this.
Can state: be set to a variable that I can change?
Possibly, when a battery percentage falls below a threshold. Maybe you want to disable the alert on certain days.
The example below that quote is only for battery percentage. I’m still unclear on a solution to this, short of checking another state in the binary sensor.
For example, I want binary_sensor.garage_door to display the correct state of the garage door always (checks just one values) however I only want the alert to fire at night. How to achieve this?
Create a template binary_sensor called binary_sensor.garage_door_alert with a value_template that indicates on only when binary_sensor.garage_door is on AND the current time is “at night”.
Create an alert that is activated when the state of binary_sensor.garage_door_alert is on.
How you go about defining “at night” is up to you. For example, you could create a Time of the Day Binary Sensor called binary_sensor.is_night.
binary_sensor:
- platform: tod
name: Is Night
after: sunset
before: sunrise
Putting it all together results in something like this:
OK, I didn’t interpret ‘short of checking another binary sensor’ as meaning a desire to avoid doing it. My mistake.
The fact is the alert component is limited to monitoring another entity’s state. Period. It doesn’t support a value_template. Therefore you have no ability to create complex criteria within it, only within whatever other entity it is monitoring.
Your existing binary_sensor.garage_door reports the door’s state at all times (not just night) so some other sensor is needed to monitor the garage door AND the desired time period.
Note that is feature “tod” has been broken since it was introduced. It does not set correctly when you restart HA and the start time is the day before. Typically sunset to sunrise fails when you restart HA after midnight. There is a work around I just added while we wait for the bug to be fixed