#21 Add PowerOFF when print is finished
neue Einstellmöglichkeiten anzeigen
This commit is contained in:
parent
c31d7b7bca
commit
3d7cb06446
@ -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>
|
||||
|
@ -2,8 +2,12 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="7e2e0eec-b22e-4d48-8f24-196d1ed9b51a" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||
<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" />
|
||||
<change beforePath="$PROJECT_DIR$/octoprint_mystromswitch/static/js/mystromswitch.js" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/static/js/mystromswitch.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/octoprint_mystromswitch/templates/mystromswitch_settings.jinja2" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/templates/mystromswitch_settings.jinja2" 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" />
|
||||
@ -11,16 +15,168 @@
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FUSProjectUsageTrigger">
|
||||
<session id="799293204">
|
||||
<usages-collector id="statistics.lifecycle.project">
|
||||
<counts>
|
||||
<entry key="project.closed" value="2" />
|
||||
<entry key="project.open.time.0" value="2" />
|
||||
<entry key="project.open.time.8" value="1" />
|
||||
<entry key="project.opened" value="3" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.extensions.open">
|
||||
<counts>
|
||||
<entry key="jinja2" value="2" />
|
||||
<entry key="js" value="1" />
|
||||
<entry key="py" value="2" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.types.open">
|
||||
<counts>
|
||||
<entry key="JavaScript" value="1" />
|
||||
<entry key="PLAIN_TEXT" value="2" />
|
||||
<entry key="Python" value="2" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.extensions.edit">
|
||||
<counts>
|
||||
<entry key="jinja2" value="652" />
|
||||
<entry key="js" value="122" />
|
||||
<entry key="py" value="332" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.types.edit">
|
||||
<counts>
|
||||
<entry key="JavaScript" value="122" />
|
||||
<entry key="PLAIN_TEXT" value="652" />
|
||||
<entry key="Python" value="332" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
</session>
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/setup.py">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/octoprint_mystromswitch/__init__.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="501">
|
||||
<caret line="280" column="48" lean-forward="true" selection-start-line="280" selection-start-column="48" selection-end-line="280" selection-end-column="48" />
|
||||
<folding>
|
||||
<element signature="e#15#53#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/octoprint_mystromswitch/templates/mystromswitch_settings.jinja2">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1479">
|
||||
<caret line="87" column="125" selection-start-line="87" selection-start-column="112" selection-end-line="87" selection-end-column="125" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/octoprint_mystromswitch/static/js/mystromswitch.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="833">
|
||||
<caret line="49" column="49" selection-start-line="49" selection-start-column="49" selection-end-line="49" selection-end-column="49" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="170">
|
||||
<caret line="10" column="104" selection-start-line="10" selection-start-column="80" selection-end-line="10" selection-end-column="104" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>onOffBu</find>
|
||||
<find>onOffButtonEnabled</find>
|
||||
<find>onmystromswitchEvent</find>
|
||||
</findStrings>
|
||||
</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="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/octoprint_mystromswitch/templates/mystromswitch_settings.jinja2" />
|
||||
<option value="$PROJECT_DIR$/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2" />
|
||||
<option value="$PROJECT_DIR$/octoprint_mystromswitch/static/js/mystromswitch.js" />
|
||||
<option value="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds" extendedState="6">
|
||||
<option name="width" value="2587" />
|
||||
<option name="height" value="1469" />
|
||||
</component>
|
||||
<component name="ProjectId" id="1TqgYXT1S9U5eM0eUvs1YarA1ll" />
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||
<component name="ProjectView">
|
||||
<navigator proportions="" version="1">
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scope" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="OctoPrint-MyStromSwitch" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="OctoPrint-MyStromSwitch" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="OctoPrint-MyStromSwitch" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="OctoPrint-MyStromSwitch" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="octoprint_mystromswitch" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="OctoPrint-MyStromSwitch" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="OctoPrint-MyStromSwitch" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="octoprint_mystromswitch" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="static" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="OctoPrint-MyStromSwitch" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="OctoPrint-MyStromSwitch" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="octoprint_mystromswitch" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="static" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="js" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="OctoPrint-MyStromSwitch" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="OctoPrint-MyStromSwitch" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="octoprint_mystromswitch" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="templates" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/../LEDStrip/RaspberryPi/Python" />
|
||||
@ -394,6 +550,29 @@
|
||||
<option name="localTasksCounter" value="61" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="-7" y="-7" width="2208" height="1208" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.25" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||
<window_info id="Favorites" order="2" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" weight="0.32917705" />
|
||||
<window_info anchor="bottom" id="Run" order="2" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
<window_info active="true" anchor="bottom" id="Version Control" order="7" visible="true" weight="0.32992566" />
|
||||
<window_info anchor="bottom" id="Terminal" order="8" />
|
||||
<window_info anchor="bottom" id="Event Log" order="9" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Python Console" order="10" />
|
||||
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
|
||||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="UnknownFeatures">
|
||||
<option featureType="com.intellij.fileTypeFactory" implementationName="*.js" />
|
||||
</component>
|
||||
@ -413,6 +592,12 @@
|
||||
<entry key="MAIN">
|
||||
<value>
|
||||
<State>
|
||||
<option name="RECENTLY_FILTERED_USER_GROUPS">
|
||||
<collection />
|
||||
</option>
|
||||
<option name="RECENTLY_FILTERED_BRANCH_GROUPS">
|
||||
<collection />
|
||||
</option>
|
||||
<option name="COLUMN_ORDER" />
|
||||
</State>
|
||||
</value>
|
||||
@ -420,6 +605,9 @@
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsContentAnnotationSettings">
|
||||
<option name="myLimit" value="2678400000" />
|
||||
</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" />
|
||||
@ -447,4 +635,40 @@
|
||||
<MESSAGE value="#17 Logs aufgeräumt" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="#17 Logs aufgeräumt" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/setup.py">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/octoprint_mystromswitch/templates/mystromswitch_settings.jinja2">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1479">
|
||||
<caret line="87" column="125" selection-start-line="87" selection-start-column="112" selection-end-line="87" selection-end-column="125" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/octoprint_mystromswitch/static/js/mystromswitch.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="833">
|
||||
<caret line="49" column="49" selection-start-line="49" selection-start-column="49" selection-end-line="49" selection-end-column="49" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="170">
|
||||
<caret line="10" column="104" selection-start-line="10" selection-start-column="80" selection-end-line="10" selection-end-column="104" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/octoprint_mystromswitch/__init__.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="501">
|
||||
<caret line="280" column="48" lean-forward="true" selection-start-line="280" selection-start-column="48" selection-end-line="280" selection-end-column="48" />
|
||||
<folding>
|
||||
<element signature="e#15#53#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
</project>
|
@ -1,11 +1,10 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
|
||||
import ssl
|
||||
import time
|
||||
|
||||
import octoprint.plugin
|
||||
import requests
|
||||
import ssl
|
||||
import time
|
||||
from octoprint.util import RepeatedTimer
|
||||
|
||||
|
||||
@ -13,6 +12,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,6 +23,11 @@ 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
|
||||
|
||||
@ -52,7 +57,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 +78,17 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
icon="power-off"),
|
||||
dict(type="settings", custom_bindings=False)]
|
||||
|
||||
def _timer_start(self):
|
||||
def _status_timer_start(self):
|
||||
if self._timer is not None:
|
||||
self._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 = RepeatedTimer(self.intervall, self._status_timer_task)
|
||||
self._timer.start()
|
||||
|
||||
def _timer_task(self):
|
||||
def _status_timer_task(self):
|
||||
if self.ip is not None:
|
||||
try:
|
||||
try:
|
||||
@ -170,6 +184,18 @@ 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.disableShutdownAfterFinish = 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(
|
||||
@ -197,14 +223,17 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
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,7 +242,10 @@ 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):
|
||||
@ -226,6 +258,31 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
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._timer_start()
|
||||
return
|
||||
|
||||
def get_update_information(self):
|
||||
return dict(
|
||||
mystromswitch=dict(
|
||||
|
@ -7,6 +7,8 @@ $(function() {
|
||||
self.printer = parameters[2];
|
||||
|
||||
self.onOffButtonEnabled = ko.observable();
|
||||
self.showShutdownOctopiOption = ko.observable();
|
||||
self.showPowerOffPrintFinishOption = ko.observable();
|
||||
self.mystromswitchPowerValue = document.getElementById("mystromswitchPowerValue")
|
||||
self.mystromswitchEnergyValue = document.getElementById("mystromswitchEnergyValue")
|
||||
|
||||
@ -22,11 +24,46 @@ $(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.automaticShutdownEnabled()) {
|
||||
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") {
|
||||
|
@ -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.') }}</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 switch your mySwitch off after your Print is finished') }}</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">
|
||||
<input type="checkbox" data-bind="enable: loginState.isUser(), checked: automaticShutdownEnabled, visible:showShutdownOctopiOption">
|
||||
{{ _('Shutdown Octoprint after print finishes') }}
|
||||
</label>
|
||||
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="enable: loginState.isUser(), checked: automaticPowerOffEnabled, visible:showPowerOffPrintFinishOption">
|
||||
{{ _('Power Off Relais after print finishes') }}
|
||||
</label>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user