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