mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Change more properties to attributes for rfxtrx (#74880)
* Move more properties to attributes * Apply suggestions from code review Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> * Convert states to attributes * Adjustments from review Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
@@ -273,15 +273,16 @@ async def async_setup_entry(
|
||||
class RfxtrxSensor(RfxtrxEntity, SensorEntity):
|
||||
"""Representation of a RFXtrx sensor."""
|
||||
|
||||
_attr_force_update = True
|
||||
"""We should force updates. Repeated states have meaning."""
|
||||
|
||||
entity_description: RfxtrxSensorEntityDescription
|
||||
|
||||
def __init__(self, device, device_id, entity_description, event=None):
|
||||
"""Initialize the sensor."""
|
||||
super().__init__(device, device_id, event=event)
|
||||
self.entity_description = entity_description
|
||||
self._unique_id = "_".join(
|
||||
x for x in (*self._device_id, entity_description.key)
|
||||
)
|
||||
self._attr_unique_id = "_".join(x for x in (*device_id, entity_description.key))
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Restore device state."""
|
||||
@@ -302,16 +303,6 @@ class RfxtrxSensor(RfxtrxEntity, SensorEntity):
|
||||
value = self._event.values.get(self.entity_description.key)
|
||||
return self.entity_description.convert(value)
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def force_update(self) -> bool:
|
||||
"""We should force updates. Repeated states have meaning."""
|
||||
return True
|
||||
|
||||
@callback
|
||||
def _handle_event(self, event, device_id):
|
||||
"""Check if event applies to me and update."""
|
||||
|
||||
Reference in New Issue
Block a user