Skip to content

Commit

Permalink
✨ Add logging to debug last state retrieval in async_added_to_hass me…
Browse files Browse the repository at this point in the history
…thod.
  • Loading branch information
basbruss committed Apr 8, 2024
1 parent 2a9eabd commit 2265e17
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/adaptive_cover/switch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Switch platform for the Adaptive Cover integration."""

from __future__ import annotations

import logging
from typing import Any

from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity
Expand Down Expand Up @@ -138,10 +138,10 @@ async def async_turn_off(self, **kwargs: Any) -> None:
async def async_added_to_hass(self) -> None:
"""Call when entity about to be added to hass."""
last_state = await self.async_get_last_state()
# _LOGGER.debug("%s: last state is %s", self._name, last_state)
_LOGGER.debug("%s: last state is %s", self._name, last_state)
if (last_state is None and self._initial_state) or (
last_state is not None and last_state.state == STATE_ON
):
await self.async_turn_on()
else:
await self.async_turn_off()
await self.async_turn_off()

0 comments on commit 2265e17

Please sign in to comment.