commit
ca61b89b3f
173
.idea/workspace.xml
generated
173
.idea/workspace.xml
generated
@ -3,7 +3,8 @@
|
||||
<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$/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/setup.py" beforeDir="false" afterPath="$PROJECT_DIR$/setup.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -48,90 +49,6 @@
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1574193087583</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00036" summary="#8 Relais ein / ausschalten von Ocotprint aus">
|
||||
<created>1574609901438</created>
|
||||
<option name="number" value="00036" />
|
||||
<option name="presentableId" value="LOCAL-00036" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574609901438</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00037" summary="#8 Relais ein / ausschalten von Ocotprint aus">
|
||||
<created>1574610253466</created>
|
||||
<option name="number" value="00037" />
|
||||
<option name="presentableId" value="LOCAL-00037" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574610253466</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00038" summary="#9 Relais ausschalten wenn Octoprint heruntergefahren wird #7 Relais einschalten wenn Octoprint gestartet wurde">
|
||||
<created>1574707150761</created>
|
||||
<option name="number" value="00038" />
|
||||
<option name="presentableId" value="LOCAL-00038" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574707150761</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00039" summary="#9 Relais ausschalten wenn Octoprint heruntergefahren wird #7 Relais einschalten wenn Octoprint gestartet wurde">
|
||||
<created>1574707411686</created>
|
||||
<option name="number" value="00039" />
|
||||
<option name="presentableId" value="LOCAL-00039" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574707411686</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00040" summary="#9 Relais ausschalten wenn Octoprint heruntergefahren wird #7 Relais einschalten wenn Octoprint gestartet wurde Logging schreibfehler Url Fix für Powercycle">
|
||||
<created>1574707826329</created>
|
||||
<option name="number" value="00040" />
|
||||
<option name="presentableId" value="LOCAL-00040" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574707826329</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00041" summary="#9 Relais ausschalten wenn Octoprint heruntergefahren wird #7 Relais einschalten wenn Octoprint gestartet wurde">
|
||||
<created>1574708023156</created>
|
||||
<option name="number" value="00041" />
|
||||
<option name="presentableId" value="LOCAL-00041" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574708023156</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00042" summary="#9 Relais ausschalten wenn Octoprint heruntergefahren wird #7 Relais einschalten wenn Octoprint gestartet wurde Api call fix">
|
||||
<created>1574708245896</created>
|
||||
<option name="number" value="00042" />
|
||||
<option name="presentableId" value="LOCAL-00042" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574708245896</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00043" summary="#9 Relais ausschalten wenn Octoprint heruntergefahren wird #7 Relais einschalten wenn Octoprint gestartet wurde Api call fix">
|
||||
<created>1574708497039</created>
|
||||
<option name="number" value="00043" />
|
||||
<option name="presentableId" value="LOCAL-00043" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574708497039</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00044" summary="#13 Wenn Request fehlschägt max. 3x versuchen">
|
||||
<created>1574710870028</created>
|
||||
<option name="number" value="00044" />
|
||||
<option name="presentableId" value="LOCAL-00044" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574710870028</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00045" summary="#11 Energieverbrauch näherungsweise berechnen">
|
||||
<created>1574712024409</created>
|
||||
<option name="number" value="00045" />
|
||||
<option name="presentableId" value="LOCAL-00045" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574712024409</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00046" summary="#11 Energieverbrauch näherungsweise berechnen">
|
||||
<created>1574712205852</created>
|
||||
<option name="number" value="00046" />
|
||||
<option name="presentableId" value="LOCAL-00046" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574712205852</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00047" summary="#14 Einstellungen reorganisieren">
|
||||
<created>1574873790898</created>
|
||||
<option name="number" value="00047" />
|
||||
<option name="presentableId" value="LOCAL-00047" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574873790898</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00048" summary="#14 Einstellungen reorganisieren">
|
||||
<created>1574873809876</created>
|
||||
<option name="number" value="00048" />
|
||||
@ -391,7 +308,91 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593354891881</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="85" />
|
||||
<task id="LOCAL-00085" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593356663020</created>
|
||||
<option name="number" value="00085" />
|
||||
<option name="presentableId" value="LOCAL-00085" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593356663020</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00086" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593627018087</created>
|
||||
<option name="number" value="00086" />
|
||||
<option name="presentableId" value="LOCAL-00086" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593627018088</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00087" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593627195608</created>
|
||||
<option name="number" value="00087" />
|
||||
<option name="presentableId" value="LOCAL-00087" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593627195608</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00088" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593628251128</created>
|
||||
<option name="number" value="00088" />
|
||||
<option name="presentableId" value="LOCAL-00088" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593628251128</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00089" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593628347105</created>
|
||||
<option name="number" value="00089" />
|
||||
<option name="presentableId" value="LOCAL-00089" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593628347105</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00090" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593628617461</created>
|
||||
<option name="number" value="00090" />
|
||||
<option name="presentableId" value="LOCAL-00090" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593628617461</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00091" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593629014910</created>
|
||||
<option name="number" value="00091" />
|
||||
<option name="presentableId" value="LOCAL-00091" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593629014910</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00092" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593629188987</created>
|
||||
<option name="number" value="00092" />
|
||||
<option name="presentableId" value="LOCAL-00092" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593629188987</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00093" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593629352018</created>
|
||||
<option name="number" value="00093" />
|
||||
<option name="presentableId" value="LOCAL-00093" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593629352018</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00094" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593629491361</created>
|
||||
<option name="number" value="00094" />
|
||||
<option name="presentableId" value="LOCAL-00094" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593629491361</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00095" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593629609079</created>
|
||||
<option name="number" value="00095" />
|
||||
<option name="presentableId" value="LOCAL-00095" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593629609079</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00096" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593630096392</created>
|
||||
<option name="number" value="00096" />
|
||||
<option name="presentableId" value="LOCAL-00096" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593630096392</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="97" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="UnknownFeatures">
|
||||
|
@ -27,8 +27,13 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self.showShutdownOctopiOption = False
|
||||
self.showPowerOffPrintFinishOption = False
|
||||
self.shutdownDelay = 60
|
||||
self.shutdownAfterPrintFinished = False
|
||||
self.powerOffAfterPrintFinished = False
|
||||
|
||||
self.rememberShutdown = False
|
||||
self.lastPowerOff = False
|
||||
self.lastShutdown = False
|
||||
|
||||
self.shutdownAfterPrintFinished = self.lastShutdown if self.rememberShutdown else False
|
||||
self.powerOffAfterPrintFinished = self.lastPowerOff if self.rememberShutdown else False
|
||||
|
||||
self._status_timer = None
|
||||
self._abort_timer = None
|
||||
@ -69,6 +74,19 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self.shutdownDelay = self._settings.get_int(["shutdownDelay"])
|
||||
self._logger.debug("shutdownDelay: %s" % self.shutdownDelay)
|
||||
|
||||
self.rememberShutdown = self._settings.get_boolean(["rememberShutdown"])
|
||||
self._logger.info("rememberShutdown: %s" % self.rememberShutdown)
|
||||
|
||||
self.lastPowerOff = self._settings.get_boolean(["lastPowerOff"])
|
||||
self._logger.info("lastPowerOff: %s" % self.lastPowerOff)
|
||||
|
||||
self.lastShutdown = self._settings.get_boolean(["lastShutdown"])
|
||||
self._logger.info("lastShutdown: %s" % self.lastShutdown)
|
||||
|
||||
if self.rememberShutdown:
|
||||
self.powerOffAfterPrintFinished = self.lastPowerOff
|
||||
self.shutdownAfterPrintFinished = self.lastShutdown
|
||||
|
||||
self._status_timer_start()
|
||||
|
||||
def get_assets(self):
|
||||
@ -123,9 +141,9 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
if self._abort_timer is not None:
|
||||
self._abort_timer.cancel()
|
||||
self._abort_timer = None
|
||||
if self.shutdownAfterPrintFinished:
|
||||
if self.shutdownAfterPrintFinished and self.showShutdownOctopiOption:
|
||||
self._shutdown_system()
|
||||
elif self.powerOffAfterPrintFinished:
|
||||
elif self.powerOffAfterPrintFinished and self.showPowerOffPrintFinishOption:
|
||||
self._logger.info("only Shutdown Relais")
|
||||
self._setRelaisState(False)
|
||||
|
||||
@ -151,7 +169,6 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self._logger.exception("Error when shutting down: {error}".format(error=e))
|
||||
return
|
||||
|
||||
|
||||
def _status_timer_task(self):
|
||||
if self.ip is not None:
|
||||
try:
|
||||
@ -185,10 +202,9 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self._logger.info("Ip is None")
|
||||
data = {"relay": True, "energy": 0, "onOffButtonEnabled": False, "showShutdownOctopiOption": False,
|
||||
"showPowerOffPrintFinishOption": False, "automaticShutdownEnabled": self.shutdownAfterPrintFinished,
|
||||
"v": self.powerOffAfterPrintFinished}
|
||||
"automaticPowerOffEnabled": self.powerOffAfterPrintFinished}
|
||||
self._plugin_manager.send_plugin_message(self._identifier, data)
|
||||
|
||||
|
||||
def _setRelaisState(self, newState):
|
||||
nbRetry = 0
|
||||
value = '0'
|
||||
@ -207,7 +223,6 @@ 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.
|
||||
@ -235,7 +250,6 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self._logger.exception(exp)
|
||||
nbRetry = nbRetry + 1
|
||||
|
||||
|
||||
def _toggleRelay(self):
|
||||
nbRetry = 0
|
||||
while nbRetry < 3:
|
||||
@ -250,7 +264,6 @@ 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")
|
||||
@ -264,16 +277,31 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
elif command == "enableShutdownAfterFinish":
|
||||
self._logger.info("enableShutdownAfterFinish")
|
||||
self.shutdownAfterPrintFinished = True
|
||||
if self.rememberShutdown:
|
||||
self.lastShutdown = self.shutdownAfterPrintFinished
|
||||
self._settings.set_boolean(["lastShutdown"], self.lastShutdown)
|
||||
self._settings.save()
|
||||
elif command == "disableShutdownAfterFinish":
|
||||
self._logger.info("disableShutdownAfterFinish")
|
||||
self.shutdownAfterPrintFinished = False
|
||||
if self.rememberShutdown:
|
||||
self.lastShutdown = self.shutdownAfterPrintFinished
|
||||
self._settings.set_boolean(["lastShutdown"], self.lastShutdown)
|
||||
self._settings.save()
|
||||
elif command == "enablePowerOffAfterFinish":
|
||||
self._logger.info("enablePowerOffAfterFinish")
|
||||
self.powerOffAfterPrintFinished = True
|
||||
if self.rememberShutdown:
|
||||
self.lastPowerOff = self.powerOffAfterPrintFinished
|
||||
self._settings.set_boolean(["lastPowerOff"], self.lastPowerOff)
|
||||
self._settings.save()
|
||||
elif command == "disablePowerOffAfterFinish":
|
||||
self._logger.info("disablePowerOffAfterFinish")
|
||||
self.powerOffAfterPrintFinished = False
|
||||
|
||||
if self.rememberShutdown:
|
||||
self.lastPowerOff = self.powerOffAfterPrintFinished
|
||||
self._settings.set_boolean(["lastPowerOff"], self.lastPowerOff)
|
||||
self._settings.save()
|
||||
|
||||
def get_api_commands(self):
|
||||
return dict(
|
||||
@ -286,13 +314,11 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
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:
|
||||
@ -303,7 +329,6 @@ 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:
|
||||
@ -316,11 +341,13 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self.showShutdownOctopiOption = False
|
||||
self.showPowerOffPrintFinishOption = False
|
||||
self.shutdownDelay = 60
|
||||
|
||||
if current <= 4:
|
||||
self.lastShutdown = False
|
||||
self.lastPowerOff = False
|
||||
self.rememberShutdown = False
|
||||
|
||||
def get_settings_version(self):
|
||||
return 4
|
||||
|
||||
return 5
|
||||
|
||||
def get_settings_defaults(self):
|
||||
return dict(
|
||||
@ -332,22 +359,22 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
powerOffDelay=0,
|
||||
showShutdownOctopiOption=False,
|
||||
showPowerOffPrintFinishOption=False,
|
||||
shutdownDelay=60
|
||||
shutdownDelay=60,
|
||||
lastShutdown=False,
|
||||
lastPowerOff=False,
|
||||
rememberShutdown=False
|
||||
)
|
||||
|
||||
|
||||
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
|
||||
@ -372,7 +399,6 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self._shutdown_timer_start()
|
||||
return
|
||||
|
||||
|
||||
def get_update_information(self):
|
||||
return dict(
|
||||
mystromswitch=dict(
|
||||
|
@ -63,6 +63,15 @@
|
||||
</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.rememberShutdown">remember Shutdown
|
||||
</label>
|
||||
<span class="help-block"><small>{{ _('Remember state of the checkboxes after reboot') }}</small></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
|
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.3"
|
||||
plugin_version = "1.0.4"
|
||||
|
||||
# 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