diff --git a/octoprint_enclosure/__init__.py b/octoprint_enclosure/__init__.py index 8116e81..5d4af89 100644 --- a/octoprint_enclosure/__init__.py +++ b/octoprint_enclosure/__init__.py @@ -150,7 +150,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, octoprint.plugin.TemplateP self.print_complete = False def get_settings_version(self): - return 8 + return 9 def on_settings_migrate(self, target, current=None): self._logger.warn("######### current settings version %s target settings version %s #########", current, target) @@ -158,9 +158,10 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, octoprint.plugin.TemplateP self._logger.info("rpi_outputs: %s", self.rpi_outputs) self._logger.info("rpi_inputs: %s", self.rpi_inputs) self._logger.info("######### End Current Settings #########") - if current >= 4 and target == 8: - self._logger.warn("######### migrating settings to v8 #########") + if current >= 4 and target == 9: + self._logger.warn("######### migrating settings to v9 #########") old_outputs = self._settings.get(["rpi_outputs"]) + old_inputs = self._settings.get(["rpi_inputs"]) for rpi_output in old_outputs: if 'shutdown_on_failed' not in rpi_output: rpi_output['shutdown_on_failed'] = False @@ -190,6 +191,10 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, octoprint.plugin.TemplateP rpi_input['temp_i2c_address'] = 1 if 'temp_i2c_register' not in rpi_input: rpi_input['temp_i2c_register'] = 1 + if 'show_graph_temp' not in rpi_input: + rpi_input['show_graph_temp'] = False + if 'show_graph_humidity' not in rpi_input: + rpi_input['show_graph_humidity'] = False self._settings.set(["rpi_inputs"], old_inputs) else: self._logger.warn("######### settings not compatible #########") @@ -2118,6 +2123,15 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, octoprint.plugin.TemplateP comm_instance._log("Setting TEMP/HUM control output %s to value %s" % (index_id, set_value)) return + def get_graph_data(self, comm, parsed_temps): + for sensor in list(filter(lambda item: item['input_type'] == 'temperature_sensor', self.rpi_inputs)): + if sensor["show_graph_temp"]: + parsed_temps[str(sensor["label"])] = (sensor['temp_sensor_temp'], None) + if sensor["show_graph_humidity"]: + parsed_temps[str(sensor["label"])+" Humidity"] = (sensor['temp_sensor_humidity'], None) + + return parsed_temps + __plugin_name__ = "Enclosure Plugin" __plugin_pythoncompat__ = ">=2.7,<4" @@ -2130,5 +2144,6 @@ def __plugin_load__(): global __plugin_hooks__ __plugin_hooks__ = { "octoprint.comm.protocol.gcode.queuing" : __plugin_implementation__.hook_gcode_queuing, - "octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information + "octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information, + "octoprint.comm.protocol.temperatures.received": (__plugin_implementation__.get_graph_data, 1) } diff --git a/octoprint_enclosure/static/js/enclosure.js b/octoprint_enclosure/static/js/enclosure.js index 048b45e..fe98a78 100644 --- a/octoprint_enclosure/static/js/enclosure.js +++ b/octoprint_enclosure/static/js/enclosure.js @@ -466,7 +466,9 @@ $(function () { temp_sensor_i2cbus: ko.observable(1), temp_i2c_bus: ko.observable(1), temp_i2c_address: ko.observable(1), - temp_i2c_register: ko.observable(1) + temp_i2c_register: ko.observable(1), + show_graph_temp: ko.observable(false), + show_graph_humidity: ko.observable(false) }); }; diff --git a/octoprint_enclosure/templates/enclosure_settings.jinja2 b/octoprint_enclosure/templates/enclosure_settings.jinja2 index 01ddaed..fa6c294 100644 --- a/octoprint_enclosure/templates/enclosure_settings.jinja2 +++ b/octoprint_enclosure/templates/enclosure_settings.jinja2 @@ -859,6 +859,24 @@ Enable and disable temperature on navbar +
+ + Enable to show temperature in temperature graph, when a printer is connected. + +

Note:This feature currently requires a custom graph plugin like PlotlyTempGraph

+ +
+
+ + Enable to show humidity in temperature graph, when a printer is connected. + +

Note:This feature currently requires a custom graph plugin like PlotlyTempGraph

+ +