piBeacon Error after upgrade to 2022.160.16

Sam
Posts: 34
Joined: Mon Aug 22, 2016 5:51 am

piBeacon Error after upgrade to 2022.160.16

Post by Sam »

Hi,
I get an error after upgrade piBeacon-plugin to 2022.160.16, Indigo version 2022.1.2.

piBeacon Error 'local variable 'xx' referenced before assignment'
setGroupStatus @line 1739: 'triggerGroup[xx]["oneHome"] = False'


I only use the plugin for sensors. The Pi:s location is 21-26.

Any ideas?
Thanks in advance.. /Sam
johnpolasek
Posts: 918
Joined: Fri Aug 05, 2011 2:01 pm
Location: Aggieland, Texas

Re: piBeacon Error after upgrade to 2022.160.16

Post by johnpolasek »

I just noticed that I am getting it as well (almost never check the log)... it does not seem to be affecting the execution though.
johnpolasek
Posts: 918
Joined: Fri Aug 05, 2011 2:01 pm
Location: Aggieland, Texas

Re: piBeacon Error after upgrade to 2022.160.16

Post by johnpolasek »

Finally got a chance to look at the actual code; the relevant portions (still present in 2022.160.19) is and the failure occurs in the elif apparently for nonBLE devices that are not sensors:

Code: Select all

				if dev.deviceTypeId  in ["rPI","rPI-Sensor","beacon","BLEconnect"]:
					for xx in _GlobalConst_groupListDef:
						if xx == "SENSOR": continue
						
						if dev.states["note"].lower().find(xx.lower()) >-1:
							if dev.states["status"] == "up":
								self.groupStatusList[xx]["nHome"]	  +=1
								triggerGroup[xx]["oneHome"]					= True
							else:
								self.groupStatusList[xx]["nAway"]	  +=1
								triggerGroup[xx]["oneHome"]					= False
						okList.append("{}".format(dev.id))

				elif dev.pluginProps.get("isSensorDevice",False):
								dt = (datetime.datetime.now() - dev.lastChanged).seconds
								up = dt < self.awayWhenNochangeInSeconds
								#self.indiLOG.log(10,"setGroupStatus1 {}, dt:{} , up:{}, self.awayWhenNochangeInSeconds:{}".format(dev.name, dt, up, self.awayWhenNochangeInSeconds))
								if up:
									self.groupStatusList["SENSOR"]["nHome"]	  +=1
									triggerGroup[xx]["oneHome"]					= True
								else:
									triggerGroup[xx]["oneHome"]					= False
									self.groupStatusList["SENSOR"]["nAway"]	  +=1
								okList.append("{}".format(dev.id))

and since I don't know what kind of non sensor, non BLE devices would have "devlastChanged" states, I can't be sure whether the entire elif should be removed OR another

Code: Select all

					for xx in _GlobalConst_groupListDef:
should be added just under the
#self.indiLOG.log(10,"setGroupStatus1 {}, dt:{} , up:{}, self.awayWhenNochangeInSeconds:{}".format(dev.name, dt, up, self.awayWhenNochangeInSeconds))

and I don't want to break anything by tweaking the code.
Post Reply

Return to “piBeacon”