diff --git a/homeassistant/components/envisalink/__init__.py b/homeassistant/components/envisalink/__init__.py index 8222c044503..0146b650c22 100644 --- a/homeassistant/components/envisalink/__init__.py +++ b/homeassistant/components/envisalink/__init__.py @@ -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 diff --git a/homeassistant/components/envisalink/alarm_control_panel.py b/homeassistant/components/envisalink/alarm_control_panel.py index ea8b6390178..4ad9a927d9c 100644 --- a/homeassistant/components/envisalink/alarm_control_panel.py +++ b/homeassistant/components/envisalink/alarm_control_panel.py @@ -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 = ( diff --git a/homeassistant/components/envisalink/binary_sensor.py b/homeassistant/components/envisalink/binary_sensor.py index 9c0909539bb..6c4e2b528e9 100644 --- a/homeassistant/components/envisalink/binary_sensor.py +++ b/homeassistant/components/envisalink/binary_sensor.py @@ -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): diff --git a/homeassistant/components/envisalink/entity.py b/homeassistant/components/envisalink/entity.py new file mode 100644 index 00000000000..a686ed2e3cb --- /dev/null +++ b/homeassistant/components/envisalink/entity.py @@ -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 diff --git a/homeassistant/components/envisalink/sensor.py b/homeassistant/components/envisalink/sensor.py index fcafc23dd37..70d471a685c 100644 --- a/homeassistant/components/envisalink/sensor.py +++ b/homeassistant/components/envisalink/sensor.py @@ -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): diff --git a/homeassistant/components/envisalink/switch.py b/homeassistant/components/envisalink/switch.py index 36ad3d5bf81..e4f37bf328d 100644 --- a/homeassistant/components/envisalink/switch.py +++ b/homeassistant/components/envisalink/switch.py @@ -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):