mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use shorthand attributes in Wolflink (#99921)
This commit is contained in:
parent
5ddaf52b27
commit
5f6f2c2cab
@ -57,14 +57,10 @@ class WolfLinkSensor(CoordinatorEntity, SensorEntity):
|
|||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self.wolf_object = wolf_object
|
self.wolf_object = wolf_object
|
||||||
self.device_id = device_id
|
self._attr_name = wolf_object.name
|
||||||
|
self._attr_unique_id = f"{device_id}:{wolf_object.parameter_id}"
|
||||||
self._state = None
|
self._state = None
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name."""
|
|
||||||
return f"{self.wolf_object.name}"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
"""Return the state. Wolf Client is returning only changed values so we need to store old value here."""
|
"""Return the state. Wolf Client is returning only changed values so we need to store old value here."""
|
||||||
@ -83,52 +79,26 @@ class WolfLinkSensor(CoordinatorEntity, SensorEntity):
|
|||||||
"parent": self.wolf_object.parent,
|
"parent": self.wolf_object.parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self):
|
|
||||||
"""Return a unique_id for this entity."""
|
|
||||||
return f"{self.device_id}:{self.wolf_object.parameter_id}"
|
|
||||||
|
|
||||||
|
|
||||||
class WolfLinkHours(WolfLinkSensor):
|
class WolfLinkHours(WolfLinkSensor):
|
||||||
"""Class for hour based entities."""
|
"""Class for hour based entities."""
|
||||||
|
|
||||||
@property
|
_attr_icon = "mdi:clock"
|
||||||
def icon(self):
|
_attr_native_unit_of_measurement = UnitOfTime.HOURS
|
||||||
"""Icon to display in the front Aend."""
|
|
||||||
return "mdi:clock"
|
|
||||||
|
|
||||||
@property
|
|
||||||
def native_unit_of_measurement(self):
|
|
||||||
"""Return the unit the value is expressed in."""
|
|
||||||
return UnitOfTime.HOURS
|
|
||||||
|
|
||||||
|
|
||||||
class WolfLinkTemperature(WolfLinkSensor):
|
class WolfLinkTemperature(WolfLinkSensor):
|
||||||
"""Class for temperature based entities."""
|
"""Class for temperature based entities."""
|
||||||
|
|
||||||
@property
|
_attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||||
def device_class(self):
|
_attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS
|
||||||
"""Return the device_class."""
|
|
||||||
return SensorDeviceClass.TEMPERATURE
|
|
||||||
|
|
||||||
@property
|
|
||||||
def native_unit_of_measurement(self):
|
|
||||||
"""Return the unit the value is expressed in."""
|
|
||||||
return UnitOfTemperature.CELSIUS
|
|
||||||
|
|
||||||
|
|
||||||
class WolfLinkPressure(WolfLinkSensor):
|
class WolfLinkPressure(WolfLinkSensor):
|
||||||
"""Class for pressure based entities."""
|
"""Class for pressure based entities."""
|
||||||
|
|
||||||
@property
|
_attr_device_class = SensorDeviceClass.PRESSURE
|
||||||
def device_class(self):
|
_attr_native_unit_of_measurement = UnitOfPressure.BAR
|
||||||
"""Return the device_class."""
|
|
||||||
return SensorDeviceClass.PRESSURE
|
|
||||||
|
|
||||||
@property
|
|
||||||
def native_unit_of_measurement(self):
|
|
||||||
"""Return the unit the value is expressed in."""
|
|
||||||
return UnitOfPressure.BAR
|
|
||||||
|
|
||||||
|
|
||||||
class WolfLinkPercentage(WolfLinkSensor):
|
class WolfLinkPercentage(WolfLinkSensor):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user