Add dsmr_reader telegram timestamp and device classes (#42909)
* Added Telegram timestamp * added to 'dsmr/reading/timestamp' and 'dsmr/consumption/gas/read_at' * Fixed import sorting * Replaced 'kW' with ENERGY_KILO_WATT_HOUR * Added device_class, changed unit_of_measurement with fallback on device_class * Fixed typo * Fixed 'black' coding format * Removed fallback, added unit_of_measurement and CURRENCY_EURO as device_class * Fixed newline * Removed 'timestamp' unit_of_meassure * Removed icons from defintions with device_class * Updated device_classes * Updated device_classes * Updated device_classes * Added 'entity_registry_enabled_default' properties * Added 'entity_registry_enabled_default' properties, fixed typo * MQTT discovery will be in another pull-request
This commit is contained in:
parent
61475cf090
commit
149ba088d4
2 changed files with 106 additions and 34 deletions
|
@ -31,6 +31,8 @@ class DSMRSensor(Entity):
|
|||
self._topic = topic
|
||||
|
||||
self._name = self._definition.get("name", topic.split("/")[-1])
|
||||
self._device_class = self._definition.get("device_class")
|
||||
self._enable_default = self._definition.get("enable_default")
|
||||
self._unit_of_measurement = self._definition.get("unit")
|
||||
self._icon = self._definition.get("icon")
|
||||
self._transform = self._definition.get("transform")
|
||||
|
@ -67,11 +69,21 @@ class DSMRSensor(Entity):
|
|||
"""Return the current state of the entity."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the device_class of this sensor."""
|
||||
return self._device_class
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit_of_measurement of this sensor."""
|
||||
return self._unit_of_measurement
|
||||
|
||||
@property
|
||||
def entity_registry_enabled_default(self) -> bool:
|
||||
"""Return if the entity should be enabled when first added to the entity registry."""
|
||||
return self._enable_default
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon of this sensor."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue