Consolidating async_add_entities into one call in Ecobee (#129917)

* Consolidating async_add_entities into one call.

* changing to comprehension.
This commit is contained in:
Nicholas Romyn 2024-11-06 02:25:18 -05:00 committed by GitHub
parent 184cbfea23
commit 2eb2bdd615
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,8 +31,7 @@ async def async_setup_entry(
"""Set up the ecobee thermostat switch entity.""" """Set up the ecobee thermostat switch entity."""
data: EcobeeData = hass.data[DOMAIN] data: EcobeeData = hass.data[DOMAIN]
async_add_entities( entities: list[SwitchEntity] = [
[
EcobeeVentilator20MinSwitch( EcobeeVentilator20MinSwitch(
data, data,
index, index,
@ -41,15 +40,17 @@ async def async_setup_entry(
) )
for index, thermostat in enumerate(data.ecobee.thermostats) for index, thermostat in enumerate(data.ecobee.thermostats)
if thermostat["settings"]["ventilatorType"] != "none" if thermostat["settings"]["ventilatorType"] != "none"
], ]
update_before_add=True,
)
async_add_entities( entities.extend(
(
EcobeeSwitchAuxHeatOnly(data, index) EcobeeSwitchAuxHeatOnly(data, index)
for index, thermostat in enumerate(data.ecobee.thermostats) for index, thermostat in enumerate(data.ecobee.thermostats)
if thermostat["settings"]["hasHeatPump"] if thermostat["settings"]["hasHeatPump"]
) )
)
async_add_entities(entities, update_before_add=True)
class EcobeeVentilator20MinSwitch(EcobeeBaseEntity, SwitchEntity): class EcobeeVentilator20MinSwitch(EcobeeBaseEntity, SwitchEntity):