From 19b957cd84e0666af8981604f408f770fd214d48 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Thu, 24 Dec 2020 20:42:56 +0100 Subject: [PATCH] Remove useless async_add_executor_job (#44496) --- homeassistant/components/somfy/climate.py | 20 +++++++++----------- homeassistant/components/somfy/cover.py | 20 +++++++++----------- homeassistant/components/somfy/sensor.py | 22 ++++++++++------------ homeassistant/components/somfy/switch.py | 20 +++++++++----------- 4 files changed, 37 insertions(+), 45 deletions(-) diff --git a/homeassistant/components/somfy/climate.py b/homeassistant/components/somfy/climate.py index c4abc12d240..00a2738f4fe 100644 --- a/homeassistant/components/somfy/climate.py +++ b/homeassistant/components/somfy/climate.py @@ -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): diff --git a/homeassistant/components/somfy/cover.py b/homeassistant/components/somfy/cover.py index 4542506bec5..e7308558127 100644 --- a/homeassistant/components/somfy/cover.py +++ b/homeassistant/components/somfy/cover.py @@ -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): diff --git a/homeassistant/components/somfy/sensor.py b/homeassistant/components/somfy/sensor.py index 3d7b1b8fc13..1becc929adc 100644 --- a/homeassistant/components/somfy/sensor.py +++ b/homeassistant/components/somfy/sensor.py @@ -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): diff --git a/homeassistant/components/somfy/switch.py b/homeassistant/components/somfy/switch.py index d614776778e..14328953367 100644 --- a/homeassistant/components/somfy/switch.py +++ b/homeassistant/components/somfy/switch.py @@ -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):