Move and rename envisalink base entity to separate module (#126054)

This commit is contained in:
epenet 2024-09-16 15:20:53 +02:00 committed by GitHub
parent 5a769fb51b
commit 21b92455af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 30 additions and 39 deletions

View file

@ -17,7 +17,6 @@ from homeassistant.core import HomeAssistant, ServiceCall, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.discovery import async_load_platform
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__)
@ -244,20 +243,3 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
)
return True
class EnvisalinkDevice(Entity):
"""Representation of an Envisalink device."""
_attr_should_poll = False
def __init__(self, name, info, controller):
"""Initialize the device."""
self._controller = controller
self._info = info
self._name = name
@property
def name(self):
"""Return the name of the device."""
return self._name

View file

@ -37,8 +37,8 @@ from . import (
PARTITION_SCHEMA,
SIGNAL_KEYPAD_UPDATE,
SIGNAL_PARTITION_UPDATE,
EnvisalinkDevice,
)
from .entity import EnvisalinkEntity
_LOGGER = logging.getLogger(__name__)
@ -102,7 +102,7 @@ async def async_setup_platform(
)
class EnvisalinkAlarm(EnvisalinkDevice, AlarmControlPanelEntity):
class EnvisalinkAlarm(EnvisalinkEntity, AlarmControlPanelEntity):
"""Representation of an Envisalink-based alarm panel."""
_attr_supported_features = (

View file

@ -13,14 +13,8 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.util import dt as dt_util
from . import (
CONF_ZONENAME,
CONF_ZONETYPE,
DATA_EVL,
SIGNAL_ZONE_UPDATE,
ZONE_SCHEMA,
EnvisalinkDevice,
)
from . import CONF_ZONENAME, CONF_ZONETYPE, DATA_EVL, SIGNAL_ZONE_UPDATE, ZONE_SCHEMA
from .entity import EnvisalinkEntity
_LOGGER = logging.getLogger(__name__)
@ -52,7 +46,7 @@ async def async_setup_platform(
async_add_entities(entities)
class EnvisalinkBinarySensor(EnvisalinkDevice, BinarySensorEntity):
class EnvisalinkBinarySensor(EnvisalinkEntity, BinarySensorEntity):
"""Representation of an Envisalink binary sensor."""
def __init__(self, hass, zone_number, zone_name, zone_type, info, controller):

View file

@ -0,0 +1,20 @@
"""Support for Envisalink devices."""
from homeassistant.helpers.entity import Entity
class EnvisalinkEntity(Entity):
"""Representation of an Envisalink device."""
_attr_should_poll = False
def __init__(self, name, info, controller):
"""Initialize the device."""
self._controller = controller
self._info = info
self._name = name
@property
def name(self):
"""Return the name of the device."""
return self._name

View file

@ -16,8 +16,8 @@ from . import (
PARTITION_SCHEMA,
SIGNAL_KEYPAD_UPDATE,
SIGNAL_PARTITION_UPDATE,
EnvisalinkDevice,
)
from .entity import EnvisalinkEntity
_LOGGER = logging.getLogger(__name__)
@ -49,7 +49,7 @@ async def async_setup_platform(
async_add_entities(entities)
class EnvisalinkSensor(EnvisalinkDevice, SensorEntity):
class EnvisalinkSensor(EnvisalinkEntity, SensorEntity):
"""Representation of an Envisalink keypad."""
def __init__(self, hass, partition_name, partition_number, info, controller):

View file

@ -11,13 +11,8 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import (
CONF_ZONENAME,
DATA_EVL,
SIGNAL_ZONE_BYPASS_UPDATE,
ZONE_SCHEMA,
EnvisalinkDevice,
)
from . import CONF_ZONENAME, DATA_EVL, SIGNAL_ZONE_BYPASS_UPDATE, ZONE_SCHEMA
from .entity import EnvisalinkEntity
_LOGGER = logging.getLogger(__name__)
@ -51,7 +46,7 @@ async def async_setup_platform(
async_add_entities(entities)
class EnvisalinkSwitch(EnvisalinkDevice, SwitchEntity):
class EnvisalinkSwitch(EnvisalinkEntity, SwitchEntity):
"""Representation of an Envisalink switch."""
def __init__(self, hass, zone_number, zone_name, info, controller):