mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Improve lists in integrations [X-Z] (#113253)
This commit is contained in:
parent
64b42a3651
commit
4547131bbc
@ -109,18 +109,18 @@ async def build_item_response(
|
||||
content_types = sorted(
|
||||
{app.content_type for app in apps.result if app.content_type in TYPE_MAP}
|
||||
)
|
||||
for c_type in content_types:
|
||||
children.append(
|
||||
BrowseMedia(
|
||||
media_class=MediaClass.DIRECTORY,
|
||||
media_content_id=c_type,
|
||||
media_content_type=TYPE_MAP[c_type].type,
|
||||
title=f"{c_type}s",
|
||||
can_play=False,
|
||||
can_expand=True,
|
||||
children_media_class=TYPE_MAP[c_type].cls,
|
||||
)
|
||||
children.extend(
|
||||
BrowseMedia(
|
||||
media_class=MediaClass.DIRECTORY,
|
||||
media_content_id=c_type,
|
||||
media_content_type=TYPE_MAP[c_type].type,
|
||||
title=f"{c_type}s",
|
||||
can_play=False,
|
||||
can_expand=True,
|
||||
children_media_class=TYPE_MAP[c_type].cls,
|
||||
)
|
||||
for c_type in content_types
|
||||
)
|
||||
|
||||
return library_info
|
||||
|
||||
|
@ -28,12 +28,12 @@ async def async_setup_entry(
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Perform the setup for Xiaomi devices."""
|
||||
entities = []
|
||||
gateway = hass.data[DOMAIN][GATEWAYS_KEY][config_entry.entry_id]
|
||||
for device in gateway.devices["lock"]:
|
||||
if device["model"] == "lock.aq1":
|
||||
entities.append(XiaomiAqaraLock(device, "Lock", gateway, config_entry))
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
XiaomiAqaraLock(device, "Lock", gateway, config_entry)
|
||||
for device in gateway.devices["lock"]
|
||||
if device["model"] == "lock.aq1"
|
||||
)
|
||||
|
||||
|
||||
class XiaomiAqaraLock(LockEntity, XiaomiDevice):
|
||||
|
@ -62,18 +62,14 @@ class XiaomiMiioDeviceScanner(DeviceScanner):
|
||||
|
||||
async def async_scan_devices(self):
|
||||
"""Scan for devices and return a list containing found device IDs."""
|
||||
devices = []
|
||||
try:
|
||||
station_info = await self.hass.async_add_executor_job(self.device.status)
|
||||
_LOGGER.debug("Got new station info: %s", station_info)
|
||||
|
||||
for device in station_info.associated_stations:
|
||||
devices.append(device["mac"])
|
||||
|
||||
except DeviceException as ex:
|
||||
_LOGGER.error("Unable to fetch the state: %s", ex)
|
||||
return []
|
||||
|
||||
return devices
|
||||
return [device["mac"] for device in station_info.associated_stations]
|
||||
|
||||
async def async_get_device_name(self, device):
|
||||
"""Return None.
|
||||
|
@ -211,27 +211,24 @@ async def async_setup_entry(
|
||||
if model not in MODEL_TO_ATTR_MAP:
|
||||
return
|
||||
|
||||
entities = []
|
||||
unique_id = config_entry.unique_id
|
||||
device = hass.data[DOMAIN][config_entry.entry_id][KEY_DEVICE]
|
||||
coordinator = hass.data[DOMAIN][config_entry.entry_id][KEY_COORDINATOR]
|
||||
attributes = MODEL_TO_ATTR_MAP[model]
|
||||
|
||||
for description in SELECTOR_TYPES:
|
||||
for attribute in attributes:
|
||||
if description.key == attribute.attr_name:
|
||||
entities.append(
|
||||
XiaomiGenericSelector(
|
||||
device,
|
||||
config_entry,
|
||||
f"{description.key}_{unique_id}",
|
||||
coordinator,
|
||||
description,
|
||||
attribute.enum_class,
|
||||
)
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
XiaomiGenericSelector(
|
||||
device,
|
||||
config_entry,
|
||||
f"{description.key}_{unique_id}",
|
||||
coordinator,
|
||||
description,
|
||||
attribute.enum_class,
|
||||
)
|
||||
for description in SELECTOR_TYPES
|
||||
for attribute in attributes
|
||||
if description.key == attribute.attr_name
|
||||
)
|
||||
|
||||
|
||||
class XiaomiSelector(XiaomiCoordinatedMiioEntity, SelectEntity):
|
||||
|
@ -349,7 +349,6 @@ async def async_setup_entry(
|
||||
|
||||
async def async_setup_coordinated_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the coordinated switch from a config entry."""
|
||||
entities = []
|
||||
model = config_entry.data[CONF_MODEL]
|
||||
unique_id = config_entry.unique_id
|
||||
device = hass.data[DOMAIN][config_entry.entry_id][KEY_DEVICE]
|
||||
@ -371,19 +370,17 @@ async def async_setup_coordinated_entry(hass, config_entry, async_add_entities):
|
||||
elif model in MODELS_PURIFIER_MIOT:
|
||||
device_features = FEATURE_FLAGS_AIRPURIFIER_MIOT
|
||||
|
||||
for description in SWITCH_TYPES:
|
||||
if description.feature & device_features:
|
||||
entities.append(
|
||||
XiaomiGenericCoordinatedSwitch(
|
||||
device,
|
||||
config_entry,
|
||||
f"{description.key}_{unique_id}",
|
||||
coordinator,
|
||||
description,
|
||||
)
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
XiaomiGenericCoordinatedSwitch(
|
||||
device,
|
||||
config_entry,
|
||||
f"{description.key}_{unique_id}",
|
||||
coordinator,
|
||||
description,
|
||||
)
|
||||
for description in SWITCH_TYPES
|
||||
if description.feature & device_features
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_other_entry(hass, config_entry, async_add_entities):
|
||||
|
@ -23,14 +23,12 @@ def setup_platform(
|
||||
"""Set up the XS1 switch platform."""
|
||||
actuators = hass.data[COMPONENT_DOMAIN][ACTUATORS]
|
||||
|
||||
switch_entities = []
|
||||
for actuator in actuators:
|
||||
if (actuator.type() == ActuatorType.SWITCH) or (
|
||||
actuator.type() == ActuatorType.DIMMER
|
||||
):
|
||||
switch_entities.append(XS1SwitchEntity(actuator))
|
||||
|
||||
add_entities(switch_entities)
|
||||
add_entities(
|
||||
XS1SwitchEntity(actuator)
|
||||
for actuator in actuators
|
||||
if (actuator.type() == ActuatorType.SWITCH)
|
||||
or (actuator.type() == ActuatorType.DIMMER)
|
||||
)
|
||||
|
||||
|
||||
class XS1SwitchEntity(XS1DeviceEntity, SwitchEntity):
|
||||
|
@ -52,11 +52,12 @@ async def async_setup_entry(
|
||||
coordinator: YaleDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id][
|
||||
COORDINATOR
|
||||
]
|
||||
sensors: list[YaleDoorSensor | YaleProblemSensor] = []
|
||||
for data in coordinator.data["door_windows"]:
|
||||
sensors.append(YaleDoorSensor(coordinator, data))
|
||||
for description in SENSOR_TYPES:
|
||||
sensors.append(YaleProblemSensor(coordinator, description))
|
||||
sensors: list[YaleDoorSensor | YaleProblemSensor] = [
|
||||
YaleDoorSensor(coordinator, data) for data in coordinator.data["door_windows"]
|
||||
]
|
||||
sensors.extend(
|
||||
YaleProblemSensor(coordinator, description) for description in SENSOR_TYPES
|
||||
)
|
||||
|
||||
async_add_entities(sensors)
|
||||
|
||||
|
@ -901,13 +901,13 @@ class MusicCastMediaPlayer(MusicCastDeviceEntity, MediaPlayerEntity):
|
||||
return
|
||||
|
||||
_LOGGER.debug("%s updates his group members", self.entity_id)
|
||||
client_ips_for_removal = []
|
||||
for expected_client_ip in self.coordinator.data.group_client_list:
|
||||
if expected_client_ip not in [
|
||||
entity.ip_address for entity in self.musiccast_group
|
||||
]:
|
||||
# The client is no longer part of the group. Prepare removal.
|
||||
client_ips_for_removal.append(expected_client_ip)
|
||||
client_ips_for_removal = [
|
||||
expected_client_ip
|
||||
for expected_client_ip in self.coordinator.data.group_client_list
|
||||
# The client is no longer part of the group. Prepare removal.
|
||||
if expected_client_ip
|
||||
not in [entity.ip_address for entity in self.musiccast_group]
|
||||
]
|
||||
|
||||
if client_ips_for_removal:
|
||||
_LOGGER.debug(
|
||||
|
@ -20,16 +20,18 @@ async def async_setup_entry(
|
||||
"""Set up MusicCast number entities based on a config entry."""
|
||||
coordinator: MusicCastDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
|
||||
number_entities = []
|
||||
number_entities = [
|
||||
NumberCapability(coordinator, capability)
|
||||
for capability in coordinator.data.capabilities
|
||||
if isinstance(capability, NumberSetter)
|
||||
]
|
||||
|
||||
for capability in coordinator.data.capabilities:
|
||||
if isinstance(capability, NumberSetter):
|
||||
number_entities.append(NumberCapability(coordinator, capability))
|
||||
|
||||
for zone, data in coordinator.data.zones.items():
|
||||
for capability in data.capabilities:
|
||||
if isinstance(capability, NumberSetter):
|
||||
number_entities.append(NumberCapability(coordinator, capability, zone))
|
||||
number_entities.extend(
|
||||
NumberCapability(coordinator, capability, zone)
|
||||
for zone, data in coordinator.data.zones.items()
|
||||
for capability in data.capabilities
|
||||
if isinstance(capability, NumberSetter)
|
||||
)
|
||||
|
||||
async_add_entities(number_entities)
|
||||
|
||||
|
@ -21,18 +21,18 @@ async def async_setup_entry(
|
||||
"""Set up MusicCast select entities based on a config entry."""
|
||||
coordinator: MusicCastDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
|
||||
select_entities = []
|
||||
select_entities = [
|
||||
SelectableCapability(coordinator, capability)
|
||||
for capability in coordinator.data.capabilities
|
||||
if isinstance(capability, OptionSetter)
|
||||
]
|
||||
|
||||
for capability in coordinator.data.capabilities:
|
||||
if isinstance(capability, OptionSetter):
|
||||
select_entities.append(SelectableCapability(coordinator, capability))
|
||||
|
||||
for zone, data in coordinator.data.zones.items():
|
||||
for capability in data.capabilities:
|
||||
if isinstance(capability, OptionSetter):
|
||||
select_entities.append(
|
||||
SelectableCapability(coordinator, capability, zone)
|
||||
)
|
||||
select_entities.extend(
|
||||
SelectableCapability(coordinator, capability, zone)
|
||||
for zone, data in coordinator.data.zones.items()
|
||||
for capability in data.capabilities
|
||||
if isinstance(capability, OptionSetter)
|
||||
)
|
||||
|
||||
async_add_entities(select_entities)
|
||||
|
||||
|
@ -20,16 +20,18 @@ async def async_setup_entry(
|
||||
"""Set up MusicCast sensor based on a config entry."""
|
||||
coordinator: MusicCastDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
|
||||
switch_entities = []
|
||||
switch_entities = [
|
||||
SwitchCapability(coordinator, capability)
|
||||
for capability in coordinator.data.capabilities
|
||||
if isinstance(capability, BinarySetter)
|
||||
]
|
||||
|
||||
for capability in coordinator.data.capabilities:
|
||||
if isinstance(capability, BinarySetter):
|
||||
switch_entities.append(SwitchCapability(coordinator, capability))
|
||||
|
||||
for zone, data in coordinator.data.zones.items():
|
||||
for capability in data.capabilities:
|
||||
if isinstance(capability, BinarySetter):
|
||||
switch_entities.append(SwitchCapability(coordinator, capability, zone))
|
||||
switch_entities.extend(
|
||||
SwitchCapability(coordinator, capability, zone)
|
||||
for zone, data in coordinator.data.zones.items()
|
||||
for capability in data.capabilities
|
||||
if isinstance(capability, BinarySetter)
|
||||
)
|
||||
|
||||
async_add_entities(switch_entities)
|
||||
|
||||
|
@ -99,16 +99,14 @@ async def async_setup_entry(
|
||||
for device_coordinator in device_coordinators.values()
|
||||
if device_coordinator.device.device_type in SENSOR_DEVICE_TYPE
|
||||
]
|
||||
entities = []
|
||||
for binary_sensor_device_coordinator in binary_sensor_device_coordinators:
|
||||
for description in SENSOR_TYPES:
|
||||
if description.exists_fn(binary_sensor_device_coordinator.device):
|
||||
entities.append(
|
||||
YoLinkBinarySensorEntity(
|
||||
config_entry, binary_sensor_device_coordinator, description
|
||||
)
|
||||
)
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
YoLinkBinarySensorEntity(
|
||||
config_entry, binary_sensor_device_coordinator, description
|
||||
)
|
||||
for binary_sensor_device_coordinator in binary_sensor_device_coordinators
|
||||
for description in SENSOR_TYPES
|
||||
if description.exists_fn(binary_sensor_device_coordinator.device)
|
||||
)
|
||||
|
||||
|
||||
class YoLinkBinarySensorEntity(YoLinkEntity, BinarySensorEntity):
|
||||
|
@ -55,17 +55,15 @@ async def async_get_triggers(
|
||||
if not registry_device or registry_device.model != ATTR_DEVICE_SMART_REMOTER:
|
||||
return []
|
||||
|
||||
triggers = []
|
||||
for trigger in DEVICE_TRIGGER_TYPES[ATTR_DEVICE_SMART_REMOTER]:
|
||||
triggers.append(
|
||||
{
|
||||
CONF_DEVICE_ID: device_id,
|
||||
CONF_DOMAIN: DOMAIN,
|
||||
CONF_PLATFORM: "device",
|
||||
CONF_TYPE: trigger,
|
||||
}
|
||||
)
|
||||
return triggers
|
||||
return [
|
||||
{
|
||||
CONF_DEVICE_ID: device_id,
|
||||
CONF_DOMAIN: DOMAIN,
|
||||
CONF_PLATFORM: "device",
|
||||
CONF_TYPE: trigger,
|
||||
}
|
||||
for trigger in DEVICE_TRIGGER_TYPES[ATTR_DEVICE_SMART_REMOTER]
|
||||
]
|
||||
|
||||
|
||||
async def async_attach_trigger(
|
||||
|
@ -75,18 +75,16 @@ async def async_setup_entry(
|
||||
for device_coordinator in device_coordinators.values()
|
||||
if device_coordinator.device.device_type in NUMBER_TYPE_CONF_SUPPORT_DEVICES
|
||||
]
|
||||
entities = []
|
||||
for config_device_coordinator in config_device_coordinators:
|
||||
for description in DEVICE_CONFIG_DESCRIPTIONS:
|
||||
if description.exists_fn(config_device_coordinator.device):
|
||||
entities.append(
|
||||
YoLinkNumberTypeConfigEntity(
|
||||
config_entry,
|
||||
config_device_coordinator,
|
||||
description,
|
||||
)
|
||||
)
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
YoLinkNumberTypeConfigEntity(
|
||||
config_entry,
|
||||
config_device_coordinator,
|
||||
description,
|
||||
)
|
||||
for config_device_coordinator in config_device_coordinators
|
||||
for description in DEVICE_CONFIG_DESCRIPTIONS
|
||||
if description.exists_fn(config_device_coordinator.device)
|
||||
)
|
||||
|
||||
|
||||
class YoLinkNumberTypeConfigEntity(YoLinkEntity, NumberEntity):
|
||||
|
@ -217,18 +217,16 @@ async def async_setup_entry(
|
||||
for device_coordinator in device_coordinators.values()
|
||||
if device_coordinator.device.device_type in SENSOR_DEVICE_TYPE
|
||||
]
|
||||
entities = []
|
||||
for sensor_device_coordinator in sensor_device_coordinators:
|
||||
for description in SENSOR_TYPES:
|
||||
if description.exists_fn(sensor_device_coordinator.device):
|
||||
entities.append(
|
||||
YoLinkSensorEntity(
|
||||
config_entry,
|
||||
sensor_device_coordinator,
|
||||
description,
|
||||
)
|
||||
)
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
YoLinkSensorEntity(
|
||||
config_entry,
|
||||
sensor_device_coordinator,
|
||||
description,
|
||||
)
|
||||
for sensor_device_coordinator in sensor_device_coordinators
|
||||
for description in SENSOR_TYPES
|
||||
if description.exists_fn(sensor_device_coordinator.device)
|
||||
)
|
||||
|
||||
|
||||
class YoLinkSensorEntity(YoLinkEntity, SensorEntity):
|
||||
|
@ -64,7 +64,12 @@ async def async_setup_entry(
|
||||
config_entry, siren_device_coordinator, description
|
||||
)
|
||||
)
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
YoLinkSirenEntity(config_entry, siren_device_coordinator, description)
|
||||
for siren_device_coordinator in siren_device_coordinators
|
||||
for description in DEVICE_TYPES
|
||||
if description.exists_fn(siren_device_coordinator.device)
|
||||
)
|
||||
|
||||
|
||||
class YoLinkSirenEntity(YoLinkEntity, SirenEntity):
|
||||
|
@ -114,16 +114,12 @@ async def async_setup_entry(
|
||||
for device_coordinator in device_coordinators.values()
|
||||
if device_coordinator.device.device_type in DEVICE_TYPE
|
||||
]
|
||||
entities = []
|
||||
for switch_device_coordinator in switch_device_coordinators:
|
||||
for description in DEVICE_TYPES:
|
||||
if description.exists_fn(switch_device_coordinator.device):
|
||||
entities.append(
|
||||
YoLinkSwitchEntity(
|
||||
config_entry, switch_device_coordinator, description
|
||||
)
|
||||
)
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
YoLinkSwitchEntity(config_entry, switch_device_coordinator, description)
|
||||
for switch_device_coordinator in switch_device_coordinators
|
||||
for description in DEVICE_TYPES
|
||||
if description.exists_fn(switch_device_coordinator.device)
|
||||
)
|
||||
|
||||
|
||||
class YoLinkSwitchEntity(YoLinkEntity, SwitchEntity):
|
||||
|
@ -140,9 +140,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
float_keys_count = len(float_keys)
|
||||
float_keys.update(floats)
|
||||
if len(float_keys) != float_keys_count:
|
||||
floats_discovery = []
|
||||
for float_key in float_keys:
|
||||
floats_discovery.append({"{#KEY}": float_key})
|
||||
floats_discovery = [{"{#KEY}": float_key} for float_key in float_keys]
|
||||
metric = ZabbixMetric(
|
||||
publish_states_host,
|
||||
"homeassistant.floats_discovery",
|
||||
|
@ -363,9 +363,11 @@ class ZeroconfDiscovery:
|
||||
# We want to make sure we know about other HomeAssistant
|
||||
# instances as soon as possible to avoid name conflicts
|
||||
# so we always browse for ZEROCONF_TYPE
|
||||
for hk_type in (ZEROCONF_TYPE, *HOMEKIT_TYPES):
|
||||
if hk_type not in self.zeroconf_types:
|
||||
types.append(hk_type)
|
||||
types.extend(
|
||||
hk_type
|
||||
for hk_type in (ZEROCONF_TYPE, *HOMEKIT_TYPES)
|
||||
if hk_type not in self.zeroconf_types
|
||||
)
|
||||
_LOGGER.debug("Starting Zeroconf browser for: %s", types)
|
||||
self.async_service_browser = AsyncServiceBrowser(
|
||||
self.zeroconf, types, handlers=[self.async_service_update]
|
||||
|
@ -452,9 +452,9 @@ class ZHAGateway:
|
||||
self, device: ZHADevice, entity_refs: list[EntityReference] | None
|
||||
) -> None:
|
||||
if entity_refs is not None:
|
||||
remove_tasks: list[asyncio.Future[Any]] = []
|
||||
for entity_ref in entity_refs:
|
||||
remove_tasks.append(entity_ref.remove_future)
|
||||
remove_tasks: list[asyncio.Future[Any]] = [
|
||||
entity_ref.remove_future for entity_ref in entity_refs
|
||||
]
|
||||
if remove_tasks:
|
||||
await asyncio.wait(remove_tasks)
|
||||
|
||||
@ -783,9 +783,7 @@ class ZHAGateway:
|
||||
_LOGGER.debug("Group: 0x%04x could not be found", group_id)
|
||||
return
|
||||
if group.members:
|
||||
tasks = []
|
||||
for member in group.members:
|
||||
tasks.append(member.async_remove_from_group())
|
||||
tasks = [member.async_remove_from_group() for member in group.members]
|
||||
if tasks:
|
||||
await asyncio.gather(*tasks)
|
||||
self.application_controller.groups.pop(group_id)
|
||||
|
@ -176,13 +176,12 @@ class ZHAGroup(LogMixin):
|
||||
async def async_add_members(self, members: list[GroupMember]) -> None:
|
||||
"""Add members to this group."""
|
||||
if len(members) > 1:
|
||||
tasks = []
|
||||
for member in members:
|
||||
tasks.append(
|
||||
self._zha_gateway.devices[member.ieee].async_add_endpoint_to_group(
|
||||
member.endpoint_id, self.group_id
|
||||
)
|
||||
tasks = [
|
||||
self._zha_gateway.devices[member.ieee].async_add_endpoint_to_group(
|
||||
member.endpoint_id, self.group_id
|
||||
)
|
||||
for member in members
|
||||
]
|
||||
await asyncio.gather(*tasks)
|
||||
else:
|
||||
await self._zha_gateway.devices[
|
||||
@ -192,15 +191,12 @@ class ZHAGroup(LogMixin):
|
||||
async def async_remove_members(self, members: list[GroupMember]) -> None:
|
||||
"""Remove members from this group."""
|
||||
if len(members) > 1:
|
||||
tasks = []
|
||||
for member in members:
|
||||
tasks.append(
|
||||
self._zha_gateway.devices[
|
||||
member.ieee
|
||||
].async_remove_endpoint_from_group(
|
||||
member.endpoint_id, self.group_id
|
||||
)
|
||||
tasks = [
|
||||
self._zha_gateway.devices[member.ieee].async_remove_endpoint_from_group(
|
||||
member.endpoint_id, self.group_id
|
||||
)
|
||||
for member in members
|
||||
]
|
||||
await asyncio.gather(*tasks)
|
||||
else:
|
||||
await self._zha_gateway.devices[
|
||||
|
@ -388,30 +388,30 @@ async def websocket_get_groupable_devices(
|
||||
zha_gateway = get_zha_gateway(hass)
|
||||
|
||||
devices = [device for device in zha_gateway.devices.values() if device.is_groupable]
|
||||
groupable_devices = []
|
||||
groupable_devices: list[dict[str, Any]] = []
|
||||
|
||||
for device in devices:
|
||||
entity_refs = zha_gateway.device_registry[device.ieee]
|
||||
for ep_id in device.async_get_groupable_endpoints():
|
||||
groupable_devices.append(
|
||||
{
|
||||
"endpoint_id": ep_id,
|
||||
"entities": [
|
||||
{
|
||||
"name": _get_entity_name(zha_gateway, entity_ref),
|
||||
"original_name": _get_entity_original_name(
|
||||
zha_gateway, entity_ref
|
||||
),
|
||||
}
|
||||
for entity_ref in entity_refs
|
||||
if list(entity_ref.cluster_handlers.values())[
|
||||
0
|
||||
].cluster.endpoint.endpoint_id
|
||||
== ep_id
|
||||
],
|
||||
"device": device.zha_device_info,
|
||||
}
|
||||
)
|
||||
groupable_devices.extend(
|
||||
{
|
||||
"endpoint_id": ep_id,
|
||||
"entities": [
|
||||
{
|
||||
"name": _get_entity_name(zha_gateway, entity_ref),
|
||||
"original_name": _get_entity_original_name(
|
||||
zha_gateway, entity_ref
|
||||
),
|
||||
}
|
||||
for entity_ref in entity_refs
|
||||
if list(entity_ref.cluster_handlers.values())[
|
||||
0
|
||||
].cluster.endpoint.endpoint_id
|
||||
== ep_id
|
||||
],
|
||||
"device": device.zha_device_info,
|
||||
}
|
||||
for ep_id in device.async_get_groupable_endpoints()
|
||||
)
|
||||
|
||||
connection.send_result(msg[ID], groupable_devices)
|
||||
|
||||
@ -521,9 +521,9 @@ async def websocket_remove_groups(
|
||||
group_ids: list[int] = msg[GROUP_IDS]
|
||||
|
||||
if len(group_ids) > 1:
|
||||
tasks = []
|
||||
for group_id in group_ids:
|
||||
tasks.append(zha_gateway.async_remove_zigpy_group(group_id))
|
||||
tasks = [
|
||||
zha_gateway.async_remove_zigpy_group(group_id) for group_id in group_ids
|
||||
]
|
||||
await asyncio.gather(*tasks)
|
||||
else:
|
||||
await zha_gateway.async_remove_zigpy_group(group_ids[0])
|
||||
|
@ -40,16 +40,16 @@ def setup_platform(
|
||||
on_state = MonitorState(config.get(CONF_COMMAND_ON))
|
||||
off_state = MonitorState(config.get(CONF_COMMAND_OFF))
|
||||
|
||||
switches = []
|
||||
switches: list[ZMSwitchMonitors] = []
|
||||
zm_client: ZoneMinder
|
||||
for zm_client in hass.data[ZONEMINDER_DOMAIN].values():
|
||||
if not (monitors := zm_client.get_monitors()):
|
||||
raise PlatformNotReady(
|
||||
"Switch could not fetch any monitors from ZoneMinder"
|
||||
)
|
||||
|
||||
for monitor in monitors:
|
||||
switches.append(ZMSwitchMonitors(monitor, on_state, off_state))
|
||||
switches.extend(
|
||||
ZMSwitchMonitors(monitor, on_state, off_state) for monitor in monitors
|
||||
)
|
||||
add_entities(switches)
|
||||
|
||||
|
||||
|
@ -379,12 +379,11 @@ class ZWaveWindowCovering(CoverPositionMixin, CoverTiltMixin):
|
||||
assert self._attr_supported_features
|
||||
self._attr_supported_features ^= set_position_feature
|
||||
|
||||
additional_info: list[str] = []
|
||||
for value in (self._current_position_value, self._current_tilt_value):
|
||||
if value and value.property_key_name:
|
||||
additional_info.append(
|
||||
value.property_key_name.removesuffix(f" {NO_POSITION_SUFFIX}")
|
||||
)
|
||||
additional_info: list[str] = [
|
||||
value.property_key_name.removesuffix(f" {NO_POSITION_SUFFIX}")
|
||||
for value in (self._current_position_value, self._current_tilt_value)
|
||||
if value and value.property_key_name
|
||||
]
|
||||
self._attr_name = self.generate_name(additional_info=additional_info)
|
||||
self._attr_device_class = CoverDeviceClass.WINDOW
|
||||
|
||||
|
@ -238,15 +238,15 @@ async def async_get_actions(
|
||||
CONF_SUBTYPE: f"Endpoint {endpoint} (All)",
|
||||
}
|
||||
)
|
||||
for meter_type in endpoint_data[ATTR_METER_TYPE]:
|
||||
actions.append(
|
||||
{
|
||||
**base_action,
|
||||
CONF_TYPE: SERVICE_RESET_METER,
|
||||
ATTR_METER_TYPE: meter_type,
|
||||
CONF_SUBTYPE: f"Endpoint {endpoint} ({meter_type.name})",
|
||||
}
|
||||
)
|
||||
actions.extend(
|
||||
{
|
||||
**base_action,
|
||||
CONF_TYPE: SERVICE_RESET_METER,
|
||||
ATTR_METER_TYPE: meter_type,
|
||||
CONF_SUBTYPE: f"Endpoint {endpoint} ({meter_type.name})",
|
||||
}
|
||||
for meter_type in endpoint_data[ATTR_METER_TYPE]
|
||||
)
|
||||
|
||||
return actions
|
||||
|
||||
|
@ -239,15 +239,14 @@ async def async_attach_trigger(
|
||||
unsubs.append(
|
||||
node.on(event_name, functools.partial(async_on_event, device=device))
|
||||
)
|
||||
|
||||
for driver in drivers:
|
||||
unsubs.append(
|
||||
async_dispatcher_connect(
|
||||
hass,
|
||||
f"{DOMAIN}_{driver.controller.home_id}_connected_to_server",
|
||||
_create_zwave_listeners,
|
||||
)
|
||||
unsubs.extend(
|
||||
async_dispatcher_connect(
|
||||
hass,
|
||||
f"{DOMAIN}_{driver.controller.home_id}_connected_to_server",
|
||||
_create_zwave_listeners,
|
||||
)
|
||||
for driver in drivers
|
||||
)
|
||||
|
||||
_create_zwave_listeners()
|
||||
|
||||
|
@ -194,14 +194,14 @@ async def async_attach_trigger(
|
||||
)
|
||||
)
|
||||
|
||||
for driver in drivers:
|
||||
unsubs.append(
|
||||
async_dispatcher_connect(
|
||||
hass,
|
||||
f"{DOMAIN}_{driver.controller.home_id}_connected_to_server",
|
||||
_create_zwave_listeners,
|
||||
)
|
||||
unsubs.extend(
|
||||
async_dispatcher_connect(
|
||||
hass,
|
||||
f"{DOMAIN}_{driver.controller.home_id}_connected_to_server",
|
||||
_create_zwave_listeners,
|
||||
)
|
||||
for driver in drivers
|
||||
)
|
||||
|
||||
_create_zwave_listeners()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user