Improve lists in integrations [N-O] (#113231)

pull/113270/head
Joost Lekkerkerker 2024-03-13 21:51:38 +01:00 committed by GitHub
parent 595d07f1c6
commit e6a692f354
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
35 changed files with 254 additions and 310 deletions

View File

@ -367,12 +367,11 @@ async def async_setup_entry(
)
ent_reg.async_update_entity(entity_id, new_unique_id=new_unique_id)
sensors: list[NAMSensor] = []
for description in SENSORS:
if getattr(coordinator.data, description.key) is not None:
sensors.append(NAMSensor(coordinator, description))
async_add_entities(sensors, False)
async_add_entities(
NAMSensor(coordinator, description)
for description in SENSORS
if getattr(coordinator.data, description.key) is not None
)
class NAMSensor(CoordinatorEntity[NAMDataUpdateCoordinator], SensorEntity):

View File

@ -29,12 +29,13 @@ async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up Neato camera with config entry."""
dev = []
neato: NeatoHub = hass.data[NEATO_LOGIN]
mapdata: dict[str, Any] | None = hass.data.get(NEATO_MAP_DATA)
for robot in hass.data[NEATO_ROBOTS]:
if "maps" in robot.traits:
dev.append(NeatoCleaningMap(neato, robot, mapdata))
dev = [
NeatoCleaningMap(neato, robot, mapdata)
for robot in hass.data[NEATO_ROBOTS]
if "maps" in robot.traits
]
if not dev:
return

View File

@ -30,10 +30,8 @@ async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up the Neato sensor using config entry."""
dev = []
neato: NeatoHub = hass.data[NEATO_LOGIN]
for robot in hass.data[NEATO_ROBOTS]:
dev.append(NeatoSensor(neato, robot))
dev = [NeatoSensor(neato, robot) for robot in hass.data[NEATO_ROBOTS]]
if not dev:
return

View File

@ -32,12 +32,12 @@ async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up Neato switch with config entry."""
dev = []
neato: NeatoHub = hass.data[NEATO_LOGIN]
for robot in hass.data[NEATO_ROBOTS]:
for type_name in SWITCH_TYPES:
dev.append(NeatoConnectedSwitch(neato, robot, type_name))
dev = [
NeatoConnectedSwitch(neato, robot, type_name)
for robot in hass.data[NEATO_ROBOTS]
for type_name in SWITCH_TYPES
]
if not dev:
return

View File

@ -64,12 +64,13 @@ async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up Neato vacuum with config entry."""
dev = []
neato: NeatoHub = hass.data[NEATO_LOGIN]
mapdata: dict[str, Any] | None = hass.data.get(NEATO_MAP_DATA)
persistent_maps: dict[str, Any] | None = hass.data.get(NEATO_PERSISTENT_MAPS)
for robot in hass.data[NEATO_ROBOTS]:
dev.append(NeatoConnectedVacuum(neato, robot, mapdata, persistent_maps))
dev = [
NeatoConnectedVacuum(neato, robot, mapdata, persistent_maps)
for robot in hass.data[NEATO_ROBOTS]
]
if not dev:
return

View File

@ -135,8 +135,7 @@ class NSDepartureSensor(SensorEntity):
if self._trips[0].trip_parts:
route = [self._trips[0].departure]
for k in self._trips[0].trip_parts:
route.append(k.destination)
route.extend(k.destination for k in self._trips[0].trip_parts)
# Static attributes
attributes = {

View File

@ -48,14 +48,12 @@ async def async_setup_entry(
device_manager: DeviceManager = hass.data[DOMAIN][entry.entry_id][
DATA_DEVICE_MANAGER
]
entities = []
for device in device_manager.devices.values():
if (
CameraImageTrait.NAME in device.traits
or CameraLiveStreamTrait.NAME in device.traits
):
entities.append(NestCamera(device))
async_add_entities(entities)
async_add_entities(
NestCamera(device)
for device in device_manager.devices.values()
if CameraImageTrait.NAME in device.traits
or CameraLiveStreamTrait.NAME in device.traits
)
class NestCamera(Camera):

View File

@ -86,11 +86,12 @@ async def async_setup_entry(
device_manager: DeviceManager = hass.data[DOMAIN][entry.entry_id][
DATA_DEVICE_MANAGER
]
entities = []
for device in device_manager.devices.values():
if ThermostatHvacTrait.NAME in device.traits:
entities.append(ThermostatEntity(device))
async_add_entities(entities)
async_add_entities(
ThermostatEntity(device)
for device in device_manager.devices.values()
if ThermostatHvacTrait.NAME in device.traits
)
class ThermostatEntity(ClimateEntity):
@ -217,13 +218,13 @@ class ThermostatEntity(ClimateEntity):
@property
def preset_modes(self) -> list[str]:
"""Return the available presets."""
modes = []
if ThermostatEcoTrait.NAME in self._device.traits:
trait = self._device.traits[ThermostatEcoTrait.NAME]
for mode in trait.available_modes:
if mode in PRESET_MODE_MAP:
modes.append(PRESET_MODE_MAP[mode])
return modes
if ThermostatEcoTrait.NAME not in self._device.traits:
return []
return [
PRESET_MODE_MAP[mode]
for mode in self._device.traits[ThermostatEcoTrait.NAME].available_modes
if mode in PRESET_MODE_MAP
]
@property
def fan_mode(self) -> str:

View File

@ -71,10 +71,11 @@ def _generate_subscription_id(cloud_project_id: str) -> str:
def generate_config_title(structures: Iterable[Structure]) -> str | None:
"""Pick a user friendly config title based on the Google Home name(s)."""
names: list[str] = []
for structure in structures:
if (trait := structure.traits.get(InfoTrait.NAME)) and trait.custom_name:
names.append(trait.custom_name)
names: list[str] = [
trait.custom_name
for structure in structures
if (trait := structure.traits.get(InfoTrait.NAME)) and trait.custom_name
]
if not names:
return None
return ", ".join(names)

View File

@ -490,9 +490,10 @@ def _browse_clip_preview(
event_id: MediaId, device: Device, event: ClipPreviewSession
) -> BrowseMediaSource:
"""Build a BrowseMediaSource for a specific clip preview event."""
types = []
for event_type in event.event_types:
types.append(MEDIA_SOURCE_EVENT_TITLE_MAP.get(event_type, "Event"))
types = [
MEDIA_SOURCE_EVENT_TITLE_MAP.get(event_type, "Event")
for event_type in event.event_types
]
return BrowseMediaSource(
domain=DOMAIN,
identifier=event_id.identifier,

View File

@ -96,7 +96,7 @@ async def async_get_triggers(
"""List device triggers for Netatmo devices."""
registry = er.async_get(hass)
device_registry = dr.async_get(hass)
triggers = []
triggers: list[dict[str, str]] = []
for entry in er.async_entries_for_device(registry, device_id):
if (
@ -106,17 +106,17 @@ async def async_get_triggers(
for trigger in DEVICES.get(device.model, []):
if trigger in SUBTYPES:
for subtype in SUBTYPES[trigger]:
triggers.append(
{
CONF_PLATFORM: "device",
CONF_DEVICE_ID: device_id,
CONF_DOMAIN: DOMAIN,
CONF_ENTITY_ID: entry.id,
CONF_TYPE: trigger,
CONF_SUBTYPE: subtype,
}
)
triggers.extend(
{
CONF_PLATFORM: "device",
CONF_DEVICE_ID: device_id,
CONF_DOMAIN: DOMAIN,
CONF_ENTITY_ID: entry.id,
CONF_TYPE: trigger,
CONF_SUBTYPE: subtype,
}
for subtype in SUBTYPES[trigger]
)
else:
triggers.append(
{

View File

@ -280,30 +280,16 @@ async def async_setup_entry(
coordinator_utilization = hass.data[DOMAIN][entry.entry_id][KEY_COORDINATOR_UTIL]
coordinator_link = hass.data[DOMAIN][entry.entry_id][KEY_COORDINATOR_LINK]
# Router entities
router_entities = []
for description in SENSOR_TRAFFIC_TYPES:
router_entities.append(
NetgearRouterSensorEntity(coordinator_traffic, router, description)
async_add_entities(
NetgearRouterSensorEntity(coordinator, router, description)
for (coordinator, descriptions) in (
(coordinator_traffic, SENSOR_TRAFFIC_TYPES),
(coordinator_speed, SENSOR_SPEED_TYPES),
(coordinator_utilization, SENSOR_UTILIZATION),
(coordinator_link, SENSOR_LINK_TYPES),
)
for description in SENSOR_SPEED_TYPES:
router_entities.append(
NetgearRouterSensorEntity(coordinator_speed, router, description)
)
for description in SENSOR_UTILIZATION:
router_entities.append(
NetgearRouterSensorEntity(coordinator_utilization, router, description)
)
for description in SENSOR_LINK_TYPES:
router_entities.append(
NetgearRouterSensorEntity(coordinator_link, router, description)
)
async_add_entities(router_entities)
for description in descriptions
)
# Entities per network device
tracked = set()
@ -317,17 +303,15 @@ async def async_setup_entry(
if not coordinator.data:
return
new_entities = []
new_entities: list[NetgearSensorEntity] = []
for mac, device in router.devices.items():
if mac in tracked:
continue
new_entities.extend(
[
NetgearSensorEntity(coordinator, router, device, attribute)
for attribute in sensors
]
NetgearSensorEntity(coordinator, router, device, attribute)
for attribute in sensors
)
tracked.add(mac)

View File

@ -104,13 +104,10 @@ async def async_setup_entry(
"""Set up switches for Netgear component."""
router = hass.data[DOMAIN][entry.entry_id][KEY_ROUTER]
# Router entities
router_entities = []
for description in ROUTER_SWITCH_TYPES:
router_entities.append(NetgearRouterSwitchEntity(router, description))
async_add_entities(router_entities)
async_add_entities(
NetgearRouterSwitchEntity(router, description)
for description in ROUTER_SWITCH_TYPES
)
# Entities per network device
coordinator = hass.data[DOMAIN][entry.entry_id][KEY_COORDINATOR]

View File

@ -131,10 +131,8 @@ async def async_get_announce_addresses(hass: HomeAssistant) -> list[str]:
for adapter in adapters:
if not adapter["enabled"]:
continue
for ips in adapter["ipv4"]:
addresses.append(str(IPv4Address(ips["address"])))
for ips in adapter["ipv6"]:
addresses.append(str(IPv6Address(ips["address"])))
addresses.extend(str(IPv4Address(ips["address"])) for ips in adapter["ipv4"])
addresses.extend(str(IPv6Address(ips["address"])) for ips in adapter["ipv6"])
# Puts the default IPv4 address first in the list to preserve compatibility,
# because some mDNS implementations ignores anything but the first announced

View File

@ -68,11 +68,9 @@ async def async_setup_entry(
ATTR_CONNECTION
]
sensors: list[NextDnsBinarySensor] = []
for description in SENSORS:
sensors.append(NextDnsBinarySensor(coordinator, description))
async_add_entities(sensors)
async_add_entities(
NextDnsBinarySensor(coordinator, description) for description in SENSORS
)
class NextDnsBinarySensor(

View File

@ -538,11 +538,9 @@ async def async_setup_entry(
ATTR_SETTINGS
]
switches: list[NextDnsSwitch] = []
for description in SWITCHES:
switches.append(NextDnsSwitch(coordinator, description))
async_add_entities(switches)
async_add_entities(
NextDnsSwitch(coordinator, description) for description in SWITCHES
)
class NextDnsSwitch(CoordinatorEntity[NextDnsSettingsUpdateCoordinator], SwitchEntity):

View File

@ -44,15 +44,11 @@ async def async_setup_entry(
regions: dict[str, str] = config_entry.data[CONF_REGIONS]
message_slots: int = config_entry.data[CONF_MESSAGE_SLOTS]
entities: list[NINAMessage] = []
for ent in coordinator.data:
for i in range(0, message_slots):
entities.append(
NINAMessage(coordinator, ent, regions[ent], i + 1, config_entry)
)
async_add_entities(entities)
async_add_entities(
NINAMessage(coordinator, ent, regions[ent], i + 1, config_entry)
for ent in coordinator.data
for i in range(0, message_slots)
)
class NINAMessage(CoordinatorEntity[NINADataUpdateCoordinator], BinarySensorEntity):

View File

@ -24,16 +24,16 @@ async def async_setup_entry(
requester: ObihaiConnection = hass.data[DOMAIN][entry.entry_id]
sensors = []
for key in requester.services:
sensors.append(ObihaiServiceSensors(requester, key))
sensors = [ObihaiServiceSensors(requester, key) for key in requester.services]
sensors.extend(
ObihaiServiceSensors(requester, key) for key in requester.call_direction
)
if requester.line_services is not None:
for key in requester.line_services:
sensors.append(ObihaiServiceSensors(requester, key))
for key in requester.call_direction:
sensors.append(ObihaiServiceSensors(requester, key))
sensors.extend(
ObihaiServiceSensors(requester, key) for key in requester.line_services
)
async_add_entities(sensors, update_before_add=True)

View File

@ -55,7 +55,7 @@ async def async_setup_entry(
if not coordinator.data["printer"]:
return
new_tools = []
new_tools: list[OctoPrintTemperatureSensor] = []
for tool in [
tool
for tool in coordinator.data["printer"].temperatures
@ -63,15 +63,15 @@ async def async_setup_entry(
]:
assert device_id is not None
known_tools.add(tool.name)
for temp_type in ("actual", "target"):
new_tools.append(
OctoPrintTemperatureSensor(
coordinator,
tool.name,
temp_type,
device_id,
)
new_tools.extend(
OctoPrintTemperatureSensor(
coordinator,
tool.name,
temp_type,
device_id,
)
for temp_type in ("actual", "target")
)
async_add_entities(new_tools)
config_entry.async_on_unload(coordinator.async_add_listener(async_add_tool_sensors))

View File

@ -80,15 +80,12 @@ async def async_setup_platform(
"country": config[CONF_REGION],
}
entities = []
for camera in config[CONF_SOURCE]:
entities.append(
OpenAlprCloudEntity(
camera[CONF_ENTITY_ID], params, confidence, camera.get(CONF_NAME)
)
async_add_entities(
OpenAlprCloudEntity(
camera[CONF_ENTITY_ID], params, confidence, camera.get(CONF_NAME)
)
async_add_entities(entities)
for camera in config[CONF_SOURCE]
)
class ImageProcessingAlprEntity(ImageProcessingEntity):

View File

@ -109,23 +109,20 @@ def setup_platform(
)
return
entities = []
if CONF_CLASSIFIER not in config:
dest_path = hass.config.path(DEFAULT_CLASSIFIER_PATH)
_get_default_classifier(dest_path)
config[CONF_CLASSIFIER] = {"Face": dest_path}
for camera in config[CONF_SOURCE]:
entities.append(
OpenCVImageProcessor(
hass,
camera[CONF_ENTITY_ID],
camera.get(CONF_NAME),
config[CONF_CLASSIFIER],
)
add_entities(
OpenCVImageProcessor(
hass,
camera[CONF_ENTITY_ID],
camera.get(CONF_NAME),
config[CONF_CLASSIFIER],
)
add_entities(entities)
for camera in config[CONF_SOURCE]
)
class OpenCVImageProcessor(ImageProcessingEntity):

View File

@ -28,25 +28,19 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the OpenTherm Gateway binary sensors."""
sensors = []
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][config_entry.data[CONF_ID]]
for var, info in BINARY_SENSOR_INFO.items():
device_class = info[0]
friendly_name_format = info[1]
status_sources = info[2]
for source in status_sources:
sensors.append(
OpenThermBinarySensor(
gw_dev,
var,
source,
device_class,
friendly_name_format,
)
)
async_add_entities(sensors)
async_add_entities(
OpenThermBinarySensor(
gw_dev,
var,
source,
info[0],
info[1],
)
for var, info in BINARY_SENSOR_INFO.items()
for source in info[2]
)
class OpenThermBinarySensor(BinarySensorEntity):

View File

@ -23,29 +23,21 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the OpenTherm Gateway sensors."""
sensors = []
gw_dev = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][config_entry.data[CONF_ID]]
for var, info in SENSOR_INFO.items():
device_class = info[0]
unit = info[1]
friendly_name_format = info[2]
suggested_display_precision = info[3]
status_sources = info[4]
for source in status_sources:
sensors.append(
OpenThermSensor(
gw_dev,
var,
source,
device_class,
unit,
friendly_name_format,
suggested_display_precision,
)
)
async_add_entities(sensors)
async_add_entities(
OpenThermSensor(
gw_dev,
var,
source,
info[0],
info[1],
info[2],
info[3],
)
for var, info in SENSOR_INFO.items()
for source in info[4]
)
class OpenThermSensor(SensorEntity):

View File

@ -187,16 +187,16 @@ async def async_setup_entry(
and forecast.unit_of_measure in [UnitOfMeasure.THERM, UnitOfMeasure.CCF]
):
sensors = GAS_SENSORS
for sensor in sensors:
entities.append(
OpowerSensor(
coordinator,
sensor,
forecast.account.utility_account_id,
device,
device_id,
)
entities.extend(
OpowerSensor(
coordinator,
sensor,
forecast.account.utility_account_id,
device,
device_id,
)
for sensor in sensors
)
async_add_entities(entities)

View File

@ -45,11 +45,9 @@ async def async_setup_entry(
"""Set up OSO Energy heater based on a config entry."""
osoenergy = hass.data[DOMAIN][entry.entry_id]
devices = osoenergy.session.device_list.get("water_heater")
entities = []
if devices:
for dev in devices:
entities.append(OSOEnergyWaterHeater(osoenergy, dev))
async_add_entities(entities, True)
if not devices:
return
async_add_entities((OSOEnergyWaterHeater(osoenergy, dev) for dev in devices), True)
class OSOEnergyWaterHeater(

View File

@ -221,21 +221,19 @@ async def async_setup_entry(
) -> None:
"""Set up the Overkiz alarm control panel from a config entry."""
data: HomeAssistantOverkizData = hass.data[DOMAIN][entry.entry_id]
entities: list[OverkizAlarmControlPanel] = []
for device in data.platforms[Platform.ALARM_CONTROL_PANEL]:
if description := SUPPORTED_DEVICES.get(device.widget) or SUPPORTED_DEVICES.get(
device.ui_class
):
entities.append(
OverkizAlarmControlPanel(
device.device_url,
data.coordinator,
description,
)
)
async_add_entities(entities)
async_add_entities(
OverkizAlarmControlPanel(
device.device_url,
data.coordinator,
description,
)
for device in data.platforms[Platform.ALARM_CONTROL_PANEL]
if (
description := SUPPORTED_DEVICES.get(device.widget)
or SUPPORTED_DEVICES.get(device.ui_class)
)
)
class OverkizAlarmControlPanel(OverkizDescriptiveEntity, AlarmControlPanelEntity):

View File

@ -128,15 +128,15 @@ async def async_setup_entry(
):
continue
for state in device.definition.states:
if description := SUPPORTED_STATES.get(state.qualified_name):
entities.append(
OverkizBinarySensor(
device.device_url,
data.coordinator,
description,
)
)
entities.extend(
OverkizBinarySensor(
device.device_url,
data.coordinator,
description,
)
for state in device.definition.states
if (description := SUPPORTED_STATES.get(state.qualified_name))
)
async_add_entities(entities)

View File

@ -95,15 +95,15 @@ async def async_setup_entry(
):
continue
for command in device.definition.commands:
if description := SUPPORTED_COMMANDS.get(command.command_name):
entities.append(
OverkizButton(
device.device_url,
data.coordinator,
description,
)
)
entities.extend(
OverkizButton(
device.device_url,
data.coordinator,
description,
)
for command in device.definition.commands
if (description := SUPPORTED_COMMANDS.get(command.command_name))
)
async_add_entities(entities)

View File

@ -183,15 +183,15 @@ async def async_setup_entry(
):
continue
for state in device.definition.states:
if description := SUPPORTED_STATES.get(state.qualified_name):
entities.append(
OverkizNumber(
device.device_url,
data.coordinator,
description,
)
)
entities.extend(
OverkizNumber(
device.device_url,
data.coordinator,
description,
)
for state in device.definition.states
if (description := SUPPORTED_STATES.get(state.qualified_name))
)
async_add_entities(entities)

View File

@ -143,15 +143,15 @@ async def async_setup_entry(
):
continue
for state in device.definition.states:
if description := SUPPORTED_STATES.get(state.qualified_name):
entities.append(
OverkizSelect(
device.device_url,
data.coordinator,
description,
)
)
entities.extend(
OverkizSelect(
device.device_url,
data.coordinator,
description,
)
for state in device.definition.states
if (description := SUPPORTED_STATES.get(state.qualified_name))
)
async_add_entities(entities)

View File

@ -459,15 +459,15 @@ async def async_setup_entry(
):
continue
for state in device.definition.states:
if description := SUPPORTED_STATES.get(state.qualified_name):
entities.append(
OverkizStateSensor(
device.device_url,
data.coordinator,
description,
)
)
entities.extend(
OverkizStateSensor(
device.device_url,
data.coordinator,
description,
)
for state in device.definition.states
if (description := SUPPORTED_STATES.get(state.qualified_name))
)
async_add_entities(entities)

View File

@ -116,21 +116,19 @@ async def async_setup_entry(
) -> None:
"""Set up the Overkiz switch from a config entry."""
data: HomeAssistantOverkizData = hass.data[DOMAIN][entry.entry_id]
entities: list[OverkizSwitch] = []
for device in data.platforms[Platform.SWITCH]:
if description := SUPPORTED_DEVICES.get(device.widget) or SUPPORTED_DEVICES.get(
device.ui_class
):
entities.append(
OverkizSwitch(
device.device_url,
data.coordinator,
description,
)
)
async_add_entities(entities)
async_add_entities(
OverkizSwitch(
device.device_url,
data.coordinator,
description,
)
for device in data.platforms[Platform.SWITCH]
if (
description := SUPPORTED_DEVICES.get(device.widget)
or SUPPORTED_DEVICES.get(device.ui_class)
)
)
class OverkizSwitch(OverkizDescriptiveEntity, SwitchEntity):

View File

@ -187,19 +187,17 @@ async def handle_webhook(hass, webhook_id, request):
async_dispatcher_send(hass, DOMAIN, hass, context, message)
response = []
for person in hass.states.async_all("person"):
if "latitude" in person.attributes and "longitude" in person.attributes:
response.append(
{
"_type": "location",
"lat": person.attributes["latitude"],
"lon": person.attributes["longitude"],
"tid": "".join(p[0] for p in person.name.split(" ")[:2]),
"tst": int(person.last_updated.timestamp()),
}
)
response = [
{
"_type": "location",
"lat": person.attributes["latitude"],
"lon": person.attributes["longitude"],
"tid": "".join(p[0] for p in person.name.split(" ")[:2]),
"tst": int(person.last_updated.timestamp()),
}
for person in hass.states.async_all("person")
if "latitude" in person.attributes and "longitude" in person.attributes
]
if message["_type"] == "encrypted" and context.secret:
return json_response(

View File

@ -63,18 +63,18 @@ async def test_get_triggers(
expected_triggers = []
for event_type in event_types:
if event_type in SUBTYPES:
for subtype in SUBTYPES[event_type]:
expected_triggers.append(
{
"platform": "device",
"domain": NETATMO_DOMAIN,
"type": event_type,
"subtype": subtype,
"device_id": device_entry.id,
"entity_id": entity_entry.id,
"metadata": {"secondary": False},
}
)
expected_triggers.extend(
{
"platform": "device",
"domain": NETATMO_DOMAIN,
"type": event_type,
"subtype": subtype,
"device_id": device_entry.id,
"entity_id": entity_entry.id,
"metadata": {"secondary": False},
}
for subtype in SUBTYPES[event_type]
)
else:
expected_triggers.append(
{

View File

@ -102,7 +102,9 @@ def _setup_owproxy_mock_device_reads(
device_sensors = mock_device.get(platform, [])
if platform is Platform.SENSOR and device_id.startswith("12"):
# We need to check if there is TAI8570 plugged in
for expected_sensor in device_sensors:
sub_read_side_effect.append(expected_sensor[ATTR_INJECT_READS])
for expected_sensor in device_sensors:
sub_read_side_effect.append(expected_sensor[ATTR_INJECT_READS])
sub_read_side_effect.extend(
expected_sensor[ATTR_INJECT_READS] for expected_sensor in device_sensors
)
sub_read_side_effect.extend(
expected_sensor[ATTR_INJECT_READS] for expected_sensor in device_sensors
)