Improve lists in integrations [L-M] (#113227)
* Improve lists in integrations [L-M] * Update homeassistant/components/mailbox/__init__.py Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com> * Fix --------- Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com>
This commit is contained in:
parent
4547131bbc
commit
595d07f1c6
34 changed files with 200 additions and 232 deletions
|
@ -208,20 +208,19 @@ async def async_setup_entry(
|
|||
"""Set up number entities."""
|
||||
coordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
|
||||
async_add_entities(
|
||||
entities: list[NumberEntity] = [
|
||||
LaMarzoccoNumberEntity(coordinator, description)
|
||||
for description in ENTITIES
|
||||
if description.supported_fn(coordinator)
|
||||
)
|
||||
]
|
||||
|
||||
entities: list[LaMarzoccoKeyNumberEntity] = []
|
||||
for description in KEY_ENTITIES:
|
||||
if description.supported_fn(coordinator):
|
||||
num_keys = KEYS_PER_MODEL[coordinator.lm.model_name]
|
||||
for key in range(min(num_keys, 1), num_keys + 1):
|
||||
entities.append(
|
||||
LaMarzoccoKeyNumberEntity(coordinator, description, key)
|
||||
)
|
||||
entities.extend(
|
||||
LaMarzoccoKeyNumberEntity(coordinator, description, key)
|
||||
for key in range(min(num_keys, 1), num_keys + 1)
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
|
||||
|
|
|
@ -286,11 +286,10 @@ async def async_setup_entry(
|
|||
name="Landis+Gyr Heat Meter",
|
||||
)
|
||||
|
||||
sensors = []
|
||||
for description in HEAT_METER_SENSOR_TYPES:
|
||||
sensors.append(HeatMeterSensor(coordinator, description, device))
|
||||
|
||||
async_add_entities(sensors)
|
||||
async_add_entities(
|
||||
HeatMeterSensor(coordinator, description, device)
|
||||
for description in HEAT_METER_SENSOR_TYPES
|
||||
)
|
||||
|
||||
|
||||
class HeatMeterSensor(
|
||||
|
|
|
@ -43,15 +43,12 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up LCN switch entities from a config entry."""
|
||||
entities = []
|
||||
|
||||
for entity_config in config_entry.data[CONF_ENTITIES]:
|
||||
if entity_config[CONF_DOMAIN] == DOMAIN_BINARY_SENSOR:
|
||||
entities.append(
|
||||
create_lcn_binary_sensor_entity(hass, entity_config, config_entry)
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
create_lcn_binary_sensor_entity(hass, entity_config, config_entry)
|
||||
for entity_config in config_entry.data[CONF_ENTITIES]
|
||||
if entity_config[CONF_DOMAIN] == DOMAIN_BINARY_SENSOR
|
||||
)
|
||||
|
||||
|
||||
class LcnRegulatorLockSensor(LcnEntity, BinarySensorEntity):
|
||||
|
|
|
@ -56,15 +56,12 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up LCN switch entities from a config entry."""
|
||||
entities = []
|
||||
|
||||
for entity_config in config_entry.data[CONF_ENTITIES]:
|
||||
if entity_config[CONF_DOMAIN] == DOMAIN_CLIMATE:
|
||||
entities.append(
|
||||
create_lcn_climate_entity(hass, entity_config, config_entry)
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
create_lcn_climate_entity(hass, entity_config, config_entry)
|
||||
for entity_config in config_entry.data[CONF_ENTITIES]
|
||||
if entity_config[CONF_DOMAIN] == DOMAIN_CLIMATE
|
||||
)
|
||||
|
||||
|
||||
class LcnClimate(LcnEntity, ClimateEntity):
|
||||
|
|
|
@ -40,13 +40,12 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up LCN cover entities from a config entry."""
|
||||
entities = []
|
||||
|
||||
for entity_config in config_entry.data[CONF_ENTITIES]:
|
||||
if entity_config[CONF_DOMAIN] == DOMAIN_COVER:
|
||||
entities.append(create_lcn_cover_entity(hass, entity_config, config_entry))
|
||||
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
create_lcn_cover_entity(hass, entity_config, config_entry)
|
||||
for entity_config in config_entry.data[CONF_ENTITIES]
|
||||
if entity_config[CONF_DOMAIN] == DOMAIN_COVER
|
||||
)
|
||||
|
||||
|
||||
class LcnOutputsCover(LcnEntity, CoverEntity):
|
||||
|
|
|
@ -53,13 +53,12 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up LCN light entities from a config entry."""
|
||||
entities = []
|
||||
|
||||
for entity_config in config_entry.data[CONF_ENTITIES]:
|
||||
if entity_config[CONF_DOMAIN] == DOMAIN_LIGHT:
|
||||
entities.append(create_lcn_light_entity(hass, entity_config, config_entry))
|
||||
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
create_lcn_light_entity(hass, entity_config, config_entry)
|
||||
for entity_config in config_entry.data[CONF_ENTITIES]
|
||||
if entity_config[CONF_DOMAIN] == DOMAIN_LIGHT
|
||||
)
|
||||
|
||||
|
||||
class LcnOutputLight(LcnEntity, LightEntity):
|
||||
|
|
|
@ -43,13 +43,12 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up LCN switch entities from a config entry."""
|
||||
entities = []
|
||||
|
||||
for entity_config in config_entry.data[CONF_ENTITIES]:
|
||||
if entity_config[CONF_DOMAIN] == DOMAIN_SCENE:
|
||||
entities.append(create_lcn_scene_entity(hass, entity_config, config_entry))
|
||||
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
create_lcn_scene_entity(hass, entity_config, config_entry)
|
||||
for entity_config in config_entry.data[CONF_ENTITIES]
|
||||
if entity_config[CONF_DOMAIN] == DOMAIN_SCENE
|
||||
)
|
||||
|
||||
|
||||
class LcnScene(LcnEntity, Scene):
|
||||
|
|
|
@ -56,13 +56,12 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up LCN switch entities from a config entry."""
|
||||
entities = []
|
||||
|
||||
for entity_config in config_entry.data[CONF_ENTITIES]:
|
||||
if entity_config[CONF_DOMAIN] == DOMAIN_SENSOR:
|
||||
entities.append(create_lcn_sensor_entity(hass, entity_config, config_entry))
|
||||
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
create_lcn_sensor_entity(hass, entity_config, config_entry)
|
||||
for entity_config in config_entry.data[CONF_ENTITIES]
|
||||
if entity_config[CONF_DOMAIN] == DOMAIN_SENSOR
|
||||
)
|
||||
|
||||
|
||||
class LcnVariableSensor(LcnEntity, SensorEntity):
|
||||
|
|
|
@ -41,13 +41,11 @@ async def async_setup_entry(
|
|||
) -> None:
|
||||
"""Set up LCN switch entities from a config entry."""
|
||||
|
||||
entities = []
|
||||
|
||||
for entity_config in config_entry.data[CONF_ENTITIES]:
|
||||
if entity_config[CONF_DOMAIN] == DOMAIN_SWITCH:
|
||||
entities.append(create_lcn_switch_entity(hass, entity_config, config_entry))
|
||||
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
create_lcn_switch_entity(hass, entity_config, config_entry)
|
||||
for entity_config in config_entry.data[CONF_ENTITIES]
|
||||
if entity_config[CONF_DOMAIN] == DOMAIN_SWITCH
|
||||
)
|
||||
|
||||
|
||||
class LcnOutputSwitch(LcnEntity, SwitchEntity):
|
||||
|
|
|
@ -166,11 +166,11 @@ class LGDevice(MediaPlayerEntity):
|
|||
@property
|
||||
def sound_mode_list(self):
|
||||
"""Return the available sound modes."""
|
||||
modes = []
|
||||
for equaliser in self._equalisers:
|
||||
if equaliser < len(temescal.equalisers):
|
||||
modes.append(temescal.equalisers[equaliser])
|
||||
return sorted(modes)
|
||||
return sorted(
|
||||
temescal.equalisers[equaliser]
|
||||
for equaliser in self._equalisers
|
||||
if equaliser < len(temescal.equalisers)
|
||||
)
|
||||
|
||||
@property
|
||||
def source(self):
|
||||
|
@ -182,11 +182,11 @@ class LGDevice(MediaPlayerEntity):
|
|||
@property
|
||||
def source_list(self):
|
||||
"""List of available input sources."""
|
||||
sources = []
|
||||
for function in self._functions:
|
||||
if function < len(temescal.functions):
|
||||
sources.append(temescal.functions[function])
|
||||
return sorted(sources)
|
||||
return sorted(
|
||||
temescal.functions[function]
|
||||
for function in self._functions
|
||||
if function < len(temescal.functions)
|
||||
)
|
||||
|
||||
def set_volume_level(self, volume: float) -> None:
|
||||
"""Set volume level, range 0..1."""
|
||||
|
|
|
@ -381,8 +381,7 @@ class LIFXUpdateCoordinator(DataUpdateCoordinator[None]):
|
|||
|
||||
# pad the color list with blanks if necessary
|
||||
if len(colors) < 82:
|
||||
for _ in range(82 - len(colors)):
|
||||
colors.append((0, 0, 0, 0))
|
||||
colors.extend([(0, 0, 0, 0) for _ in range(82 - len(colors))])
|
||||
|
||||
await async_execute_lifx(
|
||||
partial(
|
||||
|
|
|
@ -176,10 +176,10 @@ def async_subscribe_events(
|
|||
event_forwarder = event_forwarder_filtered(
|
||||
target, entities_filter, entity_ids, device_ids
|
||||
)
|
||||
for event_type in event_types:
|
||||
subscriptions.append(
|
||||
hass.bus.async_listen(event_type, event_forwarder, run_immediately=True)
|
||||
)
|
||||
subscriptions.extend(
|
||||
hass.bus.async_listen(event_type, event_forwarder, run_immediately=True)
|
||||
for event_type in event_types
|
||||
)
|
||||
|
||||
if device_ids and not entity_ids:
|
||||
# No entities to subscribe to but we are filtering
|
||||
|
|
|
@ -72,11 +72,8 @@ def setup_platform(
|
|||
"""Set up the London Air sensor."""
|
||||
data = APIData()
|
||||
data.update()
|
||||
sensors = []
|
||||
for name in config[CONF_LOCATIONS]:
|
||||
sensors.append(AirSensor(name, data))
|
||||
|
||||
add_entities(sensors, True)
|
||||
add_entities((AirSensor(name, data) for name in config[CONF_LOCATIONS]), True)
|
||||
|
||||
|
||||
class APIData:
|
||||
|
@ -141,14 +138,16 @@ class AirSensor(SensorEntity):
|
|||
|
||||
def update(self) -> None:
|
||||
"""Update the sensor."""
|
||||
sites_status = []
|
||||
sites_status: list = []
|
||||
self._api_data.update()
|
||||
if self._api_data.data:
|
||||
self._site_data = self._api_data.data[self._name]
|
||||
self._updated = self._site_data[0]["updated"]
|
||||
for site in self._site_data:
|
||||
if site["pollutants_status"] != "no_species_data":
|
||||
sites_status.append(site["pollutants_status"])
|
||||
sites_status.extend(
|
||||
site["pollutants_status"]
|
||||
for site in self._site_data
|
||||
if site["pollutants_status"] != "no_species_data"
|
||||
)
|
||||
|
||||
if sites_status:
|
||||
self._state = max(set(sites_status), key=sites_status.count)
|
||||
|
|
|
@ -45,11 +45,9 @@ async def async_setup_platform(
|
|||
if not coordinator.last_update_success:
|
||||
raise PlatformNotReady
|
||||
|
||||
sensors = []
|
||||
for line in config[CONF_LINE]:
|
||||
sensors.append(LondonTubeSensor(coordinator, line))
|
||||
|
||||
async_add_entities(sensors)
|
||||
async_add_entities(
|
||||
LondonTubeSensor(coordinator, line) for line in config[CONF_LINE]
|
||||
)
|
||||
|
||||
|
||||
class LondonTubeSensor(CoordinatorEntity[LondonTubeCoordinator], SensorEntity):
|
||||
|
|
|
@ -96,14 +96,11 @@ class LuciDeviceScanner(DeviceScanner):
|
|||
|
||||
_LOGGER.debug("Luci get_all_connected_devices returned: %s", result)
|
||||
|
||||
last_results = []
|
||||
for device in result:
|
||||
if (
|
||||
not hasattr(self.router.router.owrt_version, "release")
|
||||
or not self.router.router.owrt_version.release
|
||||
or self.router.router.owrt_version.release[0] < 19
|
||||
or device.reachable
|
||||
):
|
||||
last_results.append(device)
|
||||
|
||||
self.last_results = last_results
|
||||
self.last_results = [
|
||||
device
|
||||
for device in result
|
||||
if not hasattr(self.router.router.owrt_version, "release")
|
||||
or not self.router.router.owrt_version.release
|
||||
or self.router.router.owrt_version.release[0] < 19
|
||||
or device.reachable
|
||||
]
|
||||
|
|
|
@ -35,13 +35,12 @@ async def async_setup_entry(
|
|||
|
||||
device_types = CONST.TYPE_OPENING + CONST.TYPE_SENSOR
|
||||
|
||||
sensors = []
|
||||
partial_func = partial(data.get_devices, generic_type=device_types)
|
||||
devices = await hass.async_add_executor_job(partial_func)
|
||||
for device in devices:
|
||||
sensors.append(LupusecBinarySensor(device, config_entry.entry_id))
|
||||
|
||||
async_add_entities(sensors)
|
||||
async_add_entities(
|
||||
LupusecBinarySensor(device, config_entry.entry_id) for device in devices
|
||||
)
|
||||
|
||||
|
||||
class LupusecBinarySensor(LupusecBaseSensor, BinarySensorEntity):
|
||||
|
|
|
@ -30,13 +30,12 @@ async def async_setup_entry(
|
|||
|
||||
device_types = CONST.TYPE_SWITCH
|
||||
|
||||
switches = []
|
||||
partial_func = partial(data.get_devices, generic_type=device_types)
|
||||
devices = await hass.async_add_executor_job(partial_func)
|
||||
for device in devices:
|
||||
switches.append(LupusecSwitch(device, config_entry.entry_id))
|
||||
|
||||
async_add_entities(switches)
|
||||
async_add_entities(
|
||||
LupusecSwitch(device, config_entry.entry_id) for device in devices
|
||||
)
|
||||
|
||||
|
||||
class LupusecSwitch(LupusecBaseSensor, SwitchEntity):
|
||||
|
|
|
@ -379,8 +379,6 @@ async def async_get_triggers(
|
|||
hass: HomeAssistant, device_id: str
|
||||
) -> list[dict[str, str]]:
|
||||
"""List device triggers for lutron caseta devices."""
|
||||
triggers = []
|
||||
|
||||
# Check if device is a valid keypad. Return empty if not.
|
||||
if not (data := get_lutron_data_by_dr_id(hass, device_id)) or not (
|
||||
keypad := data.keypad_data.dr_device_id_to_keypad.get(device_id)
|
||||
|
@ -395,19 +393,17 @@ async def async_get_triggers(
|
|||
keypad_button_names_to_leap[keypad["lutron_device_id"]],
|
||||
)
|
||||
|
||||
for trigger in SUPPORTED_INPUTS_EVENTS_TYPES:
|
||||
for subtype in valid_buttons:
|
||||
triggers.append(
|
||||
{
|
||||
CONF_PLATFORM: "device",
|
||||
CONF_DEVICE_ID: device_id,
|
||||
CONF_DOMAIN: DOMAIN,
|
||||
CONF_TYPE: trigger,
|
||||
CONF_SUBTYPE: subtype,
|
||||
}
|
||||
)
|
||||
|
||||
return triggers
|
||||
return [
|
||||
{
|
||||
CONF_PLATFORM: "device",
|
||||
CONF_DEVICE_ID: device_id,
|
||||
CONF_DOMAIN: DOMAIN,
|
||||
CONF_TYPE: trigger,
|
||||
CONF_SUBTYPE: subtype,
|
||||
}
|
||||
for trigger in SUPPORTED_INPUTS_EVENTS_TYPES
|
||||
for subtype in valid_buttons
|
||||
]
|
||||
|
||||
|
||||
async def async_attach_trigger(
|
||||
|
|
|
@ -126,23 +126,22 @@ async def async_setup_entry(
|
|||
"""Set up the Honeywell Lyric climate platform based on a config entry."""
|
||||
coordinator: DataUpdateCoordinator[Lyric] = hass.data[DOMAIN][entry.entry_id]
|
||||
|
||||
entities = []
|
||||
|
||||
for location in coordinator.data.locations:
|
||||
for device in location.devices:
|
||||
entities.append(
|
||||
LyricClimate(
|
||||
coordinator,
|
||||
ClimateEntityDescription(
|
||||
key=f"{device.macID}_thermostat",
|
||||
name=device.name,
|
||||
),
|
||||
location,
|
||||
device,
|
||||
)
|
||||
async_add_entities(
|
||||
(
|
||||
LyricClimate(
|
||||
coordinator,
|
||||
ClimateEntityDescription(
|
||||
key=f"{device.macID}_thermostat",
|
||||
name=device.name,
|
||||
),
|
||||
location,
|
||||
device,
|
||||
)
|
||||
|
||||
async_add_entities(entities, True)
|
||||
for location in coordinator.data.locations
|
||||
for device in location.devices
|
||||
),
|
||||
True,
|
||||
)
|
||||
|
||||
platform = entity_platform.async_get_current_platform()
|
||||
|
||||
|
|
|
@ -149,7 +149,18 @@ async def async_setup_entry(
|
|||
)
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
async_add_entities(
|
||||
LyricSensor(
|
||||
coordinator,
|
||||
device_sensor,
|
||||
location,
|
||||
device,
|
||||
)
|
||||
for location in coordinator.data.locations
|
||||
for device in location.devices
|
||||
for device_sensor in DEVICE_SENSORS
|
||||
if device_sensor.suitable_fn(device)
|
||||
)
|
||||
|
||||
|
||||
class LyricSensor(LyricDeviceEntity, SensorEntity):
|
||||
|
|
|
@ -232,16 +232,16 @@ class MailboxPlatformsView(MailboxView):
|
|||
|
||||
async def get(self, request: web.Request) -> web.Response:
|
||||
"""Retrieve list of platforms."""
|
||||
platforms: list[dict[str, Any]] = []
|
||||
for mailbox in self.mailboxes:
|
||||
platforms.append(
|
||||
return self.json(
|
||||
[
|
||||
{
|
||||
"name": mailbox.name,
|
||||
"has_media": mailbox.has_media,
|
||||
"can_delete": mailbox.can_delete,
|
||||
}
|
||||
)
|
||||
return self.json(platforms)
|
||||
for mailbox in self.mailboxes
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class MailboxMessageView(MailboxView):
|
||||
|
|
|
@ -432,18 +432,16 @@ class MatrixBot:
|
|||
self, target_rooms: Sequence[RoomAnyID], message_type: str, content: dict
|
||||
) -> None:
|
||||
"""Wrap _handle_room_send for multiple target_rooms."""
|
||||
_tasks = []
|
||||
for target_room in target_rooms:
|
||||
_tasks.append(
|
||||
self.hass.async_create_task(
|
||||
self._handle_room_send(
|
||||
target_room=target_room,
|
||||
message_type=message_type,
|
||||
content=content,
|
||||
)
|
||||
await asyncio.wait(
|
||||
self.hass.async_create_task(
|
||||
self._handle_room_send(
|
||||
target_room=target_room,
|
||||
message_type=message_type,
|
||||
content=content,
|
||||
)
|
||||
)
|
||||
await asyncio.wait(_tasks)
|
||||
for target_room in target_rooms
|
||||
)
|
||||
|
||||
async def _send_image(
|
||||
self, image_path: str, target_rooms: Sequence[RoomAnyID]
|
||||
|
|
|
@ -54,13 +54,13 @@ def setup_platform(
|
|||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Iterate through all MAX! Devices and add thermostats."""
|
||||
devices = []
|
||||
for handler in hass.data[DATA_KEY].values():
|
||||
for device in handler.cube.devices:
|
||||
if device.is_thermostat() or device.is_wallthermostat():
|
||||
devices.append(MaxCubeClimate(handler, device))
|
||||
|
||||
add_entities(devices)
|
||||
add_entities(
|
||||
MaxCubeClimate(handler, device)
|
||||
for handler in hass.data[DATA_KEY].values()
|
||||
for device in handler.cube.devices
|
||||
if device.is_thermostat() or device.is_wallthermostat()
|
||||
)
|
||||
|
||||
|
||||
class MaxCubeClimate(ClimateEntity):
|
||||
|
|
|
@ -44,13 +44,14 @@ async def async_setup_platform(
|
|||
api = hass.data[DATA_MELISSA]
|
||||
devices = (await api.async_fetch_devices()).values()
|
||||
|
||||
all_devices = []
|
||||
|
||||
for device in devices:
|
||||
if device["type"] == "melissa":
|
||||
all_devices.append(MelissaClimate(api, device["serial_number"], device))
|
||||
|
||||
async_add_entities(all_devices, True)
|
||||
async_add_entities(
|
||||
(
|
||||
MelissaClimate(api, device["serial_number"], device)
|
||||
for device in devices
|
||||
if device["type"] == "melissa"
|
||||
),
|
||||
True,
|
||||
)
|
||||
|
||||
|
||||
class MelissaClimate(ClimateEntity):
|
||||
|
|
|
@ -117,14 +117,15 @@ def get_entities_for_valves(
|
|||
],
|
||||
) -> list[CoordinatorEntity[MelnorDataUpdateCoordinator]]:
|
||||
"""Get descriptions for valves."""
|
||||
entities = []
|
||||
entities: list[CoordinatorEntity[MelnorDataUpdateCoordinator]] = []
|
||||
|
||||
# This device may not have 4 valves total, but the library will only expose the right number of valves
|
||||
for i in range(1, 5):
|
||||
valve = coordinator.data[f"zone{i}"]
|
||||
|
||||
if valve is not None:
|
||||
for description in descriptions:
|
||||
entities.append(function(valve, description))
|
||||
entities.extend(
|
||||
function(valve, description) for description in descriptions
|
||||
)
|
||||
|
||||
return entities
|
||||
|
|
|
@ -56,15 +56,12 @@ async def async_setup_platform(
|
|||
api = hass.data[DATA_MICROSOFT_FACE]
|
||||
attributes = config[CONF_ATTRIBUTES]
|
||||
|
||||
entities = []
|
||||
for camera in config[CONF_SOURCE]:
|
||||
entities.append(
|
||||
MicrosoftFaceDetectEntity(
|
||||
camera[CONF_ENTITY_ID], api, attributes, camera.get(CONF_NAME)
|
||||
)
|
||||
async_add_entities(
|
||||
MicrosoftFaceDetectEntity(
|
||||
camera[CONF_ENTITY_ID], api, attributes, camera.get(CONF_NAME)
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
for camera in config[CONF_SOURCE]
|
||||
)
|
||||
|
||||
|
||||
class MicrosoftFaceDetectEntity(ImageProcessingFaceEntity):
|
||||
|
|
|
@ -38,19 +38,16 @@ async def async_setup_platform(
|
|||
face_group = config[CONF_GROUP]
|
||||
confidence = config[CONF_CONFIDENCE]
|
||||
|
||||
entities = []
|
||||
for camera in config[CONF_SOURCE]:
|
||||
entities.append(
|
||||
MicrosoftFaceIdentifyEntity(
|
||||
camera[CONF_ENTITY_ID],
|
||||
api,
|
||||
face_group,
|
||||
confidence,
|
||||
camera.get(CONF_NAME),
|
||||
)
|
||||
async_add_entities(
|
||||
MicrosoftFaceIdentifyEntity(
|
||||
camera[CONF_ENTITY_ID],
|
||||
api,
|
||||
face_group,
|
||||
confidence,
|
||||
camera.get(CONF_NAME),
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
for camera in config[CONF_SOURCE]
|
||||
)
|
||||
|
||||
|
||||
class MicrosoftFaceIdentifyEntity(ImageProcessingFaceEntity):
|
||||
|
|
|
@ -140,8 +140,7 @@ class MinecraftServer:
|
|||
players_list: list[str] = []
|
||||
|
||||
if players := status_response.players.sample:
|
||||
for player in players:
|
||||
players_list.append(player.name)
|
||||
players_list.extend(player.name for player in players)
|
||||
players_list.sort()
|
||||
|
||||
return MinecraftServerData(
|
||||
|
|
|
@ -93,10 +93,9 @@ class ModbusBinarySensor(BasePlatform, RestoreEntity, BinarySensorEntity):
|
|||
name=name,
|
||||
)
|
||||
|
||||
slaves: list[SlaveSensor] = []
|
||||
for idx in range(0, slave_count):
|
||||
slaves.append(SlaveSensor(self._coordinator, idx, entry))
|
||||
return slaves
|
||||
return [
|
||||
SlaveSensor(self._coordinator, idx, entry) for idx in range(0, slave_count)
|
||||
]
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Handle entity which will be added."""
|
||||
|
|
|
@ -94,10 +94,9 @@ class ModbusRegisterSensor(BaseStructPlatform, RestoreSensor, SensorEntity):
|
|||
name=name,
|
||||
)
|
||||
|
||||
slaves: list[SlaveSensor] = []
|
||||
for idx in range(0, slave_count):
|
||||
slaves.append(SlaveSensor(self._coordinator, idx, entry))
|
||||
return slaves
|
||||
return [
|
||||
SlaveSensor(self._coordinator, idx, entry) for idx in range(0, slave_count)
|
||||
]
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Handle entity which will be added."""
|
||||
|
|
|
@ -71,9 +71,8 @@ def setup_platform(
|
|||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the MVGLive sensor."""
|
||||
sensors = []
|
||||
for nextdeparture in config[CONF_NEXT_DEPARTURE]:
|
||||
sensors.append(
|
||||
add_entities(
|
||||
(
|
||||
MVGLiveSensor(
|
||||
nextdeparture.get(CONF_STATION),
|
||||
nextdeparture.get(CONF_DESTINATIONS),
|
||||
|
@ -84,8 +83,10 @@ def setup_platform(
|
|||
nextdeparture.get(CONF_NUMBER),
|
||||
nextdeparture.get(CONF_NAME),
|
||||
)
|
||||
)
|
||||
add_entities(sensors, True)
|
||||
for nextdeparture in config[CONF_NEXT_DEPARTURE]
|
||||
),
|
||||
True,
|
||||
)
|
||||
|
||||
|
||||
class MVGLiveSensor(SensorEntity):
|
||||
|
|
|
@ -52,13 +52,12 @@ async def async_setup_entry(
|
|||
) -> None:
|
||||
"""Set up the myStrom entities."""
|
||||
device: MyStromSwitch = hass.data[DOMAIN][entry.entry_id].device
|
||||
sensors = []
|
||||
|
||||
for description in SENSOR_TYPES:
|
||||
if description.value_fn(device) is not None:
|
||||
sensors.append(MyStromSwitchSensor(device, entry.title, description))
|
||||
|
||||
async_add_entities(sensors)
|
||||
async_add_entities(
|
||||
MyStromSwitchSensor(device, entry.title, description)
|
||||
for description in SENSOR_TYPES
|
||||
if description.value_fn(device) is not None
|
||||
)
|
||||
|
||||
|
||||
class MyStromSwitchSensor(SensorEntity):
|
||||
|
|
|
@ -25,21 +25,17 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up update entity."""
|
||||
entities: list[UpdateEntity] = []
|
||||
coordinator: MyUplinkDataCoordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
|
||||
# Setup update entities
|
||||
for device_id in coordinator.data.devices:
|
||||
entities.append(
|
||||
MyUplinkDeviceUpdate(
|
||||
coordinator=coordinator,
|
||||
device_id=device_id,
|
||||
entity_description=UPDATE_DESCRIPTION,
|
||||
unique_id_suffix="upd",
|
||||
)
|
||||
async_add_entities(
|
||||
MyUplinkDeviceUpdate(
|
||||
coordinator=coordinator,
|
||||
device_id=device_id,
|
||||
entity_description=UPDATE_DESCRIPTION,
|
||||
unique_id_suffix="upd",
|
||||
)
|
||||
|
||||
async_add_entities(entities)
|
||||
for device_id in coordinator.data.devices
|
||||
)
|
||||
|
||||
|
||||
class MyUplinkDeviceUpdate(MyUplinkEntity, UpdateEntity):
|
||||
|
|
|
@ -1399,15 +1399,13 @@ async def test_missing_discover_abbreviations(
|
|||
continue
|
||||
with open(fil, encoding="utf-8") as file:
|
||||
matches = re.findall(regex, file.read())
|
||||
for match in matches:
|
||||
if (
|
||||
match[1] not in ABBREVIATIONS.values()
|
||||
and match[1] not in DEVICE_ABBREVIATIONS.values()
|
||||
and match[0] not in ABBREVIATIONS_WHITE_LIST
|
||||
):
|
||||
missing.append(
|
||||
f"{fil}: no abbreviation for {match[1]} ({match[0]})"
|
||||
)
|
||||
missing.extend(
|
||||
f"{fil}: no abbreviation for {match[1]} ({match[0]})"
|
||||
for match in matches
|
||||
if match[1] not in ABBREVIATIONS.values()
|
||||
and match[1] not in DEVICE_ABBREVIATIONS.values()
|
||||
and match[0] not in ABBREVIATIONS_WHITE_LIST
|
||||
)
|
||||
|
||||
assert not missing
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue