Address late review of Switcher sensor migration (#52186)

This commit is contained in:
Shay Levy 2021-06-26 08:30:47 +03:00 committed by GitHub
parent cd9fa27f2a
commit 568e1b379d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 14 deletions

View File

@ -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()

View File

@ -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,9 +135,9 @@ 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: