mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Code improvements for microbees component (#111208)
This commit is contained in:
parent
d9addc45f9
commit
efd1ed86ae
@ -66,15 +66,13 @@ async def async_setup_entry(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Config entry."""
|
"""Config entry."""
|
||||||
coordinator = hass.data[DOMAIN][entry.entry_id].coordinator
|
coordinator = hass.data[DOMAIN][entry.entry_id].coordinator
|
||||||
sensors = []
|
|
||||||
for bee_id, bee in coordinator.data.bees.items():
|
|
||||||
for sensor in bee.sensors:
|
|
||||||
if (entity_description := SENSOR_TYPES.get(sensor.device_type)) is not None:
|
|
||||||
sensors.append(
|
|
||||||
MBSensor(coordinator, entity_description, bee_id, sensor.id)
|
|
||||||
)
|
|
||||||
|
|
||||||
async_add_entities(sensors)
|
async_add_entities(
|
||||||
|
MBSensor(coordinator, desc, bee_id, sensor.id)
|
||||||
|
for bee_id, bee in coordinator.data.bees.items()
|
||||||
|
for sensor in bee.sensors
|
||||||
|
if (desc := SENSOR_TYPES.get(sensor.device_type)) is not None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MBSensor(MicroBeesEntity, SensorEntity):
|
class MBSensor(MicroBeesEntity, SensorEntity):
|
||||||
|
@ -12,6 +12,7 @@ from .coordinator import MicroBeesUpdateCoordinator
|
|||||||
from .entity import MicroBeesActuatorEntity
|
from .entity import MicroBeesActuatorEntity
|
||||||
|
|
||||||
SOCKET_TRANSLATIONS = {46: "socket_it", 38: "socket_eu"}
|
SOCKET_TRANSLATIONS = {46: "socket_it", 38: "socket_eu"}
|
||||||
|
SWITCH_PRODUCT_IDS = {25, 26, 27, 35, 38, 46, 63, 64, 65, 86}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@ -19,13 +20,13 @@ async def async_setup_entry(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Config entry."""
|
"""Config entry."""
|
||||||
coordinator = hass.data[DOMAIN][entry.entry_id].coordinator
|
coordinator = hass.data[DOMAIN][entry.entry_id].coordinator
|
||||||
switches = []
|
|
||||||
for bee_id, bee in coordinator.data.bees.items():
|
|
||||||
if bee.productID in (25, 26, 27, 35, 38, 46, 63, 64, 65, 86):
|
|
||||||
for switch in bee.actuators:
|
|
||||||
switches.append(MBSwitch(coordinator, bee_id, switch.id))
|
|
||||||
|
|
||||||
async_add_entities(switches)
|
async_add_entities(
|
||||||
|
MBSwitch(coordinator, bee_id, switch.id)
|
||||||
|
for bee_id, bee in coordinator.data.bees.items()
|
||||||
|
if bee.productID in SWITCH_PRODUCT_IDS
|
||||||
|
for switch in bee.actuators
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MBSwitch(MicroBeesActuatorEntity, SwitchEntity):
|
class MBSwitch(MicroBeesActuatorEntity, SwitchEntity):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user