#8 Relais ein / ausschalten von Ocotprint aus
This commit is contained in:
		| @@ -62,8 +62,9 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin, | ||||
|             try: | ||||
|                 request = requests.get( | ||||
|                     'http://{}/report'.format(self.ip), timeout=1) | ||||
|                 self._plugin_manager.send_plugin_message(self._identifier, | ||||
|                                                          request.json()) | ||||
|                 data = request.json() | ||||
|                 data["onOffButtonEnabled"] = self.onOffButtonEnabled | ||||
|                 self._plugin_manager.send_plugin_message(self._identifier, data) | ||||
|             except (requests.exceptions.ConnectionError, ValueError): | ||||
|                 self._logger.info('Connection Error Host: {}'.format(self.ip)) | ||||
|         else: | ||||
|   | ||||
| @@ -6,7 +6,7 @@ $(function() { | ||||
|         self.settings = parameters[1]; | ||||
|         self.printer = parameters[2]; | ||||
|  | ||||
|         self.mystromswitchEnabled = ko.observable(); | ||||
|         self.onOffButtonEnabled = ko.observable(); | ||||
|         self.mystromswitchPowerValue = document.getElementById("mystromswitchPowerValue") | ||||
|  | ||||
|         self.onToggleRelayEvent = function(){ | ||||
| @@ -22,7 +22,7 @@ $(function() { | ||||
|         } | ||||
|  | ||||
|         self.onmystromswitchEvent = function() { | ||||
|             if (self.mystromswitchEnabled()) { | ||||
|             if (self.onOffButtonEnabled()) { | ||||
|                 $.ajax({ | ||||
|                     url: API_BASEURL + "plugin/mystromswitch", | ||||
|                     type: "POST", | ||||
| @@ -45,13 +45,13 @@ $(function() { | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         self.mystromswitchEnabled.subscribe(self.onmystromswitchEvent, self); | ||||
|         self.onOffButtonEnabled.subscribe(self.onmystromswitchEvent, self); | ||||
|  | ||||
|         self.onDataUpdaterPluginMessage = function(plugin, data) { | ||||
|             if (plugin != "mystromswitch" && plugin != "octoprint_mystromswitch") { | ||||
|                 return; | ||||
|             } | ||||
| 			self.mystromswitchEnabled(data.mystromswitchEnabled); | ||||
| 			self.onOffButtonEnabled(data.onOffButtonEnabled); | ||||
| 			if(data.relay == false){ | ||||
| 			    self.mystromswitchPowerValue.innerHTML = "Relay is off"; | ||||
| 			} else if (data.power != null) { | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| <div class="sidebar_plugin_mystromswitch"> | ||||
|     <label class="control-label" id="mystromswitchPowerValue">Powerconsumption 0.0W</label> | ||||
|     <button class="btn btn-primary" data-bind="click: onToggleRelayEvent, visible : settings.plugins.mystromswitch.onOffButtonEnabled">{{ _('Toggle Relais') }}</button> | ||||
|     <button class="btn btn-primary" data-bind="click: onToggleRelayEvent, visible : onOffButtonEnabled">{{ _('Toggle Relais') }}</button> | ||||
| </div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user