Update plugin.py
Added threadhandling to onStart. Added a .decode('utf-8') to all sock.recv command, translating the content from bytes to a utf-8 string.main
rodzic
dc2372679d
commit
40e5839d7a
15
plugin.py
15
plugin.py
|
@ -90,6 +90,9 @@ class BasePlugin:
|
|||
if (deviceFound == False):
|
||||
Domoticz.Device(Name=hostName, DeviceID=hostName, Unit=len(Devices)+1, Type=241, Subtype=8, Switchtype=7, Image=0).Create()
|
||||
|
||||
# Create/Start update thread
|
||||
self.updateThread = threading.Thread(name="WiZUpdateThread", target=BasePlugin.handleThread, args=(self,))
|
||||
self.updateThread.start()
|
||||
|
||||
def onStop(self):
|
||||
Domoticz.Debug("onStop called")
|
||||
|
@ -132,7 +135,7 @@ class BasePlugin:
|
|||
try:
|
||||
sock.sendto(mJSON, (host, port))
|
||||
|
||||
received = sock.recv(1024)
|
||||
received = sock.recv(1024).decode('utf-8')
|
||||
finally:
|
||||
sock.close()
|
||||
|
||||
|
@ -146,7 +149,7 @@ class BasePlugin:
|
|||
try:
|
||||
sock.sendto(mJSON, (host, port))
|
||||
|
||||
received = sock.recv(1024)
|
||||
received = sock.recv(1024).decode('utf-8')
|
||||
finally:
|
||||
sock.close()
|
||||
|
||||
|
@ -166,7 +169,7 @@ class BasePlugin:
|
|||
try:
|
||||
sock.sendto(mJSON, (host, port))
|
||||
|
||||
received = sock.recv(1024)
|
||||
received = sock.recv(1024).decode('utf-8')
|
||||
finally:
|
||||
sock.close()
|
||||
|
||||
|
@ -182,7 +185,7 @@ class BasePlugin:
|
|||
try:
|
||||
sock.sendto(mJSON, (host, port))
|
||||
|
||||
received = sock.recv(1024)
|
||||
received = sock.recv(1024).decode('utf-8')
|
||||
finally:
|
||||
sock.close()
|
||||
|
||||
|
@ -206,7 +209,7 @@ class BasePlugin:
|
|||
# If it hasn't been at least 1 minute (corrected for ~2s runtime) since last update, skip it
|
||||
if time.time() - self.last_update < 58:
|
||||
return
|
||||
self.startup = False
|
||||
|
||||
# Create/Start update thread
|
||||
self.updateThread = threading.Thread(name="WiZUpdateThread", target=BasePlugin.handleThread, args=(self,))
|
||||
self.updateThread.start()
|
||||
|
@ -250,7 +253,7 @@ class BasePlugin:
|
|||
try:
|
||||
sock.sendto(mJSON, (host, port))
|
||||
|
||||
received = sock.recv(1024)
|
||||
received = sock.recv(1024).decode('utf-8')
|
||||
finally:
|
||||
sock.close()
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue