commit
d92daf48f4
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7 (venv)" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Uninitialized environment" project-jdk-type="Python SDK" />
|
||||
<component name="PyCharmProfessionalAdvertiser">
|
||||
<option name="shown" value="true" />
|
||||
</component>
|
||||
|
349
.idea/workspace.xml
generated
349
.idea/workspace.xml
generated
@ -3,7 +3,7 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="7e2e0eec-b22e-4d48-8f24-196d1ed9b51a" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/setup.py" beforeDir="false" afterPath="$PROJECT_DIR$/setup.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2" afterDir="false" />
|
||||
</list>
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -12,12 +12,12 @@
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$" value="master" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectId" id="1TqgYXT1S9U5eM0eUvs1YarA1ll" />
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||
@ -48,174 +48,6 @@
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1574193087583</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00012" summary="#6 UI Updates senden und anzeigen">
|
||||
<created>1574281255732</created>
|
||||
<option name="number" value="00012" />
|
||||
<option name="presentableId" value="LOCAL-00012" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574281255732</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00013" summary="#6 UI Updates senden und anzeigen">
|
||||
<created>1574281522356</created>
|
||||
<option name="number" value="00013" />
|
||||
<option name="presentableId" value="LOCAL-00013" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574281522356</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00014" summary="#6 UI Updates senden und anzeigen">
|
||||
<created>1574281964923</created>
|
||||
<option name="number" value="00014" />
|
||||
<option name="presentableId" value="LOCAL-00014" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574281964923</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00015" summary="#6 UI Updates senden und anzeigen">
|
||||
<created>1574282183896</created>
|
||||
<option name="number" value="00015" />
|
||||
<option name="presentableId" value="LOCAL-00015" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574282183896</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00016" summary="#6 UI Updates senden und anzeigen">
|
||||
<created>1574282504648</created>
|
||||
<option name="number" value="00016" />
|
||||
<option name="presentableId" value="LOCAL-00016" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574282504648</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00017" summary="#6 UI Updates senden und anzeigen">
|
||||
<created>1574282834574</created>
|
||||
<option name="number" value="00017" />
|
||||
<option name="presentableId" value="LOCAL-00017" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574282834574</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00018" summary="#6 UI Updates senden und anzeigen">
|
||||
<created>1574283002922</created>
|
||||
<option name="number" value="00018" />
|
||||
<option name="presentableId" value="LOCAL-00018" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574283002922</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00019" summary="#6 UI Updates senden und anzeigen">
|
||||
<created>1574283107060</created>
|
||||
<option name="number" value="00019" />
|
||||
<option name="presentableId" value="LOCAL-00019" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574283107060</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00020" summary="#6 UI Updates senden und anzeigen">
|
||||
<created>1574283263948</created>
|
||||
<option name="number" value="00020" />
|
||||
<option name="presentableId" value="LOCAL-00020" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574283263948</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00021" summary="#6 UI Updates senden und anzeigen">
|
||||
<created>1574283721587</created>
|
||||
<option name="number" value="00021" />
|
||||
<option name="presentableId" value="LOCAL-00021" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574283721587</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00022" summary="#6 UI Updates senden und anzeigen">
|
||||
<created>1574284067356</created>
|
||||
<option name="number" value="00022" />
|
||||
<option name="presentableId" value="LOCAL-00022" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574284067356</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00023" summary="#6 UI Updates senden und anzeigen">
|
||||
<created>1574284365024</created>
|
||||
<option name="number" value="00023" />
|
||||
<option name="presentableId" value="LOCAL-00023" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574284365024</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00024" summary="#6 UI Updates senden und anzeigen">
|
||||
<created>1574284478325</created>
|
||||
<option name="number" value="00024" />
|
||||
<option name="presentableId" value="LOCAL-00024" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574284478325</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00025" summary="#6 UI Updates senden und anzeigen logs entfernt">
|
||||
<created>1574284617102</created>
|
||||
<option name="number" value="00025" />
|
||||
<option name="presentableId" value="LOCAL-00025" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574284617102</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00026" summary="#8 Relais ein / ausschalten von Ocotprint aus - Toggle Button anzeigen und Events eingebaut - Api funktionen für Relais ein / aus und toggle implementiert">
|
||||
<created>1574604851601</created>
|
||||
<option name="number" value="00026" />
|
||||
<option name="presentableId" value="LOCAL-00026" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574604851601</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00027" summary="#8 Relais ein / ausschalten von Ocotprint aus - Button Style auf default geändert - get_api_commands implementiert">
|
||||
<created>1574605785309</created>
|
||||
<option name="number" value="00027" />
|
||||
<option name="presentableId" value="LOCAL-00027" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574605785309</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00028" summary="#8 Relais ein / ausschalten von Ocotprint aus - url korrigiert">
|
||||
<created>1574606064523</created>
|
||||
<option name="number" value="00028" />
|
||||
<option name="presentableId" value="LOCAL-00028" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574606064523</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00029" summary="#8 Relais ein / ausschalten von Ocotprint aus">
|
||||
<created>1574606292074</created>
|
||||
<option name="number" value="00029" />
|
||||
<option name="presentableId" value="LOCAL-00029" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574606292074</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00030" summary="#8 Relais ein / ausschalten von Ocotprint aus - url korrigiert">
|
||||
<created>1574606712347</created>
|
||||
<option name="number" value="00030" />
|
||||
<option name="presentableId" value="LOCAL-00030" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574606712347</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00031" summary="#8 Relais ein / ausschalten von Ocotprint aus - Toggle Button enable / disable in Einstellunge - Databinding von Button">
|
||||
<created>1574607577396</created>
|
||||
<option name="number" value="00031" />
|
||||
<option name="presentableId" value="LOCAL-00031" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574607577396</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00032" summary="#8 Relais ein / ausschalten von Ocotprint aus">
|
||||
<created>1574607723126</created>
|
||||
<option name="number" value="00032" />
|
||||
<option name="presentableId" value="LOCAL-00032" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574607723126</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00033" summary="#8 Relais ein / ausschalten von Ocotprint aus">
|
||||
<created>1574608168544</created>
|
||||
<option name="number" value="00033" />
|
||||
<option name="presentableId" value="LOCAL-00033" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574608168544</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00034" summary="#8 Relais ein / ausschalten von Ocotprint aus">
|
||||
<created>1574608700412</created>
|
||||
<option name="number" value="00034" />
|
||||
<option name="presentableId" value="LOCAL-00034" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574608700412</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00035" summary="#8 Relais ein / ausschalten von Ocotprint aus">
|
||||
<created>1574609194050</created>
|
||||
<option name="number" value="00035" />
|
||||
<option name="presentableId" value="LOCAL-00035" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574609194050</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00036" summary="#8 Relais ein / ausschalten von Ocotprint aus">
|
||||
<created>1574609901438</created>
|
||||
<option name="number" value="00036" />
|
||||
@ -391,7 +223,175 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1579192359403</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="61" />
|
||||
<task id="LOCAL-00061" summary="#21 Add PowerOFF when print is finished neue Einstellmöglichkeiten anzeigen">
|
||||
<created>1582988883875</created>
|
||||
<option name="number" value="00061" />
|
||||
<option name="presentableId" value="LOCAL-00061" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1582988883875</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00062" summary="#22 Button taucht nicht auf Fehler anzeigen wenn Verbindung zu switch nicht klappt">
|
||||
<created>1582990110412</created>
|
||||
<option name="number" value="00062" />
|
||||
<option name="presentableId" value="LOCAL-00062" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1582990110412</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00063" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1582990799626</created>
|
||||
<option name="number" value="00063" />
|
||||
<option name="presentableId" value="LOCAL-00063" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1582990799626</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00064" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1582991033421</created>
|
||||
<option name="number" value="00064" />
|
||||
<option name="presentableId" value="LOCAL-00064" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1582991033421</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00065" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1582991352868</created>
|
||||
<option name="number" value="00065" />
|
||||
<option name="presentableId" value="LOCAL-00065" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1582991352868</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00066" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1582991720560</created>
|
||||
<option name="number" value="00066" />
|
||||
<option name="presentableId" value="LOCAL-00066" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1582991720560</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00067" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1582992279872</created>
|
||||
<option name="number" value="00067" />
|
||||
<option name="presentableId" value="LOCAL-00067" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1582992279872</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00068" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1582992989361</created>
|
||||
<option name="number" value="00068" />
|
||||
<option name="presentableId" value="LOCAL-00068" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1582992989361</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00069" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1582993317859</created>
|
||||
<option name="number" value="00069" />
|
||||
<option name="presentableId" value="LOCAL-00069" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1582993317859</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00070" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593346830444</created>
|
||||
<option name="number" value="00070" />
|
||||
<option name="presentableId" value="LOCAL-00070" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593346830445</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00071" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593346998123</created>
|
||||
<option name="number" value="00071" />
|
||||
<option name="presentableId" value="LOCAL-00071" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593346998123</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00072" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593347175159</created>
|
||||
<option name="number" value="00072" />
|
||||
<option name="presentableId" value="LOCAL-00072" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593347175159</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00073" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593347774339</created>
|
||||
<option name="number" value="00073" />
|
||||
<option name="presentableId" value="LOCAL-00073" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593347774339</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00074" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593347857755</created>
|
||||
<option name="number" value="00074" />
|
||||
<option name="presentableId" value="LOCAL-00074" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593347857755</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00075" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593347943336</created>
|
||||
<option name="number" value="00075" />
|
||||
<option name="presentableId" value="LOCAL-00075" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593347943336</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00076" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593348030528</created>
|
||||
<option name="number" value="00076" />
|
||||
<option name="presentableId" value="LOCAL-00076" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593348030528</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00077" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593348512259</created>
|
||||
<option name="number" value="00077" />
|
||||
<option name="presentableId" value="LOCAL-00077" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593348512259</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00078" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593348977898</created>
|
||||
<option name="number" value="00078" />
|
||||
<option name="presentableId" value="LOCAL-00078" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593348977898</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00079" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593350619006</created>
|
||||
<option name="number" value="00079" />
|
||||
<option name="presentableId" value="LOCAL-00079" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593350619006</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00080" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593352569980</created>
|
||||
<option name="number" value="00080" />
|
||||
<option name="presentableId" value="LOCAL-00080" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593352569980</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00081" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593352709926</created>
|
||||
<option name="number" value="00081" />
|
||||
<option name="presentableId" value="LOCAL-00081" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593352709926</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00082" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593353565224</created>
|
||||
<option name="number" value="00082" />
|
||||
<option name="presentableId" value="LOCAL-00082" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593353565224</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00083" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593354627917</created>
|
||||
<option name="number" value="00083" />
|
||||
<option name="presentableId" value="LOCAL-00083" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593354627917</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00084" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593354891881</created>
|
||||
<option name="number" value="00084" />
|
||||
<option name="presentableId" value="LOCAL-00084" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593354891881</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="85" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="UnknownFeatures">
|
||||
@ -421,8 +421,6 @@
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="#2 Einstellungen für IP Adresse von Switch #3 Einstellung für Abfrageintervall" />
|
||||
<MESSAGE value="#5 Rest Api integration" />
|
||||
<MESSAGE value="#5 Rest Api integration - Bugfix plugin_requires" />
|
||||
<MESSAGE value="#5 Rest Api integration - Nullpointer fix" />
|
||||
<MESSAGE value="#6 UI Updates senden und anzeigen - unnötigen Code entfernen, erster Versuch" />
|
||||
@ -445,6 +443,9 @@
|
||||
<MESSAGE value="#16 Codereview Octoprint Plugin Repo" />
|
||||
<MESSAGE value="#17 Logging zur Fehleranalyse eingebaut" />
|
||||
<MESSAGE value="#17 Logs aufgeräumt" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="#17 Logs aufgeräumt" />
|
||||
<MESSAGE value="#21 Add PowerOFF when print is finished neue Einstellmöglichkeiten anzeigen" />
|
||||
<MESSAGE value="#22 Button taucht nicht auf Fehler anzeigen wenn Verbindung zu switch nicht klappt" />
|
||||
<MESSAGE value="#21 Add PowerOFF when print is finished" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="#21 Add PowerOFF when print is finished" />
|
||||
</component>
|
||||
</project>
|
@ -1,11 +1,11 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
|
||||
import ssl
|
||||
import time
|
||||
|
||||
import octoprint.plugin
|
||||
import requests
|
||||
import ssl
|
||||
import time
|
||||
from octoprint.events import eventManager, Events
|
||||
from octoprint.util import RepeatedTimer
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
octoprint.plugin.AssetPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
octoprint.plugin.StartupPlugin,
|
||||
octoprint.plugin.EventHandlerPlugin,
|
||||
octoprint.plugin.SimpleApiPlugin,
|
||||
octoprint.plugin.ShutdownPlugin):
|
||||
|
||||
@ -23,8 +24,15 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self.powerOnOnStart = False
|
||||
self.powerOffOnShutdown = False
|
||||
self.powerOffDelay = 0
|
||||
self.showShutdownOctopiOption = False
|
||||
self.showPowerOffPrintFinishOption = False
|
||||
self.shutdownDelay = 60
|
||||
self.shutdownAfterPrintFinished = False
|
||||
self.powerOffAfterPrintFinished = False
|
||||
|
||||
self._timer = None
|
||||
self._status_timer = None
|
||||
self._abort_timer = None
|
||||
self._wait_for_timelapse_timer = None
|
||||
|
||||
self.energy = 0
|
||||
self.lastTimeStamp = 0
|
||||
@ -52,7 +60,16 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self.powerOffDelay = self._settings.get_int(["powerOffDelay"])
|
||||
self._logger.debug("powerOffDelay: %s" % self.powerOffDelay)
|
||||
|
||||
self._timer_start()
|
||||
self.showShutdownOctopiOption = self._settings.get_boolean(["showShutdownOctopiOption"])
|
||||
self._logger.debug("showShutdownOctopiOption: %s" % self.showShutdownOctopiOption)
|
||||
|
||||
self.showPowerOffPrintFinishOption = self._settings.get_boolean(["showPowerOffPrintFinishOption"])
|
||||
self._logger.debug("showPowerOffPrintFinishOption: %s" % self.showPowerOffPrintFinishOption)
|
||||
|
||||
self.shutdownDelay = self._settings.get_int(["shutdownDelay"])
|
||||
self._logger.debug("shutdownDelay: %s" % self.shutdownDelay)
|
||||
|
||||
self._status_timer_start()
|
||||
|
||||
def get_assets(self):
|
||||
return dict(js=["js/mystromswitch.js"], css=["css/mystromswitch.css"])
|
||||
@ -64,17 +81,78 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
icon="power-off"),
|
||||
dict(type="settings", custom_bindings=False)]
|
||||
|
||||
def _timer_start(self):
|
||||
if self._timer is not None:
|
||||
self._timer.cancel()
|
||||
def _shutdown_timer_start(self):
|
||||
if self._abort_timer is not None:
|
||||
return
|
||||
self._logger.info("_shutdown_timer_start")
|
||||
|
||||
if self._wait_for_timelapse_timer is not None:
|
||||
self._wait_for_timelapse_timer.cancel()
|
||||
|
||||
self._logger.info("Starting abort shutdown timer.")
|
||||
|
||||
self._timeout_value = self.shutdownDelay
|
||||
self._abort_timer = RepeatedTimer(1, self._shutdown_timer_task)
|
||||
self._abort_timer.start()
|
||||
|
||||
def _wait_for_timelapse_start(self):
|
||||
if self._wait_for_timelapse_timer is not None:
|
||||
return
|
||||
self._logger.info("_wait_for_timelapse_start()")
|
||||
|
||||
self._wait_for_timelapse_timer = RepeatedTimer(5, self._wait_for_timelapse)
|
||||
self._wait_for_timelapse_timer.start()
|
||||
|
||||
def _wait_for_timelapse(self):
|
||||
c = len(octoprint.timelapse.get_unrendered_timelapses())
|
||||
|
||||
if c > 0:
|
||||
self._logger.info("Waiting for %s timelapse(s) to finish rendering before starting shutdown timer..." % c)
|
||||
else:
|
||||
self._shutdown_timer_start()
|
||||
|
||||
def _shutdown_timer_task(self):
|
||||
if self._timeout_value is None:
|
||||
return
|
||||
|
||||
self._timeout_value -= 1
|
||||
if self._timeout_value <= 0:
|
||||
if self._wait_for_timelapse_timer is not None:
|
||||
self._wait_for_timelapse_timer.cancel()
|
||||
self._wait_for_timelapse_timer = None
|
||||
if self._abort_timer is not None:
|
||||
self._abort_timer.cancel()
|
||||
self._abort_timer = None
|
||||
if self.shutdownAfterPrintFinished:
|
||||
self._shutdown_system()
|
||||
elif self.powerOffAfterPrintFinished:
|
||||
self._logger.info("only Shutdown Relais")
|
||||
self._setRelaisState(False)
|
||||
|
||||
def _status_timer_start(self):
|
||||
if self._status_timer is not None:
|
||||
self._status_timer.cancel()
|
||||
self._logger.info("Canceling Timer")
|
||||
|
||||
if self.intervall >= 1 and self.ip is not None:
|
||||
self._logger.info("Starting timer")
|
||||
self._timer = RepeatedTimer(self.intervall, self._timer_task)
|
||||
self._timer.start()
|
||||
self._status_timer = RepeatedTimer(self.intervall, self._status_timer_task)
|
||||
self._status_timer.start()
|
||||
|
||||
def _timer_task(self):
|
||||
def _shutdown_system(self):
|
||||
self._logger.info("Shutdown Relais and System")
|
||||
self._powerCycleRelais(False, self.powerOffDelay)
|
||||
shutdown_command = self._settings.global_get(["server", "commands", "systemShutdownCommand"])
|
||||
self._logger.info("Shutting down system with command: {command}".format(command=shutdown_command))
|
||||
try:
|
||||
import sarge
|
||||
p = sarge.run(shutdown_command, async=True)
|
||||
except Exception as e:
|
||||
self._logger.exception("Error when shutting down: {error}".format(error=e))
|
||||
return
|
||||
|
||||
|
||||
def _status_timer_task(self):
|
||||
if self.ip is not None:
|
||||
try:
|
||||
try:
|
||||
@ -93,13 +171,23 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self.lastTimeStamp = timestamp
|
||||
data["energy"] = self.energy
|
||||
data["onOffButtonEnabled"] = self.onOffButtonEnabled
|
||||
data["showShutdownOctopiOption"] = self.showShutdownOctopiOption
|
||||
data["showPowerOffPrintFinishOption"] = self.showPowerOffPrintFinishOption
|
||||
data["automaticShutdownEnabled"] = self.shutdownAfterPrintFinished
|
||||
data["automaticPowerOffEnabled"] = self.powerOffAfterPrintFinished
|
||||
self._plugin_manager.send_plugin_message(self._identifier, data)
|
||||
return
|
||||
except (requests.exceptions.ConnectionError, ValueError) as e:
|
||||
self._logger.exception(e)
|
||||
except Exception as exp:
|
||||
self._logger.exception(exp)
|
||||
else:
|
||||
self._logger.info("Ip is None")
|
||||
data = {"relay": True, "energy": 0, "onOffButtonEnabled": False, "showShutdownOctopiOption": False,
|
||||
"showPowerOffPrintFinishOption": False, "automaticShutdownEnabled": self.shutdownAfterPrintFinished,
|
||||
"v": self.powerOffAfterPrintFinished}
|
||||
self._plugin_manager.send_plugin_message(self._identifier, data)
|
||||
|
||||
|
||||
def _setRelaisState(self, newState):
|
||||
nbRetry = 0
|
||||
@ -119,6 +207,7 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self._logger.info("Error during set Relais state")
|
||||
nbRetry = nbRetry + 1
|
||||
|
||||
|
||||
# Sets the switch to a specific inverse newState,
|
||||
# waits for a specified amount of time (max 3h),
|
||||
# then sets the the switch to the newState.
|
||||
@ -146,6 +235,7 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self._logger.exception(exp)
|
||||
nbRetry = nbRetry + 1
|
||||
|
||||
|
||||
def _toggleRelay(self):
|
||||
nbRetry = 0
|
||||
while nbRetry < 3:
|
||||
@ -160,6 +250,7 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self._logger.info("Error during toggle Relais state")
|
||||
nbRetry = nbRetry + 1
|
||||
|
||||
|
||||
def on_api_command(self, command, data):
|
||||
if command == "enableRelais":
|
||||
self._logger.info("enableRelais")
|
||||
@ -170,19 +261,38 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
elif command == "toggleRelais":
|
||||
self._logger.info("toggleRelais")
|
||||
self._toggleRelay()
|
||||
elif command == "enableShutdownAfterFinish":
|
||||
self._logger.info("enableShutdownAfterFinish")
|
||||
self.shutdownAfterPrintFinished = True
|
||||
elif command == "disableShutdownAfterFinish":
|
||||
self._logger.info("disableShutdownAfterFinish")
|
||||
self.shutdownAfterPrintFinished = False
|
||||
elif command == "enablePowerOffAfterFinish":
|
||||
self._logger.info("enablePowerOffAfterFinish")
|
||||
self.powerOffAfterPrintFinished = True
|
||||
elif command == "disablePowerOffAfterFinish":
|
||||
self._logger.info("disablePowerOffAfterFinish")
|
||||
self.powerOffAfterPrintFinished = False
|
||||
|
||||
|
||||
def get_api_commands(self):
|
||||
return dict(
|
||||
enableRelais=[],
|
||||
disableRelais=[],
|
||||
toggleRelais=[]
|
||||
toggleRelais=[],
|
||||
disableShutdownAfterFinish=[],
|
||||
enableShutdownAfterFinish=[],
|
||||
disablePowerOffAfterFinish=[],
|
||||
enablePowerOffAfterFinish=[]
|
||||
)
|
||||
|
||||
|
||||
def on_after_startup(self):
|
||||
if self.powerOnOnStart:
|
||||
self._logger.info("Turn on Relais on Start")
|
||||
self._setRelaisState(True)
|
||||
|
||||
|
||||
def on_shutdown(self):
|
||||
self._logger.info("on_shutdown_event")
|
||||
if self.powerOffOnShutdown:
|
||||
@ -193,18 +303,24 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self._logger.info("Turn off Relais on Shutdown Delayed")
|
||||
self._powerCycleRelais(False, self.powerOffDelay)
|
||||
|
||||
|
||||
def on_settings_migrate(self, target, current):
|
||||
if target > current:
|
||||
if current <= 1:
|
||||
self.onOffButtonEnabled = False
|
||||
pass
|
||||
if current <= 2:
|
||||
self.powerOnOnStart = False,
|
||||
self.powerOffOnShutdown = False,
|
||||
self.powerOffDelay = 0
|
||||
if current <= 3:
|
||||
self.showShutdownOctopiOption = False
|
||||
self.showPowerOffPrintFinishOption = False
|
||||
self.shutdownDelay = 60
|
||||
|
||||
|
||||
def get_settings_version(self):
|
||||
return 3
|
||||
return 4
|
||||
|
||||
|
||||
def get_settings_defaults(self):
|
||||
return dict(
|
||||
@ -213,19 +329,50 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
onOffButtonEnabled=False,
|
||||
powerOnOnStart=False,
|
||||
powerOffOnShutdown=False,
|
||||
powerOffDelay=0
|
||||
powerOffDelay=0,
|
||||
showShutdownOctopiOption=False,
|
||||
showPowerOffPrintFinishOption=False,
|
||||
shutdownDelay=60
|
||||
)
|
||||
|
||||
|
||||
def get_settings_restricted_paths(self):
|
||||
return dict(admin=[
|
||||
['ip']
|
||||
])
|
||||
|
||||
|
||||
def on_settings_save(self, data):
|
||||
self._logger.info("on_settings_save")
|
||||
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
|
||||
self.initialize()
|
||||
|
||||
|
||||
def on_event(self, event, payload):
|
||||
if not self.shutdownAfterPrintFinished and not self.powerOffAfterPrintFinished:
|
||||
return
|
||||
|
||||
if not self._settings.global_get(["server", "commands", "systemShutdownCommand"]):
|
||||
self._logger.warning("systemShutdownCommand is not defined. Aborting shutdown...")
|
||||
return
|
||||
|
||||
if event not in [Events.PRINT_DONE, Events.PRINT_FAILED]:
|
||||
return
|
||||
|
||||
if event == Events.PRINT_FAILED and not self._printer.is_closed_or_error():
|
||||
# Cancelled job
|
||||
return
|
||||
|
||||
if event in [Events.PRINT_DONE, Events.PRINT_FAILED]:
|
||||
webcam_config = self._settings.global_get(["webcam", "timelapse"], merged=True)
|
||||
timelapse_type = webcam_config["type"]
|
||||
if (timelapse_type is not None and timelapse_type != "off"):
|
||||
self._wait_for_timelapse_start()
|
||||
else:
|
||||
self._shutdown_timer_start()
|
||||
return
|
||||
|
||||
|
||||
def get_update_information(self):
|
||||
return dict(
|
||||
mystromswitch=dict(
|
||||
|
@ -7,6 +7,10 @@ $(function() {
|
||||
self.printer = parameters[2];
|
||||
|
||||
self.onOffButtonEnabled = ko.observable();
|
||||
self.showShutdownOctopiOption = ko.observable();
|
||||
self.showPowerOffPrintFinishOption = ko.observable();
|
||||
self.automaticPowerOffEnabled = ko.observable();
|
||||
self.automaticShutdownEnabled = ko.observable();
|
||||
self.mystromswitchPowerValue = document.getElementById("mystromswitchPowerValue")
|
||||
self.mystromswitchEnergyValue = document.getElementById("mystromswitchEnergyValue")
|
||||
|
||||
@ -22,23 +26,65 @@ $(function() {
|
||||
})
|
||||
}
|
||||
|
||||
self.onmystromswitchEvent = function() {
|
||||
//self.onmystromswitchEvent = function() {
|
||||
|
||||
//}
|
||||
|
||||
//self.onOffButtonEnabled.subscribe(self.onmystromswitchEvent, self);
|
||||
|
||||
self.onAutomaticShutdownEnabledChanged = function(){
|
||||
var cmd = "disableShutdownAfterFinish";
|
||||
if (self.automaticShutdownEnabled()) {
|
||||
var cmd = "enableShutdownAfterFinish";
|
||||
}
|
||||
$.ajax({
|
||||
url: API_BASEURL + "plugin/mystromswitch",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: JSON.stringify({
|
||||
command: cmd
|
||||
}),
|
||||
contentType: "application/json; charset=UTF-8"
|
||||
})
|
||||
}
|
||||
|
||||
self.onOffButtonEnabled.subscribe(self.onmystromswitchEvent, self);
|
||||
self.onAutomaticPowerOffEnabledChanged = function(){
|
||||
var cmd = "disablePowerOffAfterFinish";
|
||||
if (self.automaticPowerOffEnabled()) {
|
||||
var cmd = "enablePowerOffAfterFinish";
|
||||
}
|
||||
$.ajax({
|
||||
url: API_BASEURL + "plugin/mystromswitch",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: JSON.stringify({
|
||||
command: cmd
|
||||
}),
|
||||
contentType: "application/json; charset=UTF-8"
|
||||
})
|
||||
}
|
||||
|
||||
self.automaticShutdownEnabled.subscribe(self.onAutomaticShutdownEnabledChanged, self);
|
||||
self.automaticPowerOffEnabled.subscribe(self.onAutomaticPowerOffEnabledChanged, self);
|
||||
|
||||
self.onDataUpdaterPluginMessage = function(plugin, data) {
|
||||
if (plugin != "mystromswitch" && plugin != "octoprint_mystromswitch") {
|
||||
return;
|
||||
}
|
||||
self.onOffButtonEnabled(data.onOffButtonEnabled);
|
||||
self.showShutdownOctopiOption(data.showShutdownOctopiOption);
|
||||
self.showPowerOffPrintFinishOption(data.showPowerOffPrintFinishOption);
|
||||
self.mystromswitchEnergyValue.innerHTML = "Energy: "+data.energy.toFixed(1)+"Wh"
|
||||
if(data.relay == false){
|
||||
self.mystromswitchPowerValue.innerHTML = "Relay is off";
|
||||
} else if (data.power != null) {
|
||||
self.mystromswitchPowerValue.innerHTML = "Power Consumption "+data.power.toFixed(1)+"W";
|
||||
}else{
|
||||
self.mystromswitchPowerValue.innerHTML = "myStrom switch not reachable"
|
||||
self.mystromswitchEnergyValue.innerHTML = "Check url in Plugin Settings"
|
||||
}
|
||||
self.automaticShutdownEnabled(data.automaticShutdownEnabled);
|
||||
self.automaticPowerOffEnabled(data.automaticPowerOffEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<form class="form-horizontal">
|
||||
<h4>General</h4>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('URL or IP-Address of your switch') }}</label>
|
||||
<label class="control-label">{{ _('URL or IP-Address of your switch (without http)') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: settings.plugins.mystromswitch.ip">
|
||||
</div>
|
||||
@ -61,4 +61,35 @@
|
||||
<span class="help-block"><small>{{ _('Delay in seconds after octoprint is shutted down to switch off relays. This settings is recommended to make sure that Raspberry Pi is completely shutted down when you switch power off. Switching off when your Raspberry Pi is running could lead to unrepairable damage to your SD Card!') }}</small></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h4>Automatic Power Off Features</h4>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: settings.plugins.mystromswitch.showShutdownOctopiOption">Show option to automatic shutdown Octoprint after Print is finished
|
||||
</label>
|
||||
<span class="help-block"><small>{{ _('This setting shows the option to shut Octoprint down and switch your mySwitch off after your Print is finished. Use the "Delay after print is finished" option to determine after how many seconds Octoprint will be shutted down. After this use "Turn Relais Off Delay" to determine after how many seconds the Relas will be switched off') }}</small></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: settings.plugins.mystromswitch.showPowerOffPrintFinishOption">Show option to turn off Relais after Print is finished
|
||||
</label>
|
||||
<span class="help-block"><small>{{ _('This setting shows the option to only switch your mySwitch off after your Print is finished. Use the "Delay after print is finished" Option to determine after how many seconds the Relais will switch off') }}</small></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Delay after print is finished') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" class="input-block-level" data-bind="value: settings.plugins.mystromswitch.shutdownDelay">
|
||||
<span class="add-on">seconds</span>
|
||||
</div>
|
||||
<span class="help-block"><small>{{ _('Delay in seconds after after print is finished') }}</small></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
@ -2,4 +2,13 @@
|
||||
<label class="control-label" id="mystromswitchPowerValue">Powerconsumption 0.0W</label>
|
||||
<label class="control-label" id="mystromswitchEnergyValue">Energy 0.0Wh</label>
|
||||
<button class="btn btn-primary" data-bind="click: onToggleRelayEvent, visible : onOffButtonEnabled">{{ _('Toggle Relais') }}</button>
|
||||
<label class="checkbox" data-bind="visible :showShutdownOctopiOption">
|
||||
<input type="checkbox" data-bind="enable: loginState.isUser(), checked: automaticShutdownEnabled, visible :showShutdownOctopiOption">
|
||||
{{ _('Shutdown Octoprint after print finishes') }}
|
||||
</label>
|
||||
|
||||
<label class="checkbox" data-bind="visible: showPowerOffPrintFinishOption">
|
||||
<input type="checkbox" data-bind="enable: loginState.isUser(), checked: automaticPowerOffEnabled, visible: showPowerOffPrintFinishOption">
|
||||
{{ _('Power Off Relais after print finishes') }}
|
||||
</label>
|
||||
</div>
|
||||
|
2
setup.py
2
setup.py
@ -14,7 +14,7 @@ plugin_package = "octoprint_mystromswitch"
|
||||
plugin_name = "OctoPrint-MyStromSwitch"
|
||||
|
||||
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
|
||||
plugin_version = "1.0.2"
|
||||
plugin_version = "1.0.3"
|
||||
|
||||
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
|
||||
# module
|
||||
|
Loading…
Reference in New Issue
Block a user