Skip to content

Commit

Permalink
Move and rename envisalink base entity to separate module (#126054)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Sep 16, 2024
1 parent 5a769fb commit 21b9245
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 39 deletions.
18 changes: 0 additions & 18 deletions homeassistant/components/envisalink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
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__)
Expand Down Expand Up @@ -244,20 +243,3 @@ async def handle_custom_function(call: ServiceCall) -> None:
)

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
4 changes: 2 additions & 2 deletions homeassistant/components/envisalink/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
PARTITION_SCHEMA,
SIGNAL_KEYPAD_UPDATE,
SIGNAL_PARTITION_UPDATE,
EnvisalinkDevice,
)
from .entity import EnvisalinkEntity

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -102,7 +102,7 @@ def async_alarm_keypress_handler(service: ServiceCall) -> None:
)


class EnvisalinkAlarm(EnvisalinkDevice, AlarmControlPanelEntity):
class EnvisalinkAlarm(EnvisalinkEntity, AlarmControlPanelEntity):
"""Representation of an Envisalink-based alarm panel."""

_attr_supported_features = (
Expand Down
12 changes: 3 additions & 9 deletions homeassistant/components/envisalink/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@
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__)

Expand Down Expand Up @@ -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):
Expand Down
20 changes: 20 additions & 0 deletions homeassistant/components/envisalink/entity.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions homeassistant/components/envisalink/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
PARTITION_SCHEMA,
SIGNAL_KEYPAD_UPDATE,
SIGNAL_PARTITION_UPDATE,
EnvisalinkDevice,
)
from .entity import EnvisalinkEntity

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -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):
Expand Down
11 changes: 3 additions & 8 deletions homeassistant/components/envisalink/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@
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__)

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 21b9245

Please sign in to comment.