mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-06 18:54:08 +00:00
Add unit_getter for feature (#993)
Allow defining getter for unit, necessary to set the correct unit based on device responses.
This commit is contained in:
@@ -28,6 +28,7 @@ class TemperatureSensor(SmartModule):
|
||||
attribute_getter="temperature",
|
||||
icon="mdi:thermometer",
|
||||
category=Feature.Category.Primary,
|
||||
unit_getter="temperature_unit",
|
||||
)
|
||||
)
|
||||
if "current_temp_exception" in device.sys_info:
|
||||
@@ -55,7 +56,6 @@ class TemperatureSensor(SmartModule):
|
||||
choices=["celsius", "fahrenheit"],
|
||||
)
|
||||
)
|
||||
# TODO: use temperature_unit for feature creation
|
||||
|
||||
@property
|
||||
def temperature(self):
|
||||
@@ -68,7 +68,7 @@ class TemperatureSensor(SmartModule):
|
||||
return self._device.sys_info.get("current_temp_exception", 0) != 0
|
||||
|
||||
@property
|
||||
def temperature_unit(self):
|
||||
def temperature_unit(self) -> Literal["celsius", "fahrenheit"]:
|
||||
"""Return current temperature unit."""
|
||||
return self._device.sys_info["temp_unit"]
|
||||
|
||||
|
Reference in New Issue
Block a user