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):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up the Somfy climate platform."""
|
"""Set up the Somfy climate platform."""
|
||||||
|
|
||||||
def get_thermostats():
|
domain_data = hass.data[DOMAIN]
|
||||||
"""Retrieve thermostats."""
|
coordinator = domain_data[COORDINATOR]
|
||||||
domain_data = hass.data[DOMAIN]
|
api = domain_data[API]
|
||||||
coordinator = domain_data[COORDINATOR]
|
|
||||||
api = domain_data[API]
|
|
||||||
|
|
||||||
return [
|
climates = [
|
||||||
SomfyClimate(coordinator, device_id, api)
|
SomfyClimate(coordinator, device_id, api)
|
||||||
for device_id, device in coordinator.data.items()
|
for device_id, device in coordinator.data.items()
|
||||||
if SUPPORTED_CATEGORIES & set(device.categories)
|
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):
|
class SomfyClimate(SomfyEntity, ClimateEntity):
|
||||||
|
|
|
@ -36,19 +36,17 @@ SUPPORTED_CATEGORIES = {
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up the Somfy cover platform."""
|
"""Set up the Somfy cover platform."""
|
||||||
|
|
||||||
def get_covers():
|
domain_data = hass.data[DOMAIN]
|
||||||
"""Retrieve covers."""
|
coordinator = domain_data[COORDINATOR]
|
||||||
domain_data = hass.data[DOMAIN]
|
api = domain_data[API]
|
||||||
coordinator = domain_data[COORDINATOR]
|
|
||||||
api = domain_data[API]
|
|
||||||
|
|
||||||
return [
|
covers = [
|
||||||
SomfyCover(coordinator, device_id, api, domain_data[CONF_OPTIMISTIC])
|
SomfyCover(coordinator, device_id, api, domain_data[CONF_OPTIMISTIC])
|
||||||
for device_id, device in coordinator.data.items()
|
for device_id, device in coordinator.data.items()
|
||||||
if SUPPORTED_CATEGORIES & set(device.categories)
|
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):
|
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):
|
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():
|
domain_data = hass.data[DOMAIN]
|
||||||
"""Retrieve thermostats."""
|
coordinator = domain_data[COORDINATOR]
|
||||||
domain_data = hass.data[DOMAIN]
|
api = domain_data[API]
|
||||||
coordinator = domain_data[COORDINATOR]
|
|
||||||
api = domain_data[API]
|
|
||||||
|
|
||||||
return [
|
sensors = [
|
||||||
SomfyThermostatBatterySensor(coordinator, device_id, api)
|
SomfyThermostatBatterySensor(coordinator, device_id, api)
|
||||||
for device_id, device in coordinator.data.items()
|
for device_id, device in coordinator.data.items()
|
||||||
if SUPPORTED_CATEGORIES & set(device.categories)
|
if SUPPORTED_CATEGORIES & set(device.categories)
|
||||||
]
|
]
|
||||||
|
|
||||||
async_add_entities(await hass.async_add_executor_job(get_thermostats))
|
async_add_entities(sensors)
|
||||||
|
|
||||||
|
|
||||||
class SomfyThermostatBatterySensor(SomfyEntity):
|
class SomfyThermostatBatterySensor(SomfyEntity):
|
||||||
|
|
|
@ -11,19 +11,17 @@ from .const import API, COORDINATOR, DOMAIN
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up the Somfy switch platform."""
|
"""Set up the Somfy switch platform."""
|
||||||
|
|
||||||
def get_shutters():
|
domain_data = hass.data[DOMAIN]
|
||||||
"""Retrieve switches."""
|
coordinator = domain_data[COORDINATOR]
|
||||||
domain_data = hass.data[DOMAIN]
|
api = domain_data[API]
|
||||||
coordinator = domain_data[COORDINATOR]
|
|
||||||
api = domain_data[API]
|
|
||||||
|
|
||||||
return [
|
switches = [
|
||||||
SomfyCameraShutter(coordinator, device_id, api)
|
SomfyCameraShutter(coordinator, device_id, api)
|
||||||
for device_id, device in coordinator.data.items()
|
for device_id, device in coordinator.data.items()
|
||||||
if Category.CAMERA.value in device.categories
|
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):
|
class SomfyCameraShutter(SomfyEntity, SwitchEntity):
|
||||||
|
|
Loading…
Reference in New Issue