Manually turning off a presence simulation does not seem to reliably persist across HA restarts. I think the issue is that the calls to internal_turn_on / internal_turn_off update self._state, but don't communicate that state change to the HA state machine via self.async_write_ha_state(). And so if HA restarts, _restore_state_sync won't see the state change.
This patch fixes that by calling self.async_write_ha_state() inside the turn_on/turn_off routines.
Manually turning off a presence simulation does not seem to reliably persist across HA restarts. I think the issue is that the calls to internal_turn_on / internal_turn_off update self._state, but don't communicate that state change to the HA state machine via self.async_write_ha_state(). And so if HA restarts, _restore_state_sync won't see the state change.
This patch fixes that by calling self.async_write_ha_state() inside the turn_on/turn_off routines.