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