diff --git a/octoprint_dashboard/__init__.py b/octoprint_dashboard/__init__.py index 29fb6dc..fd9f9b5 100644 --- a/octoprint_dashboard/__init__.py +++ b/octoprint_dashboard/__init__.py @@ -6,9 +6,18 @@ import psutil import sys import os -if sys.platform.startswith("linux"): - if os.uname()[1].startswith("octopi"): - import Adafruit_DHT + +try: #Check to see if we are on an RPI or not + import RPi.GPIO as gpio + on_rpi = True +except (ImportError, RuntimeError): + on_rpi = False + +if on_rpi == True: + import Adafruit_DHT + + + from octoprint.events import Events, eventManager @@ -35,18 +44,17 @@ class DashboardPlugin(octoprint.plugin.SettingsPlugin, dht_sensor_type = None def adafruitDhtGetStats(self): - if sys.platform.startswith("linux"): - if os.uname()[1].startswith("octopi"): - if self.dht_sensor_type == "DHT11": - sensor = Adafruit_DHT.DHT11 - elif self.dht_sensor_type == "DHT22": - sensor = Adafruit_DHT.DHT22 - else: return - pin = self.dht_sensor_pin - try: - self.ambient_humidity, self.ambient_temperature = Adafruit_DHT.read_retry(sensor, pin) - except RuntimeError as e: - print("Reading from DHT failure: ", e.args) + if on_rpi == True: #This will only work on an actual RPi + if self.dht_sensor_type == "DHT11": + sensor = Adafruit_DHT.DHT11 + elif self.dht_sensor_type == "DHT22": + sensor = Adafruit_DHT.DHT22 + else: return + pin = self.dht_sensor_pin + try: + self.ambient_humidity, self.ambient_temperature = Adafruit_DHT.read_retry(sensor, pin) + except RuntimeError as e: + print("Reading from DHT failure: ", e.args) def psUtilGetStats(self): #temp_average = 0 @@ -106,7 +114,6 @@ def on_event(self, event, payload): averageLayerDurationInSeconds=payload.get('averageLayerDurationInSeconds'))) if event == "PrintStarted": - self._logger.info("Print Started: " + payload.get("name", "")) del self.layer_times[:] del self.layer_labels[:] self. extruded_filament = 0.0 @@ -183,7 +190,6 @@ def process_gcode(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwa elif gcode == "M117": if not cmd.startswith("M117 INDICATOR-Layer"): self.printer_message = cmd.strip("M117 ") - self._logger.info("*********** Message: " + self.printer_message) else: return elif gcode in ("M82", "G90"): diff --git a/octoprint_dashboard/templates/dashboard_tab.jinja2 b/octoprint_dashboard/templates/dashboard_tab.jinja2 index 7d17d43..4383351 100644 --- a/octoprint_dashboard/templates/dashboard_tab.jinja2 +++ b/octoprint_dashboard/templates/dashboard_tab.jinja2 @@ -119,6 +119,7 @@ Job +    
diff --git a/setup.py b/setup.py index 83f706b..b2edde6 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ plugin_name = "OctoPrint-Dashboard" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "1.10.0" +plugin_version = "1.10.1" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module @@ -35,13 +35,19 @@ plugin_license = "AGPLv3" # Any additional requirements besides OctoPrint should be listed here -if sys.platform.startswith("linux"): - if os.uname()[1].startswith("octopi"): - plugin_requires = ["psutil", "Adafruit_DHT"] - else: - plugin_requires = ["psutil"] -else: - plugin_requires = ["psutil"] +#if sys.platform.startswith("linux"): +# if os.uname()[1].startswith("octopi"): +# plugin_requires = ["psutil", "Adafruit_DHT"] +# else: +# plugin_requires = ["psutil"] +#else: +# plugin_requires = ["psutil"] + +try: + import RPi.GPIO as gpio + plugin_requires = ["psutil", "Adafruit_DHT"] #RPi.GPIO loads, so we should be on an RPi and can load Adafruit_DHT +except (ImportError, RuntimeError): + plugin_requires = ["psutil"] #We're on some other platform. ### -------------------------------------------------------------------------------------------------------------------- ### More advanced options that you usually shouldn't have to touch follow after this point