Add AlarmDecoder device info (#117357)

* Update AlarmDecoder component to newer model

This commit makes AlarmDecoder operate as a proper device entity following the new model introduced a few years ago.

Code also has an internal dependency on a newer version of adext (>= 0.4.3) which has been updated correspondingly.

* Created AlarmDecoder entity

Added an alarmdecoder entity so the device_info can be re-used across the integration

* Move _attr_has_entity_name to base entity

As per code review suggestion, clean up the object model.

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Missed one suggestion with the prior commit

Moves _attr_has_entity_name to base entity

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Address some ruff issues

* Apply additional ruff cleanups

Ran ruff again to clean up a few files tat weren't picked up last time

* Apply suggestions from code review

Some additional cleanup of style & removal of unnecessary code

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Properly generated the integration file

generation had to happen twice for this to work.  Now that it's generated, I'm including the missing update.

* Apply suggestions from code review

Use local client variable instead of self._client

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>

* Sort the manifest

documentation was added, but it wasn't sorted properly in the key/value pairs

* Add alarmdecoder entity file to coverage ignore file

Added the alarmdecoder entity file so it is ignored for coverage

---------

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
Christopher Tremblay
2024-05-17 23:59:44 -07:00
committed by GitHub
parent 2b195cab72
commit b015dbfccb
8 changed files with 57 additions and 8 deletions

View File

@@ -6,7 +6,8 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import SIGNAL_PANEL_MESSAGE
from .const import DATA_AD, DOMAIN, SIGNAL_PANEL_MESSAGE
from .entity import AlarmDecoderEntity
async def async_setup_entry(
@@ -14,17 +15,23 @@ async def async_setup_entry(
) -> None:
"""Set up for AlarmDecoder sensor."""
entity = AlarmDecoderSensor()
client = hass.data[DOMAIN][entry.entry_id][DATA_AD]
entity = AlarmDecoderSensor(client=client)
async_add_entities([entity])
class AlarmDecoderSensor(SensorEntity):
class AlarmDecoderSensor(AlarmDecoderEntity, SensorEntity):
"""Representation of an AlarmDecoder keypad."""
_attr_translation_key = "alarm_panel_display"
_attr_name = "Alarm Panel Display"
_attr_should_poll = False
def __init__(self, client):
"""Initialize the alarm decoder sensor."""
super().__init__(client)
self._attr_unique_id = f"{client.serial_number}-display"
async def async_added_to_hass(self) -> None:
"""Register callbacks."""
self.async_on_remove(