diff --git a/homeassistant/components/xs1/__init__.py b/homeassistant/components/xs1/__init__.py index e24fbc0181e..6f7197817d7 100644 --- a/homeassistant/components/xs1/__init__.py +++ b/homeassistant/components/xs1/__init__.py @@ -1,6 +1,5 @@ """Support for the EZcontrol XS1 gateway.""" -import asyncio import logging import voluptuous as vol @@ -17,7 +16,6 @@ from homeassistant.const import ( from homeassistant.core import HomeAssistant from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity from homeassistant.helpers.typing import ConfigType _LOGGER = logging.getLogger(__name__) @@ -44,11 +42,6 @@ CONFIG_SCHEMA = vol.Schema( PLATFORMS = [Platform.CLIMATE, Platform.SENSOR, Platform.SWITCH] -# Lock used to limit the amount of concurrent update requests -# as the XS1 Gateway can only handle a very -# small amount of concurrent requests -UPDATE_LOCK = asyncio.Lock() - def setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up XS1 integration.""" @@ -88,16 +81,3 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool: discovery.load_platform(hass, platform, DOMAIN, {}, config) return True - - -class XS1DeviceEntity(Entity): - """Representation of a base XS1 device.""" - - def __init__(self, device): - """Initialize the XS1 device.""" - self.device = device - - async def async_update(self): - """Retrieve latest device state.""" - async with UPDATE_LOCK: - await self.hass.async_add_executor_job(self.device.update) diff --git a/homeassistant/components/xs1/climate.py b/homeassistant/components/xs1/climate.py index e594f32adff..c7d580631d3 100644 --- a/homeassistant/components/xs1/climate.py +++ b/homeassistant/components/xs1/climate.py @@ -16,7 +16,8 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -from . import ACTUATORS, DOMAIN as COMPONENT_DOMAIN, SENSORS, XS1DeviceEntity +from . import ACTUATORS, DOMAIN as COMPONENT_DOMAIN, SENSORS +from .entity import XS1DeviceEntity MIN_TEMP = 8 MAX_TEMP = 25 diff --git a/homeassistant/components/xs1/entity.py b/homeassistant/components/xs1/entity.py new file mode 100644 index 00000000000..7239a6fd446 --- /dev/null +++ b/homeassistant/components/xs1/entity.py @@ -0,0 +1,23 @@ +"""Support for the EZcontrol XS1 gateway.""" + +import asyncio + +from homeassistant.helpers.entity import Entity + +# Lock used to limit the amount of concurrent update requests +# as the XS1 Gateway can only handle a very +# small amount of concurrent requests +UPDATE_LOCK = asyncio.Lock() + + +class XS1DeviceEntity(Entity): + """Representation of a base XS1 device.""" + + def __init__(self, device): + """Initialize the XS1 device.""" + self.device = device + + async def async_update(self): + """Retrieve latest device state.""" + async with UPDATE_LOCK: + await self.hass.async_add_executor_job(self.device.update) diff --git a/homeassistant/components/xs1/sensor.py b/homeassistant/components/xs1/sensor.py index e98fd33743b..b3895d67d82 100644 --- a/homeassistant/components/xs1/sensor.py +++ b/homeassistant/components/xs1/sensor.py @@ -9,7 +9,8 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -from . import ACTUATORS, DOMAIN as COMPONENT_DOMAIN, SENSORS, XS1DeviceEntity +from . import ACTUATORS, DOMAIN as COMPONENT_DOMAIN, SENSORS +from .entity import XS1DeviceEntity def setup_platform( diff --git a/homeassistant/components/xs1/switch.py b/homeassistant/components/xs1/switch.py index c2af652d6ad..a8f66390a6d 100644 --- a/homeassistant/components/xs1/switch.py +++ b/homeassistant/components/xs1/switch.py @@ -11,7 +11,8 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -from . import ACTUATORS, DOMAIN as COMPONENT_DOMAIN, XS1DeviceEntity +from . import ACTUATORS, DOMAIN as COMPONENT_DOMAIN +from .entity import XS1DeviceEntity def setup_platform(