Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e7bf0762d3 | ||
|
96fdafb2dc | ||
|
c5d8bbd863 | ||
|
dda93e73d3 | ||
|
96c2e954fa | ||
|
107a7ba9de | ||
|
809369f783 | ||
|
617f21a66e | ||
|
66889083fd | ||
|
1f5efa9c2a | ||
|
284d54ffa0 | ||
|
542a633559 | ||
|
6c208ce10b | ||
|
7d80c84393 | ||
|
b3e53821bb | ||
|
be81f64ec1 | ||
|
ba797fe1cc |
122
.idea/workspace.xml
generated
122
.idea/workspace.xml
generated
@ -3,8 +3,6 @@
|
||||
<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/__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" />
|
||||
@ -49,62 +47,6 @@
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1574193087583</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00048" summary="#14 Einstellungen reorganisieren">
|
||||
<created>1574873809876</created>
|
||||
<option name="number" value="00048" />
|
||||
<option name="presentableId" value="LOCAL-00048" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574873809876</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00049" summary="#14 Einstellungen reorganisieren - Beschreibungen angepasst">
|
||||
<created>1574874286229</created>
|
||||
<option name="number" value="00049" />
|
||||
<option name="presentableId" value="LOCAL-00049" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574874286229</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00050" summary="#15 Beschreibung erstellen">
|
||||
<created>1574876224274</created>
|
||||
<option name="number" value="00050" />
|
||||
<option name="presentableId" value="LOCAL-00050" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574876224274</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00051" summary="#15 Beschreibung erstellen">
|
||||
<created>1574876349466</created>
|
||||
<option name="number" value="00051" />
|
||||
<option name="presentableId" value="LOCAL-00051" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1574876349466</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00052" summary="#16 Codereview Octoprint Plugin Repo">
|
||||
<created>1575192543311</created>
|
||||
<option name="number" value="00052" />
|
||||
<option name="presentableId" value="LOCAL-00052" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1575192543311</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00053" summary="#17 Logging zur Fehleranalyse eingebaut">
|
||||
<created>1578938604039</created>
|
||||
<option name="number" value="00053" />
|
||||
<option name="presentableId" value="LOCAL-00053" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1578938604039</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00054" summary="#17 Logging zur Fehleranalyse eingebaut">
|
||||
<created>1578939868815</created>
|
||||
<option name="number" value="00054" />
|
||||
<option name="presentableId" value="LOCAL-00054" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1578939868816</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00055" summary="#17 Logging zur Fehleranalyse eingebaut">
|
||||
<created>1578940345174</created>
|
||||
<option name="number" value="00055" />
|
||||
<option name="presentableId" value="LOCAL-00055" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1578940345174</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00056" summary="#17 Logging zur Fehleranalyse eingebaut">
|
||||
<created>1578941071143</created>
|
||||
<option name="number" value="00056" />
|
||||
@ -392,7 +334,63 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593630096392</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="97" />
|
||||
<task id="LOCAL-00097" summary="#21 Add PowerOFF when print is finished">
|
||||
<created>1593630227011</created>
|
||||
<option name="number" value="00097" />
|
||||
<option name="presentableId" value="LOCAL-00097" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593630227011</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00098" summary="#24 API Token Support">
|
||||
<created>1593630650365</created>
|
||||
<option name="number" value="00098" />
|
||||
<option name="presentableId" value="LOCAL-00098" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593630650365</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00099" summary="#24 API Token Support">
|
||||
<created>1593631193159</created>
|
||||
<option name="number" value="00099" />
|
||||
<option name="presentableId" value="LOCAL-00099" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593631193159</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00100" summary="#24 API Token Support">
|
||||
<created>1593631506549</created>
|
||||
<option name="number" value="00100" />
|
||||
<option name="presentableId" value="LOCAL-00100" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593631506549</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00101" summary="#24 API Token Support">
|
||||
<created>1593631764282</created>
|
||||
<option name="number" value="00101" />
|
||||
<option name="presentableId" value="LOCAL-00101" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593631764282</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00102" summary="#24 API Token Support">
|
||||
<created>1593632006106</created>
|
||||
<option name="number" value="00102" />
|
||||
<option name="presentableId" value="LOCAL-00102" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593632006106</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00103" summary="#25 Python 3 Compatibility">
|
||||
<created>1593633576198</created>
|
||||
<option name="number" value="00103" />
|
||||
<option name="presentableId" value="LOCAL-00103" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593633576198</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00104" summary="#25 Python 3 Compatibility">
|
||||
<created>1593633696895</created>
|
||||
<option name="number" value="00104" />
|
||||
<option name="presentableId" value="LOCAL-00104" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1593633696895</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="105" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="UnknownFeatures">
|
||||
@ -422,8 +420,6 @@
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<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" />
|
||||
<MESSAGE value="Revert "#6 UI Updates senden und anzeigen" This reverts commit f83d4259" />
|
||||
<MESSAGE value="#6 UI Updates senden und anzeigen" />
|
||||
@ -447,6 +443,8 @@
|
||||
<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" />
|
||||
<MESSAGE value="#24 API Token Support" />
|
||||
<MESSAGE value="#25 Python 3 Compatibility" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="#25 Python 3 Compatibility" />
|
||||
</component>
|
||||
</project>
|
@ -19,6 +19,7 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
|
||||
def __init__(self):
|
||||
self.ip = None
|
||||
self.token = ""
|
||||
self.intervall = 1
|
||||
self.onOffButtonEnabled = False
|
||||
self.powerOnOnStart = False
|
||||
@ -50,6 +51,9 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self.ip = self._settings.get(["ip"])
|
||||
self._logger.debug("ip: %s" % self.ip)
|
||||
|
||||
self.token = self._settings.get(["token"])
|
||||
self._logger.debug("token: %s" % self.token)
|
||||
|
||||
self.intervall = self._settings.get_int(["intervall"])
|
||||
self._logger.debug("intervall: %s" % self.intervall)
|
||||
|
||||
@ -164,7 +168,7 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self._logger.info("Shutting down system with command: {command}".format(command=shutdown_command))
|
||||
try:
|
||||
import sarge
|
||||
p = sarge.run(shutdown_command, async=True)
|
||||
p = sarge.run(shutdown_command, async_=True)
|
||||
except Exception as e:
|
||||
self._logger.exception("Error when shutting down: {error}".format(error=e))
|
||||
return
|
||||
@ -174,7 +178,7 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
try:
|
||||
try:
|
||||
request = requests.get(
|
||||
'http://{}/report'.format(self.ip), timeout=1)
|
||||
'http://{}/report'.format(self.ip), headers={"Token": self.token}, timeout=1)
|
||||
if request.status_code == 200:
|
||||
timestamp = time.time()
|
||||
data = request.json()
|
||||
@ -212,8 +216,11 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
value = '1'
|
||||
while nbRetry < 3:
|
||||
try:
|
||||
headers = {}
|
||||
if self.token is not None and self.token != "":
|
||||
headers = {"Token": self.token}
|
||||
request = requests.get(
|
||||
'http://{}/relay'.format(self.ip), params={'state': value}, timeout=1)
|
||||
'http://{}/relay'.format(self.ip), params={'state': value}, headers=headers, timeout=1)
|
||||
if request.status_code == 200:
|
||||
return
|
||||
else:
|
||||
@ -237,7 +244,8 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self._logger.info("try to send Powercycle Request")
|
||||
self._logger.info('http://{}/timer'.format(self.ip))
|
||||
request = requests.post(
|
||||
'http://{}/timer'.format(self.ip), params={'mode': value, 'time': time}, timeout=1)
|
||||
'http://{}/timer'.format(self.ip), params={'mode': value, 'time': time}, headers={"Token": self.token},
|
||||
timeout=1)
|
||||
if request.status_code == 200:
|
||||
return
|
||||
else:
|
||||
@ -255,7 +263,7 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
while nbRetry < 3:
|
||||
try:
|
||||
request = requests.get(
|
||||
'http://{}/toggle'.format(self.ip), timeout=1)
|
||||
'http://{}/toggle'.format(self.ip), headers={"Token": self.token}, timeout=1)
|
||||
if request.status_code == 200:
|
||||
return
|
||||
else:
|
||||
@ -345,13 +353,16 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self.lastShutdown = False
|
||||
self.lastPowerOff = False
|
||||
self.rememberShutdown = False
|
||||
if current <= 5:
|
||||
self.token = ""
|
||||
|
||||
def get_settings_version(self):
|
||||
return 5
|
||||
return 6
|
||||
|
||||
def get_settings_defaults(self):
|
||||
return dict(
|
||||
ip=None,
|
||||
token="",
|
||||
intervall=1,
|
||||
onOffButtonEnabled=False,
|
||||
powerOnOnStart=False,
|
||||
@ -367,7 +378,7 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
|
||||
def get_settings_restricted_paths(self):
|
||||
return dict(admin=[
|
||||
['ip']
|
||||
['ip', 'token']
|
||||
])
|
||||
|
||||
def on_settings_save(self, data):
|
||||
@ -418,6 +429,7 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
|
||||
|
||||
|
||||
__plugin_name__ = "MyStrom Switch"
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
|
||||
|
||||
def __plugin_load__():
|
||||
|
@ -7,6 +7,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('API Token') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: settings.plugins.mystromswitch.token">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">Refresh Intervall</label>
|
||||
<div class="controls">
|
||||
|
@ -4,11 +4,11 @@
|
||||
<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') }}
|
||||
{{ _('Shutdown Octoprint after print finished') }}
|
||||
</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') }}
|
||||
{{ _('Power Off Relais after print finished') }}
|
||||
</label>
|
||||
</div>
|
||||
|
6
setup.py
6
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.4"
|
||||
plugin_version = "1.2.0"
|
||||
|
||||
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
|
||||
# module
|
||||
@ -57,7 +57,9 @@ plugin_ignored_packages = []
|
||||
# Example:
|
||||
# plugin_requires = ["someDependency==dev"]
|
||||
# additional_setup_parameters = {"dependency_links": ["https://github.com/someUser/someRepo/archive/master.zip#egg=someDependency-dev"]}
|
||||
additional_setup_parameters = {}
|
||||
additional_setup_parameters = {
|
||||
"use_2to3": True,
|
||||
}
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user