Alerts with "skip_first: True" should not have their entity states go from 'idle' to 'on' until they actually fire for the first time
See original GitHub issueThe problem
The Alert integration creates entities that have “idle” or “on” states. The “skip_first” attribute for these entities is often used to alert the user after a certain time period (most common being e.g. a door left open for more than 5 minutes). However, the state of this entity turns “on” immediately when the tracked entity switches to the required state instead of when the Alert actually fires. This not only spams the Logbook for those preferring to track the Alert states every time a door is opened (even if the door was open less than skip_first
requires to actually activate the Alert), but because of the simplicity of the Alert integration, simply repeats in the database, logbook, and history the state of the tracked entity instead of providing anything useful (which would be seeing when the Alerts were actually activated).
So all in all, I believe the more correct behavior for Alerts is that the Alert entities should only turn “on” when the Alert first fires when skip_first
is specified.
The documentation seems to imply this should already be the case (not sure what it means by “add an entity to the front end” because you can add the entity to a view as soon as you create the configuration for it), but it is not:
Alerts will add an entity to the front end only when they are firing. This entity allows you to silence an alert until it is resolved.
Environment
- Home Assistant Core release with the issue: 0.112.3
- Last working Home Assistant Core release (if known): N/A
- Operating environment (OS/Container/Supervised/Core): Container
- Integration causing this issue: Alert
- Link to integration documentation on our website: https://www.home-assistant.io/integrations/alert/
Problem-relevant configuration.yaml
alert:
front_door_left_open:
name: Front Door left open
entity_id: binary_sensor.front_door
state: 'on'
repeat:
- 3
- 15
- 30
- 60
- 120
skip_first: true
can_acknowledge: true
message: "Warning: Front Door has been left open for {{ relative_time(states.binary_sensor.front_door.last_changed) }}."
notifiers:
- slack
Traceback/Error logs
Additional information
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (9 by maintainers)
Top GitHub Comments
FYI: I did run into the same problem and opened a PR to fix it: https://github.com/home-assistant/core/pull/65948
@melyux if we find someone to review it, then I am happy to update my PR. The code runs flawlessly in my fork of Home Assistant for months now.