Restore state of trigger based template binary sensor - #67538
Conversation
|
Hey there @PhracturedBlue, @tetienne, @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( |
| is not None | ||
| and last_state.state not in (STATE_UNKNOWN, STATE_UNAVAILABLE) | ||
| ): | ||
| self._state = last_state.state == STATE_ON |
There was a problem hiding this comment.
Maybe we should only restore state if either of CONF_AUTO_OFF; CONF_DELAY_ON; CONF_DELAY_OFF are set?
There was a problem hiding this comment.
IMO restart/reload should not change the state of a trigger entity, only the trigger should. So they all should restore state to ensure that they always remain in whatever state was determined by the last trigger until the next trigger.
I am fine with adding a config option to control this behavior though in case there are cases I'm not considering where not restoring state is desirable. I don't know if I agree that the auto_off, delay_on and delay_off options make them more restorable. If anything auto_off sensors are the only ones that we could maybe skip restoring and just default to off for the reasons suggested by the author in the linked issue. But I think what you're doing here with restoring both the state and the timer sounds much better, I really like it.
a7e96ad to
804fc77
Compare
Breaking change
Trigger based template binary sensors now initialized to the last state, instead of to "unknown".
Proposed change
Restore state of trigger based template binary sensor:
auto_offconfigured, the timer is restartedonbut the timer has already expired when restoring the state, state is set toonType of change
Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: