mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Move xs1 base entity to separate module (#126199)
This commit is contained in:
parent
8827b5510f
commit
dd77c6b59f
@ -1,6 +1,5 @@
|
|||||||
"""Support for the EZcontrol XS1 gateway."""
|
"""Support for the EZcontrol XS1 gateway."""
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -17,7 +16,6 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -44,11 +42,6 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
|
|
||||||
PLATFORMS = [Platform.CLIMATE, Platform.SENSOR, Platform.SWITCH]
|
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:
|
def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up XS1 integration."""
|
"""Set up XS1 integration."""
|
||||||
@ -88,16 +81,3 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
discovery.load_platform(hass, platform, DOMAIN, {}, config)
|
discovery.load_platform(hass, platform, DOMAIN, {}, config)
|
||||||
|
|
||||||
return True
|
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)
|
|
||||||
|
@ -16,7 +16,8 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
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
|
MIN_TEMP = 8
|
||||||
MAX_TEMP = 25
|
MAX_TEMP = 25
|
||||||
|
23
homeassistant/components/xs1/entity.py
Normal file
23
homeassistant/components/xs1/entity.py
Normal file
@ -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)
|
@ -9,7 +9,8 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
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(
|
def setup_platform(
|
||||||
|
@ -11,7 +11,8 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
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(
|
def setup_platform(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user