Fritz cleanup: part1 (naming) (#63535)
This commit is contained in:
parent
53d86d4317
commit
60b6871b46
9 changed files with 152 additions and 156 deletions
|
@ -281,12 +281,12 @@ async def async_setup_entry(
|
|||
) -> None:
|
||||
"""Set up entry."""
|
||||
_LOGGER.debug("Setting up FRITZ!Box sensors")
|
||||
fritzbox_tools: FritzBoxTools = hass.data[DOMAIN][entry.entry_id]
|
||||
avm_device: FritzBoxTools = hass.data[DOMAIN][entry.entry_id]
|
||||
|
||||
dsl: bool = False
|
||||
try:
|
||||
dslinterface = await hass.async_add_executor_job(
|
||||
fritzbox_tools.connection.call_action,
|
||||
avm_device.connection.call_action,
|
||||
"WANDSLInterfaceConfig:1",
|
||||
"GetInfo",
|
||||
)
|
||||
|
@ -300,10 +300,10 @@ async def async_setup_entry(
|
|||
pass
|
||||
|
||||
entities = [
|
||||
FritzBoxSensor(fritzbox_tools, entry.title, description)
|
||||
FritzBoxSensor(avm_device, entry.title, description)
|
||||
for description in SENSOR_TYPES
|
||||
if (dsl or description.connection_type != DSL_CONNECTION)
|
||||
and description.exclude_mesh_role != fritzbox_tools.mesh_role
|
||||
and description.exclude_mesh_role != avm_device.mesh_role
|
||||
]
|
||||
|
||||
async_add_entities(entities, True)
|
||||
|
@ -316,7 +316,7 @@ class FritzBoxSensor(FritzBoxBaseEntity, SensorEntity):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
fritzbox_tools: FritzBoxTools,
|
||||
avm_device: FritzBoxTools,
|
||||
device_friendly_name: str,
|
||||
description: FritzSensorEntityDescription,
|
||||
) -> None:
|
||||
|
@ -325,15 +325,15 @@ class FritzBoxSensor(FritzBoxBaseEntity, SensorEntity):
|
|||
self._last_device_value: str | None = None
|
||||
self._attr_available = True
|
||||
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 sensors")
|
||||
|
||||
try:
|
||||
status: FritzStatus = self._fritzbox_tools.fritz_status
|
||||
status: FritzStatus = self._avm_device.fritz_status
|
||||
self._attr_available = True
|
||||
except FritzConnectionException:
|
||||
_LOGGER.error("Error getting the state from the FRITZ!Box", exc_info=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue