Skip to content

Commit

Permalink
fix to remove state error
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeneef committed Sep 28, 2024
1 parent 340fdce commit 5b51978
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion custom_components/gpiod/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ async def async_added_to_hass(self) -> None:
"""Call when the switch is added to hass."""
await super().async_added_to_hass()
state = await self.async_get_last_state()
_LOGGER.debug(f"GPIODSwitch async_added_to_has initial port: {self._port} persistent: {self._persistent} state: {state.state}")
if not state or not self._persistent:
self.is_on = False
else:
_LOGGER.debug(f"GPIODSwitch async_added_to_has initial port: {self._port} persistent: {self._persistent} state: {state.state}")
self.is_on = True if state.state == STATE_ON else False
self._hub.add_switch(self, self._port, self._active_low, self._bias, self._drive_mode)
self.async_write_ha_state()
Expand Down

0 comments on commit 5b51978

Please sign in to comment.