diff --git a/homeassistant/components/switcher_kis/sensor.py b/homeassistant/components/switcher_kis/sensor.py index 037e7297cee..5b6b40a0e2d 100644 --- a/homeassistant/components/switcher_kis/sensor.py +++ b/homeassistant/components/switcher_kis/sensor.py @@ -13,7 +13,7 @@ from homeassistant.components.sensor import ( SensorEntity, ) from homeassistant.const import ELECTRICAL_CURRENT_AMPERE, POWER_WATT -from homeassistant.core import HomeAssistant +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import DiscoveryInfoType, StateType @@ -124,8 +124,8 @@ class SwitcherSensorEntity(SensorEntity): ) ) - async def async_update_data(self, device_data: SwitcherV2Device) -> None: + @callback + def async_update_data(self, device_data: SwitcherV2Device) -> None: """Update the entity data.""" - if device_data: - self._device_data = device_data - self.async_write_ha_state() + self._device_data = device_data + self.async_write_ha_state() diff --git a/homeassistant/components/switcher_kis/switch.py b/homeassistant/components/switcher_kis/switch.py index 27d9e16e1f8..21ebcf54cc7 100644 --- a/homeassistant/components/switcher_kis/switch.py +++ b/homeassistant/components/switcher_kis/switch.py @@ -13,7 +13,7 @@ from aioswitcher.devices import SwitcherV2Device import voluptuous as vol from homeassistant.components.switch import SwitchEntity -from homeassistant.core import HomeAssistant, ServiceCall +from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -135,15 +135,15 @@ class SwitcherControl(SwitchEntity): ) ) - async def async_update_data(self, device_data: SwitcherV2Device) -> None: + @callback + def async_update_data(self, device_data: SwitcherV2Device) -> None: """Update the entity data.""" - if device_data: - if self._self_initiated: - self._self_initiated = False - else: - self._device_data = device_data - self._state = self._device_data.state - self.async_write_ha_state() + if self._self_initiated: + self._self_initiated = False + else: + self._device_data = device_data + self._state = self._device_data.state + self.async_write_ha_state() async def async_turn_on(self, **kwargs: dict) -> None: """Turn the entity on."""