Address late review of fritzbox (#82369)
This commit is contained in:
parent
93897016f0
commit
217d8eb9c5
8 changed files with 83 additions and 78 deletions
|
@ -8,7 +8,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import FritzBoxDeviceEntity
|
||||
from . import FritzboxDataUpdateCoordinator, FritzBoxDeviceEntity
|
||||
from .const import CONF_COORDINATOR, DOMAIN as FRITZBOX_DOMAIN
|
||||
|
||||
|
||||
|
@ -16,7 +16,9 @@ async def async_setup_entry(
|
|||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
) -> None:
|
||||
"""Set up the FRITZ!SmartHome switch from ConfigEntry."""
|
||||
coordinator = hass.data[FRITZBOX_DOMAIN][entry.entry_id][CONF_COORDINATOR]
|
||||
coordinator: FritzboxDataUpdateCoordinator = hass.data[FRITZBOX_DOMAIN][
|
||||
entry.entry_id
|
||||
][CONF_COORDINATOR]
|
||||
|
||||
async_add_entities(
|
||||
[
|
||||
|
@ -33,14 +35,14 @@ class FritzboxSwitch(FritzBoxDeviceEntity, SwitchEntity):
|
|||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return true if the switch is on."""
|
||||
return self.entity.switch_state # type: ignore [no-any-return]
|
||||
return self.data.switch_state # type: ignore [no-any-return]
|
||||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch on."""
|
||||
await self.hass.async_add_executor_job(self.entity.set_switch_state_on)
|
||||
await self.hass.async_add_executor_job(self.data.set_switch_state_on)
|
||||
await self.coordinator.async_refresh()
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch off."""
|
||||
await self.hass.async_add_executor_job(self.entity.set_switch_state_off)
|
||||
await self.hass.async_add_executor_job(self.data.set_switch_state_off)
|
||||
await self.coordinator.async_refresh()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue