Skip to content

Commit

Permalink
Fixing FPM dependency list, Dummy device value counter, DomoMQTT reco…
Browse files Browse the repository at this point in the history
…nnection
  • Loading branch information
enesbcs committed Mar 19, 2020
1 parent 5b98e26 commit 0ffa093
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 65 deletions.
120 changes: 61 additions & 59 deletions _C002_DomoMQTT.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,72 +219,73 @@ def webform_save(self,params): # process settings post reply
return True

def on_message(self, msg):
msg2 = msg.payload.decode('utf-8')
list = []
if ('{' in msg2):
try:
list = json.loads(msg2)
except Exception as e:
misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"JSON decode error:"+str(e)+str(msg2))
list = []
if (list) and (len(list)>0):
try:
if list['Type'] == "Scene": # not interested in scenes..
return False
except:
pass
devidx = -1
nvalue = "0"
svalue = ""
decodeerr = False
tval = [-1,-1,-1,-1]
try:
devidx = str(list['idx']).strip()
except:
if self.enabled:
msg2 = msg.payload.decode('utf-8')
list = []
if ('{' in msg2):
try:
list = json.loads(msg2)
except Exception as e:
misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"JSON decode error:"+str(e)+str(msg2))
list = []
if (list) and (len(list)>0):
try:
if list['Type'] == "Scene": # not interested in scenes..
return False
except:
pass
devidx = -1
decodeerr = True
try:
nvalue = str(list['nvalue']).strip()
except:
nvalue = "0"
decodeerr = True
try:
svalue = str(list['svalue']).strip()
except:
svalue = ""
if (';' in svalue):
tval = svalue.split(';')
tval2 = []
for x in range(1,4):
sval = ""
decodeerr = False
tval = [-1,-1,-1,-1]
try:
devidx = str(list['idx']).strip()
except:
devidx = -1
decodeerr = True
try:
nvalue = str(list['nvalue']).strip()
except:
nvalue = "0"
decodeerr = True
try:
sval = str(list['svalue'+str(x)]).strip()
svalue = str(list['svalue']).strip()
except:
svalue = ""
if (';' in svalue):
tval = svalue.split(';')
tval2 = []
for x in range(1,4):
sval = ""
if sval!="":
tval2.append(sval)
if len(tval2)==1 and svalue=="":
svalue=tval2[0]
else:
for y in range(len(tval2)):
matches = re.findall('[0-9]', tval2[y])
if len(matches) > 0:
tval[y] = tval2[y]
forcesval1 = False
try:
if ("Selector" in list['switchType']) or ("Dimmer" in list['switchType']):
forcesval1 = True
except:
try:
sval = str(list['svalue'+str(x)]).strip()
except:
sval = ""
if sval!="":
tval2.append(sval)
if len(tval2)==1 and svalue=="":
svalue=tval2[0]
else:
for y in range(len(tval2)):
matches = re.findall('[0-9]', tval2[y])
if len(matches) > 0:
tval[y] = tval2[y]
forcesval1 = False
if (tval[0] == -1) or (tval[0] == ""):
if (float(nvalue)==0 and svalue.lower()!="off" and svalue!="") or (forcesval1):
tval[0] = str(svalue)
try:
if ("Selector" in list['switchType']) or ("Dimmer" in list['switchType']):
forcesval1 = True
except:
forcesval1 = False
if (tval[0] == -1) or (tval[0] == ""):
if (float(nvalue)==0 and svalue.lower()!="off" and svalue!="") or (forcesval1):
tval[0] = str(svalue)
else:
tval[0] = str(nvalue)
if decodeerr:
misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"JSON decode error: "+msg2)
else:
tval[0] = str(nvalue)
if decodeerr:
misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"JSON decode error: "+msg2)
else:
self.onmsgcallbackfunc(self.controllerindex,devidx,tval)
self.onmsgcallbackfunc(self.controllerindex,devidx,tval)

def senddata(self,idx,sensortype,value,userssi=-1,usebattery=-1,tasknum=-1,changedvalue=-1):
if self.enabled:
Expand Down Expand Up @@ -330,7 +331,8 @@ def senddata(self,idx,sensortype,value,userssi=-1,usebattery=-1,tasknum=-1,chang
misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"MQTT idx error, sending failed.")
else:
misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,"MQTT not connected, sending failed.")
if ((time.time()-self.lastreconnect)>30) and (self.connectinprogress==0):
if ((time.time()-self.lastreconnect)>30):
# if ((time.time()-self.lastreconnect)>30) and (self.connectinprogress==0):
self.connect()

def on_connect(self):
Expand Down
14 changes: 14 additions & 0 deletions _P033_Dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,23 @@ def plugin_receivedata(self,data):
self.set_value(x+1,data[x],False)
# print("Data received:",data)

def getvaluecount(self):
if self.vtype in [rpieGlobals.SENSOR_TYPE_SINGLE,rpieGlobals.SENSOR_TYPE_SWITCH,rpieGlobals.SENSOR_TYPE_DIMMER,rpieGlobals.SENSOR_TYPE_LONG,rpieGlobals.SENSOR_TYPE_WIND]:
return 1
elif self.vtype in [rpieGlobals.SENSOR_TYPE_TEMP_HUM,rpieGlobals.SENSOR_TYPE_TEMP_BARO,rpieGlobals.SENSOR_TYPE_DUAL]:
return 2
elif self.vtype in [rpieGlobals.SENSOR_TYPE_TEMP_HUM_BARO,rpieGlobals.SENSOR_TYPE_TRIPLE]:
return 3
elif self.vtype == rpieGlobals.SENSOR_TYPE_QUAD:
return 4
else:
return 0

def plugin_init(self,enableplugin=None):
plugin.PluginProto.plugin_init(self,enableplugin)
if self.taskdevicepluginconfig[0]>0:
self.vtype = self.taskdevicepluginconfig[0]
self.valuecount = self.getvaluecount()

def webform_load(self): # create html page for settings
choice = self.taskdevicepluginconfig[0]
Expand All @@ -57,6 +70,7 @@ def webform_save(self,params): # process settings post reply
if par1:
self.taskdevicepluginconfig[0] = int(par1)
self.vtype = self.taskdevicepluginconfig[0]
self.valuecount = self.getvaluecount()
return True

def plugin_read(self): # deal with data processing at specified time interval
Expand Down
6 changes: 2 additions & 4 deletions _P205_EPD.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ def webform_load(self): # create html page for settings
options = ['1.54" (200x200)','1.54"B (200x200)','1.54"C (150x150)','2.13" (250x122)','2.13"B (212x104)','2.7" (264x176)','2.7"B (264x176)','2.9" (296x128)','2.9"B (296x128)','4.2" (400x300)','4.2"B (400x300)','7.5" (800x480)','7.5"B (800x480)']
optionvalues = ["154","154b","154c","213","213b","270","270b","290","290b","420","420b","750","750b"]
webserver.addHtml("<tr><td>Display type:<td>")
webserver.addSelector_Head("p205_type",True)
webserver.addSelector_Head("p205_type",False)
for d in range(len(options)):
webserver.addSelector_Item(options[d],optionvalues[d],(choice1==optionvalues[d]),False)
webserver.addSelector_Item(options[d],optionvalues[d],(str(choice1)==str(optionvalues[d])),False)
webserver.addSelector_Foot()
webserver.addFormNote("Enable <a href='pinout'>SPI-0</a> first!")
webserver.addFormNote("Hardware connection (OLED => Raspberry Pi)<br>VCC->3.3V, GND->GND, SDI->MOSI, SCLK->SCLK, CS-> GPIO8/CE0, D/C->GPIO25, RES->GPIO17, BUSY->GPIO2")
Expand Down Expand Up @@ -245,8 +245,6 @@ def plugin_exit(self):

def webform_save(self,params): # process settings post reply
par = webserver.arg("p205_type",params)
if par == "":
par = 0
self.taskdevicepluginconfig[0] = str(par)

par = webserver.arg("p205_rotate",params)
Expand Down
2 changes: 1 addition & 1 deletion plugindeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@
"modules":["i2c","rtimu"]},
{"pluginid": "208", #PFM
"supported_os_level": [1,2,10],
"modules":["pyserial","pfm"]},
"modules":["pyserial","pfm","pil"]},
{"pluginid": "209", # AMG
"supported_os_level": [10],
"modules":["i2c","amg","pil"]},
Expand Down
2 changes: 1 addition & 1 deletion rpieGlobals.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Copyright (C) 2018-2020 by Alexander Nagy - https://bitekmindenhol.blog.hu/
#
PROGNAME = "RPIEasy"
BUILD = 20076
BUILD = 20079
PROGVER = str(BUILD)[:1]+"."+str(BUILD)[1:2]+"."+str(BUILD)[2:]

gpMenu = []
Expand Down

0 comments on commit 0ffa093

Please sign in to comment.