From 981cfcc2eb439503436573f512c218e1c566d028 Mon Sep 17 00:00:00 2001 From: Sander Lokerse Date: Mon, 6 Jan 2020 17:57:46 +0100 Subject: [PATCH] bug fix for reconnect --- plugin.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugin.py b/plugin.py index 72f94ca..d4e52aa 100644 --- a/plugin.py +++ b/plugin.py @@ -3,14 +3,14 @@ # Author: lokonli # """ - +

Slide by Innovation in Motion


Plugin for Slide by Innovation in Motion.

It uses the Innovation in Motion open API.

- This is beta release 0.1.7.
+ This is beta release 0.1.8.

Configuration

First you have to register via the Slide app. @@ -85,9 +85,9 @@ def onConnect(self, Connection, Status, Description): if (self.access_token == ''): self.authorize() elif len(self.messageQueue) > 0: - Connection.Send(self.messageQueue) + self.slideRequest(self.messageQueue) self.messageQueue = {} - self.getOverview(1) + #self.getOverview(1) else: Domoticz.Log("Failed to connect ("+str(Status)+") to: " + Parameters["Address"]+" with error: "+Description) @@ -223,10 +223,7 @@ def onCommand(self, Unit, Command, Level, Hue): self.slideStop(Devices[Unit].DeviceID, Level/100) def slideRequest(self, sendData, delay=0): - if ((not self.myConn.Connected()) or (self.access_token == '')): - self.messageQueue = sendData - self.myConn.Connect() - else: + if self.myConn.Connected() & (self.access_token != ''): sendData['Headers'] = {'Content-Type': 'application/json', 'Host': 'api.goslide.io', 'Accept': 'application/json', @@ -239,6 +236,9 @@ def slideRequest(self, sendData, delay=0): self._checkMovement=min(self._checkMovement+1,2) if self._checkMovement == 1: self.getOverview(2) + else: + self.messageQueue = sendData + self.myConn.Connect() def setPosition(self, id, level): sendData = {'Verb': 'POST', @@ -282,13 +282,13 @@ def onNotification(self, Name, Subject, Text, Status, Priority, Sound, ImageFile def onDisconnect(self, Connection): Domoticz.Log("onDisconnect called") + self._checkMovement = 0 def onHeartbeat(self): self._tick = self._tick + 1 if self._tick > 3: self._tick = 0 - if self._checkMovement == 0: - self.getOverview(1) + self.getOverview() if self._expiretoken is not None: from datetime import datetime, timezone