From b8492832a6dcdabb7e3d83489ece7f3064e5d25a Mon Sep 17 00:00:00 2001 From: William Scanlon Date: Wed, 3 Aug 2016 00:53:26 -0400 Subject: [PATCH] Convert null to 0 for temp % sensors (#2710) --- homeassistant/components/sensor/octoprint.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/sensor/octoprint.py b/homeassistant/components/sensor/octoprint.py index 4bf543f3831..f7e7fa30817 100644 --- a/homeassistant/components/sensor/octoprint.py +++ b/homeassistant/components/sensor/octoprint.py @@ -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