Fritz cleanup: part1 (naming) (#63535)
This commit is contained in:
parent
53d86d4317
commit
60b6871b46
9 changed files with 152 additions and 156 deletions
|
@ -55,12 +55,12 @@ async def async_setup_entry(
|
|||
) -> None:
|
||||
"""Set up entry."""
|
||||
_LOGGER.debug("Setting up FRITZ!Box binary sensors")
|
||||
fritzbox_tools: FritzBoxTools = hass.data[DOMAIN][entry.entry_id]
|
||||
avm_device: FritzBoxTools = hass.data[DOMAIN][entry.entry_id]
|
||||
|
||||
entities = [
|
||||
FritzBoxBinarySensor(fritzbox_tools, entry.title, description)
|
||||
FritzBoxBinarySensor(avm_device, entry.title, description)
|
||||
for description in SENSOR_TYPES
|
||||
if (description.exclude_mesh_role != fritzbox_tools.mesh_role)
|
||||
if (description.exclude_mesh_role != avm_device.mesh_role)
|
||||
]
|
||||
|
||||
async_add_entities(entities, True)
|
||||
|
@ -71,27 +71,27 @@ class FritzBoxBinarySensor(FritzBoxBaseEntity, BinarySensorEntity):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
fritzbox_tools: FritzBoxTools,
|
||||
avm_device: FritzBoxTools,
|
||||
device_friendly_name: str,
|
||||
description: BinarySensorEntityDescription,
|
||||
) -> None:
|
||||
"""Init FRITZ!Box connectivity class."""
|
||||
self.entity_description = description
|
||||
self._attr_name = f"{device_friendly_name} {description.name}"
|
||||
self._attr_unique_id = f"{fritzbox_tools.unique_id}-{description.key}"
|
||||
super().__init__(fritzbox_tools, device_friendly_name)
|
||||
self._attr_unique_id = f"{avm_device.unique_id}-{description.key}"
|
||||
super().__init__(avm_device, device_friendly_name)
|
||||
|
||||
def update(self) -> None:
|
||||
"""Update data."""
|
||||
_LOGGER.debug("Updating FRITZ!Box binary sensors")
|
||||
|
||||
if self.entity_description.key == "firmware_update":
|
||||
self._attr_is_on = self._fritzbox_tools.update_available
|
||||
self._attr_is_on = self._avm_device.update_available
|
||||
self._attr_extra_state_attributes = {
|
||||
"installed_version": self._fritzbox_tools.current_firmware,
|
||||
"latest_available_version": self._fritzbox_tools.latest_firmware,
|
||||
"installed_version": self._avm_device.current_firmware,
|
||||
"latest_available_version": self._avm_device.latest_firmware,
|
||||
}
|
||||
if self.entity_description.key == "is_connected":
|
||||
self._attr_is_on = bool(self._fritzbox_tools.fritz_status.is_connected)
|
||||
self._attr_is_on = bool(self._avm_device.fritz_status.is_connected)
|
||||
elif self.entity_description.key == "is_linked":
|
||||
self._attr_is_on = bool(self._fritzbox_tools.fritz_status.is_linked)
|
||||
self._attr_is_on = bool(self._avm_device.fritz_status.is_linked)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue