diff --git a/README.md b/README.md index 89fd65a..ece1e70 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A dashboard tab for Octoprint that displays the most relevant info regarding the * RPi iost CPU Load, CPU Temp, Mem Utilization, Storage Utilization. * Printer profile, Connection status, Printer Status * Hotend temp(s), Bed Temp, Chamber Temp, Fan speed - * Printed file, Progress + * Printed file, Job Progress, Layer Progress * Layer Duration Graph * Estimated total time, ETA, Time left, Time since print started * Current layer, Total layers diff --git a/octoprint_dashboard/__init__.py b/octoprint_dashboard/__init__.py index fa1b994..4398917 100644 --- a/octoprint_dashboard/__init__.py +++ b/octoprint_dashboard/__init__.py @@ -4,6 +4,7 @@ from octoprint.util import RepeatedTimer import re import psutil +import Adafruit_DHT from octoprint.events import Events, eventManager @@ -24,6 +25,23 @@ class DashboardPlugin(octoprint.plugin.SettingsPlugin, layer_times = [] layer_labels = [] + ambient_humidity = 0 + ambient_temperature = 0 + dht_sensor_pin = 0 + dht_sensor_type = None + + def adafruitDhtGetStats(self): + 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 temp_sum = 0 @@ -38,13 +56,18 @@ def psUtilGetStats(self): self.virtual_memory_percent = str(psutil.virtual_memory().percent) self.disk_usage = str(psutil.disk_usage("/").percent) + # ~~ StartupPlugin mixin def on_after_startup(self): self._logger.info("Dashboard started") self.timer = RepeatedTimer(3.0, self.send_notifications, run_first=True) self.timer.start() + #Read settings + self.dht_sensor_pin = self._settings.get(["dhtSensorPin"]) + self.dht_sensor_type = self._settings.get(["dhtSensorType"]) def send_notifications(self): self.psUtilGetStats() + self.adafruitDhtGetStats() self._plugin_manager.send_plugin_message(self._identifier, dict(cpuPercent=str(self.cpu_percent), virtualMemPercent=str(self.virtual_memory_percent), diskUsagePercent=str(self.disk_usage), @@ -52,7 +75,9 @@ def send_notifications(self): extrudedFilament=str( round( (sum(self.extruded_filament_arr) + self.extruded_filament) / 1000, 2) ), layerTimes=str(self.layer_times), layerLabels=str(self.layer_labels), - printerMessage =str(self.printer_message))) + printerMessage =str(self.printer_message), + ambientHumidity = str(self.ambient_humidity), + ambientTemperature = str(self.ambient_temperature))) def on_event(self, event, payload): if event == "DisplayLayerProgress_layerChanged" or event == "DisplayLayerProgress_fanspeedChanged": @@ -103,9 +128,18 @@ def get_settings_defaults(self): showFullscreen=True, showFilament=True, showLayerGraph=False, - showPrinterMessage=False + showPrinterMessage=False, + showSensorInfo=False, + dhtSensorPin=4, + dhtSensorType=None ) + def on_settings_save(self, data): + octoprint.plugin.SettingsPlugin.on_settings_save(self, data) + self.dht_sensor_pin = self._settings.get(["dhtSensorPin"]) + self.dht_sensor_type = self._settings.get(["dhtSensorType"]) + + def get_template_configs(self): return [ dict(dict(type="tab", custom_bindings=False), type="settings", custom_bindings=False) ] diff --git a/octoprint_dashboard/static/css/dashboard.css b/octoprint_dashboard/static/css/dashboard.css index d2a0b63..bdf4fef 100644 --- a/octoprint_dashboard/static/css/dashboard.css +++ b/octoprint_dashboard/static/css/dashboard.css @@ -77,6 +77,7 @@ svg path { will-change: auto; stroke-width: 20px; stroke-miterlimit: round; + shape-rendering: auto; transition: stroke-dashoffset 500ms ease-in-out; } diff --git a/octoprint_dashboard/static/img/ambient-sensor-icon.png b/octoprint_dashboard/static/img/ambient-sensor-icon.png new file mode 100644 index 0000000..d896ee1 Binary files /dev/null and b/octoprint_dashboard/static/img/ambient-sensor-icon.png differ diff --git a/octoprint_dashboard/static/js/dashboard.js b/octoprint_dashboard/static/js/dashboard.js index 67d6cd0..9b3f192 100644 --- a/octoprint_dashboard/static/js/dashboard.js +++ b/octoprint_dashboard/static/js/dashboard.js @@ -30,18 +30,19 @@ $(function () { self.lastLayerDuration = ko.observable("-"); self.averageLayerDuration = ko.observable("-"); + //Dashboard backend vars self.getEta = ko.observable(); self.embedUrl = ko.observable(""); self.extrudedFilament = ko.observable(0.00); self.layerProgressString = ko.observable(0); self.layerProgressBarString = ko.observable("0%"); self.printerMessage = ko.observable(""); - - //Dashboard backend vars self.cpuPercent = ko.observable(0); self.virtualMemPercent = ko.observable(0); self.diskUsagePercent = ko.observable(0); self.cpuTemp = ko.observable(0); + self.ambientTemperature = ko.observable(0); + self.ambientHumidity = ko.observable(0); //Fullscreen self.urlParams = new URLSearchParams(window.location.search); @@ -260,6 +261,8 @@ $(function () { if (data.cpuTemp) { self.cpuTemp(data.cpuTemp); } if (data.printerMessage) { self.printerMessage(data.printerMessage); } if (data.extrudedFilament) { self.extrudedFilament(data.extrudedFilament); } + if (data.ambientTemperature) { self.ambientTemperature(data.ambientTemperature); } + if (data.ambientHumidity) { self.ambientHumidity(data.ambientHumidity); } if (data.layerTimes && data.layerLabels) { self.renderChart(data.layerTimes, data.layerLabels); } } }; diff --git a/octoprint_dashboard/templates/dashboard_settings.jinja2 b/octoprint_dashboard/templates/dashboard_settings.jinja2 index a8e4b31..7374ccb 100644 --- a/octoprint_dashboard/templates/dashboard_settings.jinja2 +++ b/octoprint_dashboard/templates/dashboard_settings.jinja2 @@ -50,6 +50,11 @@ +
+ +
+ + Note! This is an experimental feature to support temperature/humidity sensors connected via RPi GPIO pins. + + +
+ +
+ +
+ +
diff --git a/octoprint_dashboard/templates/dashboard_tab.jinja2 b/octoprint_dashboard/templates/dashboard_tab.jinja2 index 31cc4f4..7d17d43 100644 --- a/octoprint_dashboard/templates/dashboard_tab.jinja2 +++ b/octoprint_dashboard/templates/dashboard_tab.jinja2 @@ -10,8 +10,7 @@
- +
@@ -23,6 +22,18 @@
+
+ +
+ + +
+
+
+
+
+
+
@@ -108,9 +119,6 @@ Job
- -       -
diff --git a/setup.py b/setup.py index 52ca626..ce3417a 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,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.9.0" +plugin_version = "1.10.0" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module @@ -33,7 +33,7 @@ plugin_license = "AGPLv3" # Any additional requirements besides OctoPrint should be listed here -plugin_requires = ["psutil"] +plugin_requires = ["psutil", "Adafruit_DHT"] ### -------------------------------------------------------------------------------------------------------------------- ### More advanced options that you usually shouldn't have to touch follow after this point