diff --git a/homeassistant/components/raspihats/binary_sensor.py b/homeassistant/components/raspihats/binary_sensor.py index f8fbc0d010f..e027d766bcb 100644 --- a/homeassistant/components/raspihats/binary_sensor.py +++ b/homeassistant/components/raspihats/binary_sensor.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import TYPE_CHECKING import voluptuous as vol @@ -108,6 +109,11 @@ class I2CHatBinarySensor(BinarySensorEntity): self._device_class = device_class self._state = self.I2C_HATS_MANAGER.read_di(self._address, self._channel) + async def async_added_to_hass(self) -> None: + """Register callbacks.""" + if TYPE_CHECKING: + assert self.I2C_HATS_MANAGER + def online_callback(): """Call fired when board is online.""" self.schedule_update_ha_state() diff --git a/homeassistant/components/raspihats/switch.py b/homeassistant/components/raspihats/switch.py index c67a2b4ab8f..bf9c14e87ed 100644 --- a/homeassistant/components/raspihats/switch.py +++ b/homeassistant/components/raspihats/switch.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import TYPE_CHECKING import voluptuous as vol @@ -108,6 +109,11 @@ class I2CHatSwitch(ToggleEntity): state = initial_state self.I2C_HATS_MANAGER.write_dq(self._address, self._channel, state) + async def async_added_to_hass(self) -> None: + """Register callbacks.""" + if TYPE_CHECKING: + assert self.I2C_HATS_MANAGER + def online_callback(): """Call fired when board is online.""" self.schedule_update_ha_state()