* Move temperature conversions to entity base class (1/8) * Update integrations a-c * Leave old temperature conversion until all integrations are migrated * tweak * Use contextlib.suppress * Remove the MeasurableUnitEntity mixin * Address comments, add tests * Fix f-string * Drop deprecation warning from base entity class * Update with _attr-shorthand * Fix rebase mistakes * Fix additional rebase mistakes * Only report temperature conversion once * Fix additional rebase mistakes * Format homeassistant/components/bbox/sensor.py * Fix check for overidden _attr_state * Remove test workarounds from implementation * Remove useless None-check * Tweaks * Migrate new sensors a-c * Update climacell * Push deprecation of temperature conversion forward * Override __repr__ in SensorEntity * Include native_value in SensorEntity attributes * Pylint * Black * Black * Fix rebase mistakes * black * Fix rebase mistakes * Revert changes in august/sensor.py * Revert handling of unit converted restored state * Apply code review suggestion * Fix arlo test
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
"""Support for AlarmDecoder sensors (Shows Panel Display)."""
|
|
from homeassistant.components.sensor import SensorEntity
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
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()
|
|
async_add_entities([entity])
|
|
return True
|
|
|
|
|
|
class AlarmDecoderSensor(SensorEntity):
|
|
"""Representation of an AlarmDecoder keypad."""
|
|
|
|
_attr_icon = "mdi:alarm-check"
|
|
_attr_name = "Alarm Panel Display"
|
|
_attr_should_poll = False
|
|
|
|
async def async_added_to_hass(self):
|
|
"""Register callbacks."""
|
|
self.async_on_remove(
|
|
self.hass.helpers.dispatcher.async_dispatcher_connect(
|
|
SIGNAL_PANEL_MESSAGE, self._message_callback
|
|
)
|
|
)
|
|
|
|
def _message_callback(self, message):
|
|
if self._attr_native_value != message.text:
|
|
self._attr_native_value = message.text
|
|
self.schedule_update_ha_state()
|