mirror of
https://github.com/home-assistant/core.git
synced 2025-08-01 11:45:09 +02:00
Convert null to 0 for temp % sensors (#2710)
This commit is contained in:
committed by
Paulus Schoutsen
parent
bb22ad3064
commit
b8492832a6
@@ -95,6 +95,9 @@ class OctoPrintSensor(Entity):
|
||||
"""Return the state of the sensor."""
|
||||
sensor_unit = self.unit_of_measurement
|
||||
if sensor_unit == TEMP_CELSIUS or sensor_unit == "%":
|
||||
# API sometimes returns null and not 0
|
||||
if self._state is None:
|
||||
self._state = 0
|
||||
return round(self._state, 2)
|
||||
else:
|
||||
return self._state
|
||||
|
Reference in New Issue
Block a user