mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 19:09:32 +00:00
Streamline naming in deCONZ integration (#111977)
This commit is contained in:
@@ -31,7 +31,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import ATTR_DARK, ATTR_ON
|
||||
from .deconz_device import DeconzDevice
|
||||
from .hub import DeconzHub, get_gateway_from_config_entry
|
||||
from .hub import DeconzHub
|
||||
|
||||
_SensorDeviceT = TypeVar("_SensorDeviceT", bound=PydeconzSensorBase)
|
||||
|
||||
@@ -168,13 +168,13 @@ async def async_setup_entry(
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the deCONZ binary sensor."""
|
||||
gateway = get_gateway_from_config_entry(hass, config_entry)
|
||||
gateway.entities[DOMAIN] = set()
|
||||
hub = DeconzHub.get_hub(hass, config_entry)
|
||||
hub.entities[DOMAIN] = set()
|
||||
|
||||
@callback
|
||||
def async_add_sensor(_: EventType, sensor_id: str) -> None:
|
||||
"""Add sensor from deCONZ."""
|
||||
sensor = gateway.api.sensors[sensor_id]
|
||||
sensor = hub.api.sensors[sensor_id]
|
||||
|
||||
for description in ENTITY_DESCRIPTIONS:
|
||||
if (
|
||||
@@ -182,11 +182,11 @@ async def async_setup_entry(
|
||||
and not isinstance(sensor, description.instance_check)
|
||||
) or description.value_fn(sensor) is None:
|
||||
continue
|
||||
async_add_entities([DeconzBinarySensor(sensor, gateway, description)])
|
||||
async_add_entities([DeconzBinarySensor(sensor, hub, description)])
|
||||
|
||||
gateway.register_platform_add_device_callback(
|
||||
hub.register_platform_add_device_callback(
|
||||
async_add_sensor,
|
||||
gateway.api.sensors,
|
||||
hub.api.sensors,
|
||||
)
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ class DeconzBinarySensor(DeconzDevice[SensorResources], BinarySensorEntity):
|
||||
def __init__(
|
||||
self,
|
||||
device: SensorResources,
|
||||
gateway: DeconzHub,
|
||||
hub: DeconzHub,
|
||||
description: DeconzBinarySensorDescription,
|
||||
) -> None:
|
||||
"""Initialize deCONZ binary sensor."""
|
||||
@@ -208,7 +208,7 @@ class DeconzBinarySensor(DeconzDevice[SensorResources], BinarySensorEntity):
|
||||
self._update_key = description.update_key
|
||||
if description.name_suffix:
|
||||
self._name_suffix = description.name_suffix
|
||||
super().__init__(device, gateway)
|
||||
super().__init__(device, hub)
|
||||
|
||||
if (
|
||||
self.entity_description.key in PROVIDES_EXTRA_ATTRIBUTES
|
||||
|
||||
Reference in New Issue
Block a user