I’d like to get feedback on an issue I have logged.
I believe this is an edge case not catered for with the introduction (standardisation) of allowing unknown states for binary sensors.
I want to be clear that this isn’t an objection against the use of the unknown state – only that there is an edge case where it doesn’t actually make sense (to me).
When using template binary sensor triggered by an event, the sensor will have an unknown state (e.g. after an HA restart) until triggered for the first time. At this point, it may still make sense to allow an unknown state, but once the auto_off
option gets specified, it indirectly implies a sensor that’s normally off (by default) and sometimes on (when triggered). Considering this, it would be impossible for the sensor to have any other state.
It would not be an option to perform any kind of artificial triggering, since it may lead to undesired consequences.
Perhaps one option is to introduce an initial_state
option to make this explicit (rather than inferring a default state from auto_off
).
There doesn’t seem to be any workarounds.
- trigger:
- platform: event
# the type below can really be set to any valid event type for the purposes of illustration
event_type: amcrest
# the next section can be omitted, but i wanted to include my full config to make the specific issue clear
event_data:
event: CallNoAnswered
payload:
action: Start
binary_sensor:
name: Doorbell Rang
state: true
auto_off: 5 # seconds
Documentation: Template - Home Assistant (home-assistant.io)