Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions homeassistant/components/iaqualink/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,25 @@ def name(self) -> str:
return self.dev.label

@property
def unit_of_measurement(self) -> str:
def unit_of_measurement(self) -> Optional[str]:
"""Return the measurement unit for the sensor."""
if self.dev.system.temp_unit == "F":
return TEMP_FAHRENHEIT
return TEMP_CELSIUS
if self.dev.name.endswith("_temp"):
if self.dev.system.temp_unit == "F":
return TEMP_FAHRENHEIT
return TEMP_CELSIUS
return None

Comment thread
flz marked this conversation as resolved.
@property
def state(self) -> str:
def state(self) -> Optional[str]:
"""Return the state of the sensor."""
return int(self.dev.state) if self.dev.state != "" else None
if self.dev.state == "":
return None

try:
state = int(self.dev.state)
except ValueError:
state = float(self.dev.state)
return state

@property
def device_class(self) -> Optional[str]:
Comment thread
flz marked this conversation as resolved.
Expand Down