#21 Add PowerOFF when print is finished

This commit is contained in:
David Zingg 2020-06-28 16:34:51 +02:00
parent 39ff47e829
commit 6f96140e10
2 changed files with 230 additions and 231 deletions

View File

@ -2,8 +2,7 @@
<project version="4">
<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/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@ -48,13 +47,6 @@
<option name="presentableId" value="Default" />
<updated>1574193087583</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" />
@ -391,7 +383,14 @@
<option name="project" value="LOCAL" />
<updated>1593353565224</updated>
</task>
<option name="localTasksCounter" value="83" />
<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>
<option name="localTasksCounter" value="84" />
<servers />
</component>
<component name="UnknownFeatures">

View File

@ -152,7 +152,7 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
return
def _status_timer_task(self):
def _status_timer_task(self):
if self.ip is not None:
try:
try:
@ -189,7 +189,7 @@ def _status_timer_task(self):
self._plugin_manager.send_plugin_message(self._identifier, data)
def _setRelaisState(self, newState):
def _setRelaisState(self, newState):
nbRetry = 0
value = '0'
if newState:
@ -208,10 +208,10 @@ def _setRelaisState(self, newState):
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.
def _powerCycleRelais(self, newState, time):
# 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.
def _powerCycleRelais(self, newState, time):
nbRetry = 0
value = 'on'
if newState:
@ -236,7 +236,7 @@ def _powerCycleRelais(self, newState, time):
nbRetry = nbRetry + 1
def _toggleRelay(self):
def _toggleRelay(self):
nbRetry = 0
while nbRetry < 3:
try:
@ -251,7 +251,7 @@ def _toggleRelay(self):
nbRetry = nbRetry + 1
def on_api_command(self, command, data):
def on_api_command(self, command, data):
if command == "enableRelais":
self._logger.info("enableRelais")
self._setRelaisState(True)
@ -275,7 +275,7 @@ def on_api_command(self, command, data):
self.powerOffAfterPrintFinished = False
def get_api_commands(self):
def get_api_commands(self):
return dict(
enableRelais=[],
disableRelais=[],
@ -287,13 +287,13 @@ def get_api_commands(self):
)
def on_after_startup(self):
def on_after_startup(self):
if self.powerOnOnStart:
self._logger.info("Turn on Relais on Start")
self._setRelaisState(True)
def on_shutdown(self):
def on_shutdown(self):
self._logger.info("on_shutdown_event")
if self.powerOffOnShutdown:
if self.powerOffDelay <= 0:
@ -304,7 +304,7 @@ def on_shutdown(self):
self._powerCycleRelais(False, self.powerOffDelay)
def on_settings_migrate(self, target, current):
def on_settings_migrate(self, target, current):
if target > current:
if current <= 1:
self.onOffButtonEnabled = False
@ -318,11 +318,11 @@ def on_settings_migrate(self, target, current):
self.shutdownDelay = 60
def get_settings_version(self):
def get_settings_version(self):
return 4
def get_settings_defaults(self):
def get_settings_defaults(self):
return dict(
ip=None,
intervall=1,
@ -336,19 +336,19 @@ def get_settings_defaults(self):
)
def get_settings_restricted_paths(self):
def get_settings_restricted_paths(self):
return dict(admin=[
['ip']
])
def on_settings_save(self, data):
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):
def on_event(self, event, payload):
if not self.shutdownAfterPrintFinished and not self.powerOffAfterPrintFinished:
return
@ -373,7 +373,7 @@ def on_event(self, event, payload):
return
def get_update_information(self):
def get_update_information(self):
return dict(
mystromswitch=dict(
displayName="OctoPrint-MyStromSwitch",