From 0d807bc5bb78d3389bc1527df3a8db8381eebdbd Mon Sep 17 00:00:00 2001 From: cristianku Date: Mon, 19 Aug 2019 17:44:25 +0200 Subject: [PATCH] implemented bme680 with air quality --- 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 f8c444c..f4f2584 100644 --- a/octoprint_enclosure/__init__.py +++ b/octoprint_enclosure/__init__.py @@ -505,7 +505,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, octoprint.plugin.TemplateP elif sensor['temp_sensor_type'] == "bme280": temp, hum = self.read_bme280_temp(sensor['temp_sensor_address']) elif sensor['temp_sensor_type'] == "bme680": - temp, hum = self.read_bme680_temp(sensor['temp_sensor_address']) + temp, hum, airquality = self.read_bme680_temp(sensor['temp_sensor_address']) elif sensor['temp_sensor_type'] == "si7021": temp, hum = self.read_si7021_temp(sensor['temp_sensor_address']) elif sensor['temp_sensor_type'] == "tmp102": @@ -613,14 +613,15 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, octoprint.plugin.TemplateP stdout = (Popen(cmd, shell=True, stdout=PIPE).stdout).read() if self._settings.get(["debug_temperature_log"]) is True: self._logger.debug("BME680 result: %s", stdout) - temp, hum = stdout.split("|") - return (self.to_float(temp.strip()), self.to_float(hum.strip())) + temp, hum, airq = stdout.split("|") + return (self.to_float(temp.strip()), self.to_float(hum.strip()), self.to_float(airq.strip())) except Exception as ex: self._logger.info( "Failed to execute python scripts, try disabling use SUDO on advanced section of the plugin.") self.log_error(ex) return (0, 0) - + + def read_si7021_temp(self, address): try: script = os.path.dirname(os.path.realpath(__file__)) + "/SI7021.py " @@ -1579,4 +1580,4 @@ def __plugin_load__(): __plugin_hooks__ = { "octoprint.comm.protocol.gcode.queuing" : __plugin_implementation__.hook_gcode_queuing, "octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information - } \ No newline at end of file + }