mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Improve lists in integrations [A] (#113006)
* Use list comprehension [A] * Use list comprehension [A] * Update homeassistant/components/aws/notify.py
This commit is contained in:
parent
bf40b33117
commit
690ba103ed
@ -40,12 +40,13 @@ class AcmedaFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
entry.unique_id for entry in self._async_current_entries()
|
entry.unique_id for entry in self._async_current_entries()
|
||||||
}
|
}
|
||||||
|
|
||||||
hubs: list[aiopulse.Hub] = []
|
|
||||||
with suppress(TimeoutError):
|
with suppress(TimeoutError):
|
||||||
async with timeout(5):
|
async with timeout(5):
|
||||||
async for hub in aiopulse.Hub.discover():
|
hubs: list[aiopulse.Hub] = [
|
||||||
if hub.id not in already_configured:
|
hub
|
||||||
hubs.append(hub)
|
async for hub in aiopulse.Hub.discover()
|
||||||
|
if hub.id not in already_configured
|
||||||
|
]
|
||||||
|
|
||||||
if not hubs:
|
if not hubs:
|
||||||
return self.async_abort(reason="no_devices_found")
|
return self.async_abort(reason="no_devices_found")
|
||||||
|
@ -21,11 +21,8 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
instance: AdvantageAirData = hass.data[ADVANTAGE_AIR_DOMAIN][config_entry.entry_id]
|
instance: AdvantageAirData = hass.data[ADVANTAGE_AIR_DOMAIN][config_entry.entry_id]
|
||||||
|
|
||||||
entities: list[SelectEntity] = []
|
|
||||||
if aircons := instance.coordinator.data.get("aircons"):
|
if aircons := instance.coordinator.data.get("aircons"):
|
||||||
for ac_key in aircons:
|
async_add_entities(AdvantageAirMyZone(instance, ac_key) for ac_key in aircons)
|
||||||
entities.append(AdvantageAirMyZone(instance, ac_key))
|
|
||||||
async_add_entities(entities)
|
|
||||||
|
|
||||||
|
|
||||||
class AdvantageAirMyZone(AdvantageAirAcEntity, SelectEntity):
|
class AdvantageAirMyZone(AdvantageAirAcEntity, SelectEntity):
|
||||||
|
@ -34,9 +34,11 @@ async def async_setup_entry(
|
|||||||
if ADVANTAGE_AIR_AUTOFAN_ENABLED in ac_device["info"]:
|
if ADVANTAGE_AIR_AUTOFAN_ENABLED in ac_device["info"]:
|
||||||
entities.append(AdvantageAirMyFan(instance, ac_key))
|
entities.append(AdvantageAirMyFan(instance, ac_key))
|
||||||
if things := instance.coordinator.data.get("myThings"):
|
if things := instance.coordinator.data.get("myThings"):
|
||||||
for thing in things["things"].values():
|
entities.extend(
|
||||||
if thing["channelDipState"] == 8: # 8 = Other relay
|
AdvantageAirRelay(instance, thing)
|
||||||
entities.append(AdvantageAirRelay(instance, thing))
|
for thing in things["things"].values()
|
||||||
|
if thing["channelDipState"] == 8 # 8 = Other relay
|
||||||
|
)
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
||||||
|
@ -368,20 +368,16 @@ async def async_setup_entry(
|
|||||||
name: str = domain_data[ENTRY_NAME]
|
name: str = domain_data[ENTRY_NAME]
|
||||||
coordinator: WeatherUpdateCoordinator = domain_data[ENTRY_WEATHER_COORDINATOR]
|
coordinator: WeatherUpdateCoordinator = domain_data[ENTRY_WEATHER_COORDINATOR]
|
||||||
|
|
||||||
entities: list[AemetSensor] = []
|
async_add_entities(
|
||||||
|
AemetSensor(
|
||||||
for description in FORECAST_SENSORS + WEATHER_SENSORS:
|
name,
|
||||||
if dict_nested_value(coordinator.data["lib"], description.keys) is not None:
|
coordinator,
|
||||||
entities.append(
|
description,
|
||||||
AemetSensor(
|
config_entry,
|
||||||
name,
|
)
|
||||||
coordinator,
|
for description in FORECAST_SENSORS + WEATHER_SENSORS
|
||||||
description,
|
if dict_nested_value(coordinator.data["lib"], description.keys) is not None
|
||||||
config_entry,
|
)
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
async_add_entities(entities)
|
|
||||||
|
|
||||||
|
|
||||||
class AemetSensor(AemetEntity, SensorEntity):
|
class AemetSensor(AemetEntity, SensorEntity):
|
||||||
|
@ -181,13 +181,15 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
sensors = []
|
async_add_entities(
|
||||||
for description in SENSOR_TYPES:
|
(
|
||||||
# When we use the nearest method, we are not sure which sensors are available
|
AirlySensor(coordinator, name, description)
|
||||||
if coordinator.data.get(description.key):
|
for description in SENSOR_TYPES
|
||||||
sensors.append(AirlySensor(coordinator, name, description))
|
# When we use the nearest method, we are not sure which sensors are available
|
||||||
|
if coordinator.data.get(description.key)
|
||||||
async_add_entities(sensors, False)
|
),
|
||||||
|
False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AirlySensor(CoordinatorEntity[AirlyDataUpdateCoordinator], SensorEntity):
|
class AirlySensor(CoordinatorEntity[AirlyDataUpdateCoordinator], SensorEntity):
|
||||||
|
@ -109,8 +109,10 @@ async def async_setup_entry(
|
|||||||
entities.append(Airtouch5AC(client, ac))
|
entities.append(Airtouch5AC(client, ac))
|
||||||
|
|
||||||
# Add each zone
|
# Add each zone
|
||||||
for zone in client.zones:
|
entities.extend(
|
||||||
entities.append(Airtouch5Zone(client, zone, zone_to_ac[zone.zone_number]))
|
Airtouch5Zone(client, zone, zone_to_ac[zone.zone_number])
|
||||||
|
for zone in client.zones
|
||||||
|
)
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
@ -80,33 +80,31 @@ async def async_setup_entry(
|
|||||||
"""Add Airzone binary sensors from a config_entry."""
|
"""Add Airzone binary sensors from a config_entry."""
|
||||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
binary_sensors: list[AirzoneBinarySensor] = []
|
binary_sensors: list[AirzoneBinarySensor] = [
|
||||||
|
AirzoneSystemBinarySensor(
|
||||||
|
coordinator,
|
||||||
|
description,
|
||||||
|
entry,
|
||||||
|
system_id,
|
||||||
|
system_data,
|
||||||
|
)
|
||||||
|
for system_id, system_data in coordinator.data[AZD_SYSTEMS].items()
|
||||||
|
for description in SYSTEM_BINARY_SENSOR_TYPES
|
||||||
|
if description.key in system_data
|
||||||
|
]
|
||||||
|
|
||||||
for system_id, system_data in coordinator.data[AZD_SYSTEMS].items():
|
binary_sensors.extend(
|
||||||
for description in SYSTEM_BINARY_SENSOR_TYPES:
|
AirzoneZoneBinarySensor(
|
||||||
if description.key in system_data:
|
coordinator,
|
||||||
binary_sensors.append(
|
description,
|
||||||
AirzoneSystemBinarySensor(
|
entry,
|
||||||
coordinator,
|
system_zone_id,
|
||||||
description,
|
zone_data,
|
||||||
entry,
|
)
|
||||||
system_id,
|
for system_zone_id, zone_data in coordinator.data[AZD_ZONES].items()
|
||||||
system_data,
|
for description in ZONE_BINARY_SENSOR_TYPES
|
||||||
)
|
if description.key in zone_data
|
||||||
)
|
)
|
||||||
|
|
||||||
for system_zone_id, zone_data in coordinator.data[AZD_ZONES].items():
|
|
||||||
for description in ZONE_BINARY_SENSOR_TYPES:
|
|
||||||
if description.key in zone_data:
|
|
||||||
binary_sensors.append(
|
|
||||||
AirzoneZoneBinarySensor(
|
|
||||||
coordinator,
|
|
||||||
description,
|
|
||||||
entry,
|
|
||||||
system_zone_id,
|
|
||||||
zone_data,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
async_add_entities(binary_sensors)
|
async_add_entities(binary_sensors)
|
||||||
|
|
||||||
|
@ -84,22 +84,18 @@ async def async_setup_entry(
|
|||||||
"""Add Airzone sensors from a config_entry."""
|
"""Add Airzone sensors from a config_entry."""
|
||||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
entities: list[AirzoneBaseSelect] = []
|
async_add_entities(
|
||||||
|
AirzoneZoneSelect(
|
||||||
for system_zone_id, zone_data in coordinator.data[AZD_ZONES].items():
|
coordinator,
|
||||||
for description in ZONE_SELECT_TYPES:
|
description,
|
||||||
if description.key in zone_data:
|
entry,
|
||||||
entities.append(
|
system_zone_id,
|
||||||
AirzoneZoneSelect(
|
zone_data,
|
||||||
coordinator,
|
)
|
||||||
description,
|
for description in ZONE_SELECT_TYPES
|
||||||
entry,
|
for system_zone_id, zone_data in coordinator.data[AZD_ZONES].items()
|
||||||
system_zone_id,
|
if description.key in zone_data
|
||||||
zone_data,
|
)
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
async_add_entities(entities)
|
|
||||||
|
|
||||||
|
|
||||||
class AirzoneBaseSelect(AirzoneEntity, SelectEntity):
|
class AirzoneBaseSelect(AirzoneEntity, SelectEntity):
|
||||||
|
@ -82,44 +82,40 @@ async def async_setup_entry(
|
|||||||
"""Add Airzone sensors from a config_entry."""
|
"""Add Airzone sensors from a config_entry."""
|
||||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
sensors: list[AirzoneSensor] = []
|
sensors: list[AirzoneSensor] = [
|
||||||
|
AirzoneZoneSensor(
|
||||||
|
coordinator,
|
||||||
|
description,
|
||||||
|
entry,
|
||||||
|
system_zone_id,
|
||||||
|
zone_data,
|
||||||
|
)
|
||||||
|
for system_zone_id, zone_data in coordinator.data[AZD_ZONES].items()
|
||||||
|
for description in ZONE_SENSOR_TYPES
|
||||||
|
if description.key in zone_data
|
||||||
|
]
|
||||||
|
|
||||||
if AZD_HOT_WATER in coordinator.data:
|
if AZD_HOT_WATER in coordinator.data:
|
||||||
dhw_data = coordinator.data[AZD_HOT_WATER]
|
sensors.extend(
|
||||||
for description in HOT_WATER_SENSOR_TYPES:
|
AirzoneHotWaterSensor(
|
||||||
if description.key in dhw_data:
|
coordinator,
|
||||||
sensors.append(
|
description,
|
||||||
AirzoneHotWaterSensor(
|
entry,
|
||||||
coordinator,
|
)
|
||||||
description,
|
for description in HOT_WATER_SENSOR_TYPES
|
||||||
entry,
|
if description.key in coordinator.data[AZD_HOT_WATER]
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
if AZD_WEBSERVER in coordinator.data:
|
if AZD_WEBSERVER in coordinator.data:
|
||||||
ws_data = coordinator.data[AZD_WEBSERVER]
|
sensors.extend(
|
||||||
for description in WEBSERVER_SENSOR_TYPES:
|
AirzoneWebServerSensor(
|
||||||
if description.key in ws_data:
|
coordinator,
|
||||||
sensors.append(
|
description,
|
||||||
AirzoneWebServerSensor(
|
entry,
|
||||||
coordinator,
|
)
|
||||||
description,
|
for description in WEBSERVER_SENSOR_TYPES
|
||||||
entry,
|
if description.key in coordinator.data[AZD_WEBSERVER]
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
for system_zone_id, zone_data in coordinator.data[AZD_ZONES].items():
|
|
||||||
for description in ZONE_SENSOR_TYPES:
|
|
||||||
if description.key in zone_data:
|
|
||||||
sensors.append(
|
|
||||||
AirzoneZoneSensor(
|
|
||||||
coordinator,
|
|
||||||
description,
|
|
||||||
entry,
|
|
||||||
system_zone_id,
|
|
||||||
zone_data,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
async_add_entities(sensors)
|
async_add_entities(sensors)
|
||||||
|
|
||||||
|
@ -99,43 +99,41 @@ async def async_setup_entry(
|
|||||||
"""Add Airzone Cloud binary sensors from a config_entry."""
|
"""Add Airzone Cloud binary sensors from a config_entry."""
|
||||||
coordinator: AirzoneUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator: AirzoneUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
binary_sensors: list[AirzoneBinarySensor] = []
|
binary_sensors: list[AirzoneBinarySensor] = [
|
||||||
|
AirzoneAidooBinarySensor(
|
||||||
|
coordinator,
|
||||||
|
description,
|
||||||
|
aidoo_id,
|
||||||
|
aidoo_data,
|
||||||
|
)
|
||||||
|
for aidoo_id, aidoo_data in coordinator.data.get(AZD_AIDOOS, {}).items()
|
||||||
|
for description in AIDOO_BINARY_SENSOR_TYPES
|
||||||
|
if description.key in aidoo_data
|
||||||
|
]
|
||||||
|
|
||||||
for aidoo_id, aidoo_data in coordinator.data.get(AZD_AIDOOS, {}).items():
|
binary_sensors.extend(
|
||||||
for description in AIDOO_BINARY_SENSOR_TYPES:
|
AirzoneSystemBinarySensor(
|
||||||
if description.key in aidoo_data:
|
coordinator,
|
||||||
binary_sensors.append(
|
description,
|
||||||
AirzoneAidooBinarySensor(
|
system_id,
|
||||||
coordinator,
|
system_data,
|
||||||
description,
|
)
|
||||||
aidoo_id,
|
for system_id, system_data in coordinator.data.get(AZD_SYSTEMS, {}).items()
|
||||||
aidoo_data,
|
for description in SYSTEM_BINARY_SENSOR_TYPES
|
||||||
)
|
if description.key in system_data
|
||||||
)
|
)
|
||||||
|
|
||||||
for system_id, system_data in coordinator.data.get(AZD_SYSTEMS, {}).items():
|
binary_sensors.extend(
|
||||||
for description in SYSTEM_BINARY_SENSOR_TYPES:
|
AirzoneZoneBinarySensor(
|
||||||
if description.key in system_data:
|
coordinator,
|
||||||
binary_sensors.append(
|
description,
|
||||||
AirzoneSystemBinarySensor(
|
zone_id,
|
||||||
coordinator,
|
zone_data,
|
||||||
description,
|
)
|
||||||
system_id,
|
for zone_id, zone_data in coordinator.data.get(AZD_ZONES, {}).items()
|
||||||
system_data,
|
for description in ZONE_BINARY_SENSOR_TYPES
|
||||||
)
|
if description.key in zone_data
|
||||||
)
|
)
|
||||||
|
|
||||||
for zone_id, zone_data in coordinator.data.get(AZD_ZONES, {}).items():
|
|
||||||
for description in ZONE_BINARY_SENSOR_TYPES:
|
|
||||||
if description.key in zone_data:
|
|
||||||
binary_sensors.append(
|
|
||||||
AirzoneZoneBinarySensor(
|
|
||||||
coordinator,
|
|
||||||
description,
|
|
||||||
zone_id,
|
|
||||||
zone_data,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
async_add_entities(binary_sensors)
|
async_add_entities(binary_sensors)
|
||||||
|
|
||||||
|
@ -108,46 +108,44 @@ async def async_setup_entry(
|
|||||||
"""Add Airzone Cloud sensors from a config_entry."""
|
"""Add Airzone Cloud sensors from a config_entry."""
|
||||||
coordinator: AirzoneUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator: AirzoneUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
sensors: list[AirzoneSensor] = []
|
|
||||||
|
|
||||||
# Aidoos
|
# Aidoos
|
||||||
for aidoo_id, aidoo_data in coordinator.data.get(AZD_AIDOOS, {}).items():
|
sensors: list[AirzoneSensor] = [
|
||||||
for description in AIDOO_SENSOR_TYPES:
|
AirzoneAidooSensor(
|
||||||
if description.key in aidoo_data:
|
coordinator,
|
||||||
sensors.append(
|
description,
|
||||||
AirzoneAidooSensor(
|
aidoo_id,
|
||||||
coordinator,
|
aidoo_data,
|
||||||
description,
|
)
|
||||||
aidoo_id,
|
for aidoo_id, aidoo_data in coordinator.data.get(AZD_AIDOOS, {}).items()
|
||||||
aidoo_data,
|
for description in AIDOO_SENSOR_TYPES
|
||||||
)
|
if description.key in aidoo_data
|
||||||
)
|
]
|
||||||
|
|
||||||
# WebServers
|
# WebServers
|
||||||
for ws_id, ws_data in coordinator.data.get(AZD_WEBSERVERS, {}).items():
|
sensors.extend(
|
||||||
for description in WEBSERVER_SENSOR_TYPES:
|
AirzoneWebServerSensor(
|
||||||
if description.key in ws_data:
|
coordinator,
|
||||||
sensors.append(
|
description,
|
||||||
AirzoneWebServerSensor(
|
ws_id,
|
||||||
coordinator,
|
ws_data,
|
||||||
description,
|
)
|
||||||
ws_id,
|
for ws_id, ws_data in coordinator.data.get(AZD_WEBSERVERS, {}).items()
|
||||||
ws_data,
|
for description in WEBSERVER_SENSOR_TYPES
|
||||||
)
|
if description.key in ws_data
|
||||||
)
|
)
|
||||||
|
|
||||||
# Zones
|
# Zones
|
||||||
for zone_id, zone_data in coordinator.data.get(AZD_ZONES, {}).items():
|
sensors.extend(
|
||||||
for description in ZONE_SENSOR_TYPES:
|
AirzoneZoneSensor(
|
||||||
if description.key in zone_data:
|
coordinator,
|
||||||
sensors.append(
|
description,
|
||||||
AirzoneZoneSensor(
|
zone_id,
|
||||||
coordinator,
|
zone_data,
|
||||||
description,
|
)
|
||||||
zone_id,
|
for zone_id, zone_data in coordinator.data.get(AZD_ZONES, {}).items()
|
||||||
zone_data,
|
for description in ZONE_SENSOR_TYPES
|
||||||
)
|
if description.key in zone_data
|
||||||
)
|
)
|
||||||
|
|
||||||
async_add_entities(sensors)
|
async_add_entities(sensors)
|
||||||
|
|
||||||
|
@ -1196,11 +1196,12 @@ class AlexaThermostatController(AlexaCapability):
|
|||||||
if self.entity.domain == water_heater.DOMAIN:
|
if self.entity.domain == water_heater.DOMAIN:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
supported_modes: list[str] = []
|
|
||||||
hvac_modes = self.entity.attributes.get(climate.ATTR_HVAC_MODES) or []
|
hvac_modes = self.entity.attributes.get(climate.ATTR_HVAC_MODES) or []
|
||||||
for mode in hvac_modes:
|
supported_modes: list[str] = [
|
||||||
if thermostat_mode := API_THERMOSTAT_MODES.get(mode):
|
API_THERMOSTAT_MODES[mode]
|
||||||
supported_modes.append(thermostat_mode)
|
for mode in hvac_modes
|
||||||
|
if mode in API_THERMOSTAT_MODES
|
||||||
|
]
|
||||||
|
|
||||||
preset_modes = self.entity.attributes.get(climate.ATTR_PRESET_MODES)
|
preset_modes = self.entity.attributes.get(climate.ATTR_PRESET_MODES)
|
||||||
if preset_modes:
|
if preset_modes:
|
||||||
|
@ -442,9 +442,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
return entity_ids
|
return entity_ids
|
||||||
|
|
||||||
async def async_service_handler(call: ServiceCall) -> None:
|
async def async_service_handler(call: ServiceCall) -> None:
|
||||||
args = []
|
args = [call.data[arg] for arg in CAMERA_SERVICES[call.service][2]]
|
||||||
for arg in CAMERA_SERVICES[call.service][2]:
|
|
||||||
args.append(call.data[arg])
|
|
||||||
for entity_id in await async_extract_from_service(call):
|
for entity_id in await async_extract_from_service(call):
|
||||||
async_dispatcher_send(hass, service_signal(call.service, entity_id), *args)
|
async_dispatcher_send(hass, service_signal(call.service, entity_id), *args)
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ class Analytics:
|
|||||||
system_info = await async_get_system_info(hass)
|
system_info = await async_get_system_info(hass)
|
||||||
integrations = []
|
integrations = []
|
||||||
custom_integrations = []
|
custom_integrations = []
|
||||||
addons = []
|
addons: list[dict[str, Any]] = []
|
||||||
payload: dict = {
|
payload: dict = {
|
||||||
ATTR_UUID: self.uuid,
|
ATTR_UUID: self.uuid,
|
||||||
ATTR_VERSION: HA_VERSION,
|
ATTR_VERSION: HA_VERSION,
|
||||||
@ -267,15 +267,15 @@ class Analytics:
|
|||||||
for addon in supervisor_info[ATTR_ADDONS]
|
for addon in supervisor_info[ATTR_ADDONS]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
for addon in installed_addons:
|
addons.extend(
|
||||||
addons.append(
|
{
|
||||||
{
|
ATTR_SLUG: addon[ATTR_SLUG],
|
||||||
ATTR_SLUG: addon[ATTR_SLUG],
|
ATTR_PROTECTED: addon[ATTR_PROTECTED],
|
||||||
ATTR_PROTECTED: addon[ATTR_PROTECTED],
|
ATTR_VERSION: addon[ATTR_VERSION],
|
||||||
ATTR_VERSION: addon[ATTR_VERSION],
|
ATTR_AUTO_UPDATE: addon[ATTR_AUTO_UPDATE],
|
||||||
ATTR_AUTO_UPDATE: addon[ATTR_AUTO_UPDATE],
|
}
|
||||||
}
|
for addon in installed_addons
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.preferences.get(ATTR_USAGE, False):
|
if self.preferences.get(ATTR_USAGE, False):
|
||||||
payload[ATTR_CERTIFICATE] = hass.http.ssl_certificate is not None
|
payload[ATTR_CERTIFICATE] = hass.http.ssl_certificate is not None
|
||||||
|
@ -46,13 +46,12 @@ async def async_setup_platform(
|
|||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the switch platform."""
|
"""Set up the switch platform."""
|
||||||
switches = []
|
|
||||||
|
|
||||||
processor: AquaLogicProcessor = hass.data[DOMAIN]
|
processor: AquaLogicProcessor = hass.data[DOMAIN]
|
||||||
for switch_type in config[CONF_MONITORED_CONDITIONS]:
|
|
||||||
switches.append(AquaLogicSwitch(processor, switch_type))
|
|
||||||
|
|
||||||
async_add_entities(switches)
|
async_add_entities(
|
||||||
|
AquaLogicSwitch(processor, switch_type)
|
||||||
|
for switch_type in config[CONF_MONITORED_CONDITIONS]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AquaLogicSwitch(SwitchEntity):
|
class AquaLogicSwitch(SwitchEntity):
|
||||||
|
@ -33,23 +33,19 @@ async def async_get_triggers(
|
|||||||
hass: HomeAssistant, device_id: str
|
hass: HomeAssistant, device_id: str
|
||||||
) -> list[dict[str, str]]:
|
) -> list[dict[str, str]]:
|
||||||
"""List device triggers for Arcam FMJ Receiver control devices."""
|
"""List device triggers for Arcam FMJ Receiver control devices."""
|
||||||
registry = er.async_get(hass)
|
entity_registry = er.async_get(hass)
|
||||||
triggers = []
|
|
||||||
|
|
||||||
# Get all the integrations entities for this device
|
return [
|
||||||
for entry in er.async_entries_for_device(registry, device_id):
|
{
|
||||||
if entry.domain == "media_player":
|
CONF_PLATFORM: "device",
|
||||||
triggers.append(
|
CONF_DEVICE_ID: device_id,
|
||||||
{
|
CONF_DOMAIN: DOMAIN,
|
||||||
CONF_PLATFORM: "device",
|
CONF_ENTITY_ID: entry.id,
|
||||||
CONF_DEVICE_ID: device_id,
|
CONF_TYPE: "turn_on",
|
||||||
CONF_DOMAIN: DOMAIN,
|
}
|
||||||
CONF_ENTITY_ID: entry.id,
|
for entry in er.async_entries_for_device(entity_registry, device_id)
|
||||||
CONF_TYPE: "turn_on",
|
if entry.domain == "media_player"
|
||||||
}
|
]
|
||||||
)
|
|
||||||
|
|
||||||
return triggers
|
|
||||||
|
|
||||||
|
|
||||||
async def async_attach_trigger(
|
async def async_attach_trigger(
|
||||||
|
@ -57,11 +57,11 @@ async def async_setup_entry(
|
|||||||
data: list[tuple[Unit, AsekoDataUpdateCoordinator]] = hass.data[DOMAIN][
|
data: list[tuple[Unit, AsekoDataUpdateCoordinator]] = hass.data[DOMAIN][
|
||||||
config_entry.entry_id
|
config_entry.entry_id
|
||||||
]
|
]
|
||||||
entities: list[BinarySensorEntity] = []
|
async_add_entities(
|
||||||
for unit, coordinator in data:
|
AsekoUnitBinarySensorEntity(unit, coordinator, description)
|
||||||
for description in UNIT_BINARY_SENSORS:
|
for unit, coordinator in data
|
||||||
entities.append(AsekoUnitBinarySensorEntity(unit, coordinator, description))
|
for description in UNIT_BINARY_SENSORS
|
||||||
async_add_entities(entities)
|
)
|
||||||
|
|
||||||
|
|
||||||
class AsekoUnitBinarySensorEntity(AsekoEntity, BinarySensorEntity):
|
class AsekoUnitBinarySensorEntity(AsekoEntity, BinarySensorEntity):
|
||||||
|
@ -27,11 +27,12 @@ async def async_setup_entry(
|
|||||||
data: list[tuple[Unit, AsekoDataUpdateCoordinator]] = hass.data[DOMAIN][
|
data: list[tuple[Unit, AsekoDataUpdateCoordinator]] = hass.data[DOMAIN][
|
||||||
config_entry.entry_id
|
config_entry.entry_id
|
||||||
]
|
]
|
||||||
entities = []
|
|
||||||
for unit, coordinator in data:
|
async_add_entities(
|
||||||
for variable in unit.variables:
|
VariableSensorEntity(unit, variable, coordinator)
|
||||||
entities.append(VariableSensorEntity(unit, variable, coordinator))
|
for unit, coordinator in data
|
||||||
async_add_entities(entities)
|
for variable in unit.variables
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class VariableSensorEntity(AsekoEntity, SensorEntity):
|
class VariableSensorEntity(AsekoEntity, SensorEntity):
|
||||||
|
@ -765,12 +765,12 @@ class PipelineRun:
|
|||||||
# spoken, we need to make sure pending audio is forwarded to
|
# spoken, we need to make sure pending audio is forwarded to
|
||||||
# speech-to-text so the user does not have to pause before
|
# speech-to-text so the user does not have to pause before
|
||||||
# speaking the voice command.
|
# speaking the voice command.
|
||||||
for chunk_ts in result.queued_audio:
|
audio_chunks_for_stt.extend(
|
||||||
audio_chunks_for_stt.append(
|
ProcessedAudioChunk(
|
||||||
ProcessedAudioChunk(
|
audio=chunk_ts[0], timestamp_ms=chunk_ts[1], is_speech=False
|
||||||
audio=chunk_ts[0], timestamp_ms=chunk_ts[1], is_speech=False
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
for chunk_ts in result.queued_audio
|
||||||
|
)
|
||||||
|
|
||||||
wake_word_output = asdict(result)
|
wake_word_output = asdict(result)
|
||||||
|
|
||||||
|
@ -80,11 +80,9 @@ async def async_setup_platform(
|
|||||||
sw_version=sw_version,
|
sw_version=sw_version,
|
||||||
)
|
)
|
||||||
|
|
||||||
switches = []
|
async_add_entities(
|
||||||
async for outlet in outlets:
|
(AtenSwitch(dev, info, mac, outlet.id, outlet.name) for outlet in outlets), True
|
||||||
switches.append(AtenSwitch(dev, info, mac, outlet.id, outlet.name))
|
)
|
||||||
|
|
||||||
async_add_entities(switches, True)
|
|
||||||
|
|
||||||
|
|
||||||
class AtenSwitch(SwitchEntity):
|
class AtenSwitch(SwitchEntity):
|
||||||
|
@ -151,8 +151,7 @@ async def async_setup_entry(
|
|||||||
entities.append(keypad_battery_sensor)
|
entities.append(keypad_battery_sensor)
|
||||||
migrate_unique_id_devices.append(keypad_battery_sensor)
|
migrate_unique_id_devices.append(keypad_battery_sensor)
|
||||||
|
|
||||||
for device in operation_sensors:
|
entities.extend(AugustOperatorSensor(data, device) for device in operation_sensors)
|
||||||
entities.append(AugustOperatorSensor(data, device))
|
|
||||||
|
|
||||||
await _async_migrate_old_unique_ids(hass, migrate_unique_id_devices)
|
await _async_migrate_old_unique_ids(hass, migrate_unique_id_devices)
|
||||||
|
|
||||||
|
@ -79,13 +79,11 @@ async def async_setup_entry(
|
|||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up aurora_abb_powerone sensor based on a config entry."""
|
"""Set up aurora_abb_powerone sensor based on a config entry."""
|
||||||
entities = []
|
|
||||||
|
|
||||||
coordinator = hass.data[DOMAIN][config_entry.entry_id]
|
coordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
data = config_entry.data
|
data = config_entry.data
|
||||||
|
|
||||||
for sens in SENSOR_TYPES:
|
entities = [AuroraSensor(coordinator, data, sens) for sens in SENSOR_TYPES]
|
||||||
entities.append(AuroraSensor(coordinator, data, sens))
|
|
||||||
|
|
||||||
_LOGGER.debug("async_setup_entry adding %d entities", len(entities))
|
_LOGGER.debug("async_setup_entry adding %d entities", len(entities))
|
||||||
async_add_entities(entities, True)
|
async_add_entities(entities, True)
|
||||||
|
@ -17,13 +17,12 @@ async def async_get_config_entry_diagnostics(
|
|||||||
hass: HomeAssistant, config_entry: ConfigEntry
|
hass: HomeAssistant, config_entry: ConfigEntry
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Return diagnostics for a config entry."""
|
"""Return diagnostics for a config entry."""
|
||||||
services = []
|
return {
|
||||||
for service in hass.data[DOMAIN][config_entry.entry_id]["services"]:
|
"services": [
|
||||||
services.append(
|
|
||||||
{
|
{
|
||||||
"service": async_redact_data(service, TO_REDACT),
|
"service": async_redact_data(service, TO_REDACT),
|
||||||
"usage": async_redact_data(service["coordinator"].data, ["historical"]),
|
"usage": async_redact_data(service["coordinator"].data, ["historical"]),
|
||||||
}
|
}
|
||||||
)
|
for service in hass.data[DOMAIN][config_entry.entry_id]["services"]
|
||||||
|
]
|
||||||
return {"services": services}
|
}
|
||||||
|
@ -53,21 +53,25 @@ def setup_platform(
|
|||||||
"""Set up an Avion switch."""
|
"""Set up an Avion switch."""
|
||||||
avion = importlib.import_module("avion")
|
avion = importlib.import_module("avion")
|
||||||
|
|
||||||
lights = []
|
lights = [
|
||||||
if CONF_USERNAME in config and CONF_PASSWORD in config:
|
AvionLight(
|
||||||
devices = avion.get_devices(config[CONF_USERNAME], config[CONF_PASSWORD])
|
avion.Avion(
|
||||||
for device in devices:
|
mac=address,
|
||||||
lights.append(AvionLight(device))
|
passphrase=device_config[CONF_API_KEY],
|
||||||
|
name=device_config.get(CONF_NAME),
|
||||||
for address, device_config in config[CONF_DEVICES].items():
|
object_id=device_config.get(CONF_ID),
|
||||||
device = avion.Avion(
|
connect=False,
|
||||||
mac=address,
|
)
|
||||||
passphrase=device_config[CONF_API_KEY],
|
)
|
||||||
name=device_config.get(CONF_NAME),
|
for address, device_config in config[CONF_DEVICES].items()
|
||||||
object_id=device_config.get(CONF_ID),
|
]
|
||||||
connect=False,
|
if CONF_USERNAME in config and CONF_PASSWORD in config:
|
||||||
|
lights.extend(
|
||||||
|
AvionLight(device)
|
||||||
|
for device in avion.get_devices(
|
||||||
|
config[CONF_USERNAME], config[CONF_PASSWORD]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
lights.append(AvionLight(device))
|
|
||||||
|
|
||||||
add_entities(lights)
|
add_entities(lights)
|
||||||
|
|
||||||
|
@ -129,9 +129,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
# validate credentials and create sessions
|
# validate credentials and create sessions
|
||||||
validation = True
|
validation = True
|
||||||
tasks = []
|
tasks = [_validate_aws_credentials(hass, cred) for cred in conf[ATTR_CREDENTIALS]]
|
||||||
for cred in conf[ATTR_CREDENTIALS]:
|
|
||||||
tasks.append(_validate_aws_credentials(hass, cred))
|
|
||||||
if tasks:
|
if tasks:
|
||||||
results = await asyncio.gather(*tasks, return_exceptions=True)
|
results = await asyncio.gather(*tasks, return_exceptions=True)
|
||||||
for index, result in enumerate(results):
|
for index, result in enumerate(results):
|
||||||
|
@ -155,15 +155,14 @@ class AWSLambda(AWSNotify):
|
|||||||
async with self.session.create_client(
|
async with self.session.create_client(
|
||||||
self.service, **self.aws_config
|
self.service, **self.aws_config
|
||||||
) as client:
|
) as client:
|
||||||
tasks = []
|
tasks = [
|
||||||
for target in kwargs.get(ATTR_TARGET, []):
|
client.invoke(
|
||||||
tasks.append(
|
FunctionName=target,
|
||||||
client.invoke(
|
Payload=json_payload,
|
||||||
FunctionName=target,
|
ClientContext=self.context,
|
||||||
Payload=json_payload,
|
|
||||||
ClientContext=self.context,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
for target in kwargs.get(ATTR_TARGET, [])
|
||||||
|
]
|
||||||
|
|
||||||
if tasks:
|
if tasks:
|
||||||
await asyncio.gather(*tasks)
|
await asyncio.gather(*tasks)
|
||||||
@ -192,16 +191,15 @@ class AWSSNS(AWSNotify):
|
|||||||
async with self.session.create_client(
|
async with self.session.create_client(
|
||||||
self.service, **self.aws_config
|
self.service, **self.aws_config
|
||||||
) as client:
|
) as client:
|
||||||
tasks = []
|
tasks = [
|
||||||
for target in kwargs.get(ATTR_TARGET, []):
|
client.publish(
|
||||||
tasks.append(
|
TargetArn=target,
|
||||||
client.publish(
|
Message=message,
|
||||||
TargetArn=target,
|
Subject=subject,
|
||||||
Message=message,
|
MessageAttributes=message_attributes,
|
||||||
Subject=subject,
|
|
||||||
MessageAttributes=message_attributes,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
for target in kwargs.get(ATTR_TARGET, [])
|
||||||
|
]
|
||||||
|
|
||||||
if tasks:
|
if tasks:
|
||||||
await asyncio.gather(*tasks)
|
await asyncio.gather(*tasks)
|
||||||
@ -265,7 +263,6 @@ class AWSEventBridge(AWSNotify):
|
|||||||
async with self.session.create_client(
|
async with self.session.create_client(
|
||||||
self.service, **self.aws_config
|
self.service, **self.aws_config
|
||||||
) as client:
|
) as client:
|
||||||
tasks = []
|
|
||||||
entries = []
|
entries = []
|
||||||
for target in kwargs.get(ATTR_TARGET, [None]):
|
for target in kwargs.get(ATTR_TARGET, [None]):
|
||||||
entry = {
|
entry = {
|
||||||
@ -278,10 +275,10 @@ class AWSEventBridge(AWSNotify):
|
|||||||
entry["EventBusName"] = target
|
entry["EventBusName"] = target
|
||||||
|
|
||||||
entries.append(entry)
|
entries.append(entry)
|
||||||
for i in range(0, len(entries), 10):
|
tasks = [
|
||||||
tasks.append(
|
client.put_events(Entries=entries[i : min(i + 10, len(entries))])
|
||||||
client.put_events(Entries=entries[i : min(i + 10, len(entries))])
|
for i in range(0, len(entries), 10)
|
||||||
)
|
]
|
||||||
|
|
||||||
if tasks:
|
if tasks:
|
||||||
results = await asyncio.gather(*tasks)
|
results = await asyncio.gather(*tasks)
|
||||||
|
@ -267,8 +267,7 @@ class AxisOptionsFlowHandler(OptionsFlowWithConfigEntry):
|
|||||||
and profiles.max_groups > 0
|
and profiles.max_groups > 0
|
||||||
):
|
):
|
||||||
stream_profiles = [DEFAULT_STREAM_PROFILE]
|
stream_profiles = [DEFAULT_STREAM_PROFILE]
|
||||||
for profile in vapix.streaming_profiles:
|
stream_profiles.extend(profile.name for profile in vapix.streaming_profiles)
|
||||||
stream_profiles.append(profile.name)
|
|
||||||
|
|
||||||
schema[
|
schema[
|
||||||
vol.Optional(
|
vol.Optional(
|
||||||
|
@ -86,12 +86,12 @@ async def test_load_pipelines(hass: HomeAssistant, init_components) -> None:
|
|||||||
"wake_word_id": "wakeword_id_3",
|
"wake_word_id": "wakeword_id_3",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
pipeline_ids = []
|
|
||||||
|
|
||||||
pipeline_data: PipelineData = hass.data[DOMAIN]
|
pipeline_data: PipelineData = hass.data[DOMAIN]
|
||||||
store1 = pipeline_data.pipeline_store
|
store1 = pipeline_data.pipeline_store
|
||||||
for pipeline in pipelines:
|
pipeline_ids = [
|
||||||
pipeline_ids.append((await store1.async_create_item(pipeline)).id)
|
(await store1.async_create_item(pipeline)).id for pipeline in pipelines
|
||||||
|
]
|
||||||
assert len(store1.data) == 4 # 3 manually created plus a default pipeline
|
assert len(store1.data) == 4 # 3 manually created plus a default pipeline
|
||||||
assert store1.async_get_preferred_item() == list(store1.data)[0]
|
assert store1.async_get_preferred_item() == list(store1.data)[0]
|
||||||
|
|
||||||
|
@ -136,10 +136,7 @@ async def _create_august_api_with_devices( # noqa: C901
|
|||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
def _get_base_devices(device_type):
|
def _get_base_devices(device_type):
|
||||||
base_devices = []
|
return [device["base"] for device in device_data[device_type]]
|
||||||
for device in device_data[device_type]:
|
|
||||||
base_devices.append(device["base"])
|
|
||||||
return base_devices
|
|
||||||
|
|
||||||
def get_lock_detail_side_effect(access_token, device_id):
|
def get_lock_detail_side_effect(access_token, device_id):
|
||||||
return _get_device_detail("locks", device_id)
|
return _get_device_detail("locks", device_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user