Clean up alarmdecoder (#52517)
* Clean up alarmdecoder * fix * try again * tweak
This commit is contained in:
parent
07bda0973e
commit
6e779855f7
5 changed files with 65 additions and 153 deletions
|
@ -8,7 +8,7 @@ from .const import SIGNAL_PANEL_MESSAGE
|
|||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
|
||||
):
|
||||
) -> bool:
|
||||
"""Set up for AlarmDecoder sensor."""
|
||||
|
||||
entity = AlarmDecoderSensor()
|
||||
|
@ -19,12 +19,9 @@ async def async_setup_entry(
|
|||
class AlarmDecoderSensor(SensorEntity):
|
||||
"""Representation of an AlarmDecoder keypad."""
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize the alarm panel."""
|
||||
self._display = ""
|
||||
self._state = None
|
||||
self._icon = "mdi:alarm-check"
|
||||
self._name = "Alarm Panel Display"
|
||||
_attr_icon = "mdi:alarm-check"
|
||||
_attr_name = "Alarm Panel Display"
|
||||
_attr_should_poll = False
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register callbacks."""
|
||||
|
@ -35,26 +32,6 @@ class AlarmDecoderSensor(SensorEntity):
|
|||
)
|
||||
|
||||
def _message_callback(self, message):
|
||||
if self._display != message.text:
|
||||
self._display = message.text
|
||||
if self._attr_state != message.text:
|
||||
self._attr_state = message.text
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon if any."""
|
||||
return self._icon
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the overall state."""
|
||||
return self._display
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the device."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue