From ad775fef2a035fe5beda7ec69ee7f3b55e3fe9af Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Wed, 7 Mar 2018 13:59:11 -0600 Subject: [PATCH] fix for dht when not possible to read temperature --- octoprint_enclosure/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/octoprint_enclosure/__init__.py b/octoprint_enclosure/__init__.py index c12cadc..00ad043 100644 --- a/octoprint_enclosure/__init__.py +++ b/octoprint_enclosure/__init__.py @@ -316,8 +316,9 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, if self._settings.get(["debug"]) is True and self._settings.get(["debug_temperature_log"]) is True: self._logger.info( "Sensor %s Temperature: %s humidity %s", sensor['label'], temp, hum) - sensor_data.append( - dict(index_id=sensor['index_id'], temperature=temp, humidity=hum)) + if temp is not None and hum is not None: + sensor_data.append( + dict(index_id=sensor['index_id'], temperature=temp, humidity=hum)) self.temperature_sensor_data = sensor_data self.handle_temp_hum_control() self.handle_temperature_events() @@ -493,14 +494,14 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, hum = 0 else: self._logger.info("temp_sensor_type no match") - temp = 0 - hum = 0 + temp = None + hum = None if temp != -1 and hum != -1: temp = round(self.to_float( temp), 1) if not sensor['use_fahrenheit'] else round(self.to_float(temp) * 1.8 + 32, 1) hum = round(self.to_float(hum), 1) return temp, hum - return 0, 0 + return None, None except Exception as ex: self.log_error(ex)