Remove useless async_add_executor_job (#44496)
parent
d385a51653
commit
19b957cd84
|
@ -49,19 +49,17 @@ HVAC_MODES_MAPPING = {HvacState.COOL: HVAC_MODE_COOL, HvacState.HEAT: HVAC_MODE_
|
|||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Somfy climate platform."""
|
||||
|
||||
def get_thermostats():
|
||||
"""Retrieve thermostats."""
|
||||
domain_data = hass.data[DOMAIN]
|
||||
coordinator = domain_data[COORDINATOR]
|
||||
api = domain_data[API]
|
||||
domain_data = hass.data[DOMAIN]
|
||||
coordinator = domain_data[COORDINATOR]
|
||||
api = domain_data[API]
|
||||
|
||||
return [
|
||||
SomfyClimate(coordinator, device_id, api)
|
||||
for device_id, device in coordinator.data.items()
|
||||
if SUPPORTED_CATEGORIES & set(device.categories)
|
||||
]
|
||||
climates = [
|
||||
SomfyClimate(coordinator, device_id, api)
|
||||
for device_id, device in coordinator.data.items()
|
||||
if SUPPORTED_CATEGORIES & set(device.categories)
|
||||
]
|
||||
|
||||
async_add_entities(await hass.async_add_executor_job(get_thermostats))
|
||||
async_add_entities(climates)
|
||||
|
||||
|
||||
class SomfyClimate(SomfyEntity, ClimateEntity):
|
||||
|
|
|
@ -36,19 +36,17 @@ SUPPORTED_CATEGORIES = {
|
|||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Somfy cover platform."""
|
||||
|
||||
def get_covers():
|
||||
"""Retrieve covers."""
|
||||
domain_data = hass.data[DOMAIN]
|
||||
coordinator = domain_data[COORDINATOR]
|
||||
api = domain_data[API]
|
||||
domain_data = hass.data[DOMAIN]
|
||||
coordinator = domain_data[COORDINATOR]
|
||||
api = domain_data[API]
|
||||
|
||||
return [
|
||||
SomfyCover(coordinator, device_id, api, domain_data[CONF_OPTIMISTIC])
|
||||
for device_id, device in coordinator.data.items()
|
||||
if SUPPORTED_CATEGORIES & set(device.categories)
|
||||
]
|
||||
covers = [
|
||||
SomfyCover(coordinator, device_id, api, domain_data[CONF_OPTIMISTIC])
|
||||
for device_id, device in coordinator.data.items()
|
||||
if SUPPORTED_CATEGORIES & set(device.categories)
|
||||
]
|
||||
|
||||
async_add_entities(await hass.async_add_executor_job(get_covers))
|
||||
async_add_entities(covers)
|
||||
|
||||
|
||||
class SomfyCover(SomfyEntity, RestoreEntity, CoverEntity):
|
||||
|
|
|
@ -12,21 +12,19 @@ SUPPORTED_CATEGORIES = {Category.HVAC.value}
|
|||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Somfy climate platform."""
|
||||
"""Set up the Somfy sensor platform."""
|
||||
|
||||
def get_thermostats():
|
||||
"""Retrieve thermostats."""
|
||||
domain_data = hass.data[DOMAIN]
|
||||
coordinator = domain_data[COORDINATOR]
|
||||
api = domain_data[API]
|
||||
domain_data = hass.data[DOMAIN]
|
||||
coordinator = domain_data[COORDINATOR]
|
||||
api = domain_data[API]
|
||||
|
||||
return [
|
||||
SomfyThermostatBatterySensor(coordinator, device_id, api)
|
||||
for device_id, device in coordinator.data.items()
|
||||
if SUPPORTED_CATEGORIES & set(device.categories)
|
||||
]
|
||||
sensors = [
|
||||
SomfyThermostatBatterySensor(coordinator, device_id, api)
|
||||
for device_id, device in coordinator.data.items()
|
||||
if SUPPORTED_CATEGORIES & set(device.categories)
|
||||
]
|
||||
|
||||
async_add_entities(await hass.async_add_executor_job(get_thermostats))
|
||||
async_add_entities(sensors)
|
||||
|
||||
|
||||
class SomfyThermostatBatterySensor(SomfyEntity):
|
||||
|
|
|
@ -11,19 +11,17 @@ from .const import API, COORDINATOR, DOMAIN
|
|||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the Somfy switch platform."""
|
||||
|
||||
def get_shutters():
|
||||
"""Retrieve switches."""
|
||||
domain_data = hass.data[DOMAIN]
|
||||
coordinator = domain_data[COORDINATOR]
|
||||
api = domain_data[API]
|
||||
domain_data = hass.data[DOMAIN]
|
||||
coordinator = domain_data[COORDINATOR]
|
||||
api = domain_data[API]
|
||||
|
||||
return [
|
||||
SomfyCameraShutter(coordinator, device_id, api)
|
||||
for device_id, device in coordinator.data.items()
|
||||
if Category.CAMERA.value in device.categories
|
||||
]
|
||||
switches = [
|
||||
SomfyCameraShutter(coordinator, device_id, api)
|
||||
for device_id, device in coordinator.data.items()
|
||||
if Category.CAMERA.value in device.categories
|
||||
]
|
||||
|
||||
async_add_entities(await hass.async_add_executor_job(get_shutters), True)
|
||||
async_add_entities(switches)
|
||||
|
||||
|
||||
class SomfyCameraShutter(SomfyEntity, SwitchEntity):
|
||||
|
|
Loading…
Reference in New Issue