From 79005e3b33e03d29cab0754873ea5d6132fe28c7 Mon Sep 17 00:00:00 2001 From: Smanar Date: Tue, 5 Feb 2019 17:08:28 +0100 Subject: [PATCH 1/6] Update plugin.py --- plugin.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plugin.py b/plugin.py index 91cfd39..e888beb 100644 --- a/plugin.py +++ b/plugin.py @@ -59,7 +59,9 @@ #https://stackoverflow.com/questions/32436864/raw-post-request-with-json-in-body class BasePlugin: + enabled = False + def __init__(self): self.Devices = {} self.SelectorSwitch = {} #IEEE,update,model @@ -82,6 +84,13 @@ def onStart(self): #CreateDevice('1234','1234','ZHAWater') self.bug = Parameters["Mode2"] + #Check Domoticz IP + if Parameters["Address"] != '127.0.0.1' and Parameters["Address"] != 'localhost': + global DOMOTICZ_IP + DOMOTICZ_IP = get_ip() + Domoticz.Log("Your haven't use 127.0.0.1 as IP, so I suppose deCONZ and Domoticz aren't on same machine") + Domoticz.Log("Taking " + DOMOTICZ_IP + " as Domoticz IP") + if Parameters["Mode3"] != "0": Domoticz.Debugging(int(Parameters["Mode3"])) #DumpConfigToLog() @@ -801,6 +810,19 @@ def GetDeviceIEEE(id,type): #***************************************************************************************************** +def get_ip(): + import socket + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + try: + # doesn't even have to be reachable + s.connect(('10.255.255.255', 1)) + IP = s.getsockname()[0] + except: + IP = '127.0.0.1' + finally: + s.close() + return IP + def GetDomoDeviceInfo(IEEE): for x in Devices: if Devices[x].DeviceID == str(IEEE) : From 3479abf361874df83d1bc3759d95ba6d0cb1657b Mon Sep 17 00:00:00 2001 From: Smanar Date: Tue, 26 Feb 2019 19:05:59 +0100 Subject: [PATCH 2/6] Update plugin.py --- plugin.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugin.py b/plugin.py index e888beb..18e97c7 100644 --- a/plugin.py +++ b/plugin.py @@ -13,7 +13,7 @@

Supported Devices