#9 Relais ausschalten wenn Octoprint heruntergefahren wird

#7 Relais einschalten wenn Octoprint gestartet wurde

Api call fix
This commit is contained in:
David Zingg 2019-11-25 19:57:25 +01:00
parent 70355683b2
commit 722c39604e

View File

@ -100,11 +100,11 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
# then sets the the switch to the newState. # then sets the the switch to the newState.
def _powerCycleRelais(self, newState, time): def _powerCycleRelais(self, newState, time):
try: try:
value = '0' value = 'off'
if (newState == True): if (newState == True):
value = '1' value = 'on'
request = requests.post( request = requests.post(
'http://{}/timer'.format(self.ip), json={'mode': value, 'time': time}, timeout=1) 'http://{}/timer'.format(self.ip), params={'mode': value, 'time': time}, timeout=1)
if not request.status_code == 200: if not request.status_code == 200:
self._logger.info("Could not powerCycle Relais, Http Status Code: {}".format(request.status_code)) self._logger.info("Could not powerCycle Relais, Http Status Code: {}".format(request.status_code))
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError: