Adjust callback registration
This commit is contained in:
parent
a766ac1c5d
commit
88c179f870
2 changed files with 12 additions and 0 deletions
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue