piBeacon: 3- presence monitoring download

Posted on
Mon Oct 10, 2022 3:34 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Code: Select all
Added features / changes in v2022.151.14@ 2022-10-10
===================================================
   
1. made switchbot operation work more smoothly, timing, error recovery ..

2. added an action that stops any switchbot actions pending on an rpi
   eg when you got multiple triggers and the first responding action worked, no need to have the action executed many times
     like when the door is open no need to trigger open magnet n times more 

3. added option in the switchbot action to have a sensor(BLE only) on one RPi that triggers
   a switchbot action on another (or same) rpi w/o indigo being up.
   the sensor RPI will send a command to the switchbot rpi through sftp
   eg a BLE sensor with button press signal (eg ibs04-button) can be received on rpi-1,
     rpi-1 sends a press/on command to rpi-2 for a switchbot to move the arm.
     Indigo is not involved.
     This is useful if the button is out of reach of the rpi where the switchbot is managed and indigo is down
   To setup create an action in indigo "Set switchbot relay to on/off or pulses.."

4. added option to have ON/OFF sensors stay longer ON for xx secs. Some of these sensors go from on-off within 0.2 secs.
   This gives the indigo dev state more time to show the ON state

5. added option for on/off sensor to show arbitrary text in display like moving / stopped etc.

6. added support for musegear finder beacons (regular, mini, wallet). They can be purchased from amazon in Europe
   They can be beeped (to find its location) and the plugin gets the battery level.
   They have the itrack software similar to Rinex, Njoii, Spotypal etc, which can be bought in the USA

6.1 added support for NUT-pro beacon (with beep command and battery read)

7. Added a virtual device "garage door". (similar to the virtual device Car)
   This dev type tracks the states of a garage door:
   Closed, opening, stopped, open, closing, position
   This device needs 3 on/off magnet sensors(eg switchbot connect) and several magnets
   The sensors are positioned at: at closed position, open position; on the moving door
   Magnets are at:
   - One on door, moving between open sensor and closed sensor to indicate open/closed.
   - Several magnets on the rail where the sensor on the door moves by and gets triggered by the magnets
     the magnets should be placed >1 "second" apart, something like 20-30 cm
     But the speed of the door changes, eg at close it slows down. There the magnets should be closer together
     But not too close as the sensor might not be ready for the next trigger
     With these magnets the plugin counts the magnets passed and calculates the current position (0-100%)

   The dev states used for the sensors are onoffState and one that indicates the moving changes
   eg lastMotion of the sensor that is mounted on the door.
 
8. for ADS-1115 ADC added samples per second option, removed un-used code and made differential measurement (eg input0 -input1) 
   a single measurement instead of 2 single and then subtract

Karl

Posted on
Sat Dec 03, 2022 1:47 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Code: Select all
1. made all major py programs on rpi run under python2 or python3
   py2 vs py3 can be selected in config for all rpi or left to each individual rpi
   in rpi dev edit the py version can be selected if in config it is set to individual rpi
    py3 requires pi-os >=10 (stretch ssd) to work properly
    On  pi-os 11 =  bullseye  python 2 is not fully supported anymore, the rpi  will automatically switch to py3 usage and
          will ignore any p2/py settings

   All required libs are installed by the plugin system (ie neopixel, sensor libs etc, see checkForInclude-py2/py3.py on the rpi
       eg   libs: io, hcidump, smbus2 pexpect, expect, ... , syntax changes:  / vs // (int//float), print /;print() etc
       the devil is in the details: 
        calling py3 modules can be different from py2 eg to make them "unlinked" /E option has to be used and many more "little" changes
        binary socket data transfer is different

   ==> this was a major pice of work <== 

   for ssd updates:  I suggest that you do
     1. updates apps and sys:
      sudo apt update
      sudo apt upgrade -y   ( or a more thorough, but mostly not needed:  sudo apt dist-upgrade  -y )
     2. cleanup:
      sudo apt autoremove
      sudo apt clean
     3. then reboot
     every 2 months to keep the security patches up to date

2. added option to detect new beacons looking at the manufacturer name in the BLE message. Some beacons send that info in their BLE msg
   some beacons like from NUT or april have several tag definitions, with this option you can catch them all
   the plugin will then find the proper individual tag that works for the soecific beacon type ie beep, battery, ..
   to use this: select in "accept new beacons" menu item

3. added TOF sensor vl503l1xDistance. It has range up to 4 m
   you now can use several of vl503l1x or vl503l0x tof sensors on one RPI

3. several smaller fixes and improvements

4. some menu fixes


Also a new SSD w pi-os-11 (bullseye) has been posted @ https://forums.indigodomo.com/viewtopic.php?f=187&t=15152 (first post in this thread)

Karl

Posted on
Tue Dec 06, 2022 3:27 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Added features / changes in v2022.160.15@ 2022-12-08
===================================================

1. fixed issues with py3 ie for BLE connect devices like xiaomi soil meter, Temp&Humidity sensors...

Posted on
Wed Dec 14, 2022 4:41 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Added features / changes in v2022.160.16@ 2022-12-14
===================================================

1. improved switchbot response time by ~ 0.5 secs

Posted on
Sat Jan 14, 2023 3:29 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Code: Select all
Added features / changes in v2022.160.19@ 2023-01-14
===================================================
   
1. added option for each pi to ignore known_hosts for ssh and sftp to rpi
   this is to avoid needing to modify knownhostsfile incase of changes in ip number etc.

2. fixed pmairquality py2 -> py3 bug ( concatenate strings / bytes)
   sensor now only works with py3 !!

3. bug for sensor INPUTpulse, device statename was wrong (typo), fixed (bug was added in py2->py3 conversion (u"xxx" changed to  "uxxx" instead of "xxx"))


this should finalizes the py2 -> py conversion

Karl

Posted on
Tue Jan 24, 2023 7:48 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Added features / changes in v2022.160.23@ 2023-01-24
===================================================

1. added feature kight rider for neopixel (swinging band of leds left right )

2. delay start time for gpio and i2c-relay: now checks ALSO during delay before any action if it should be cancelled
in general you can remove the previous command by issuing a new one
eg send 10 pulses 1 sec each and then an off after 5 secs, only 5 pulses will be done
before this it was only checking during the active part if it should stop.
... this matters only if you use a delay at start parameter

3. bug fix: File "plugin.py", line 6052, in filterNeopixeldevices
it is a format error

4. bug fix in config edit

5. some menu changes


Karl

Posted on
Wed Jan 25, 2023 6:25 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Added features / changes in v2022.160.25@ 2023-01-25
===================================================

1. fixed bug introduced in v ..19, error setting up new RPI

Posted on
Sat Feb 11, 2023 6:20 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Code: Select all
Added features / changes in v2022.161.52@ 2023-02-11
===================================================
   
This version now offers to directly show distance sensor information on attached neopixel devices on the rpi
It does not have to go through indigo.
you configure
a) the neopixel output device in indigo, set the pyhical parameters - # of LED etc, connect teh device to the RPI
b) configure the distance sensor in indigo (any of the supported models3 work) and connect the distance sensor to the same RPI
   configure the neopixel commands (see menu/indigo/pibeacon/print various info.. for examples) in the distance sensor device
   like: distance limits for versyshort, short, medium, long verylong and stopped
   then the distance sensor will send these commands directly to the neopixel.py program on the same RPI
   when it reaches the limits set, eg stop, verylong distance ...
   you can have the neopixel device show simple colored LEDS R/B/B or blinking or "knightrider" type
   the neopixel indigo device status will also show the commands send to it on the rpi


1. improved trigger for distance sensors (how often new values get send to indigo)
   now it is trigger:  if  (delta absolut > DA and  delta% > D% ) or delta time > 30 secs : send to indigo
    DA, D% = set in sensor edit
    added dev state trigger to distance sensor
    with these setting you can now fine tune trigger sensitivity
    there is also the option for local execution of any script on the rpi
        eg set LED lights  r/g/b if distance is gt or lt xx... must have neopixel device attached on that RPI
        do menu /Print various info to logfile../Print Distance action help to logfile/    or click on help button in distance sensors

2. fixed status column method. only ON/off was used. now if detailed colors are set then they are used, on/off only if details not defined.
   added data field "trigger" send to indigo if there is an action trigger event (Short, Med, Long, Stop, Dist, Time )
   you can trigger on that device state["trigger"] == "your choice here"
   added option to have neopixel return command type received. you must supply "ststus":"yourtext" to the command send to neopixel, eg:
   echo '{"repeat":"1","status":"Long","command":[{"type":"sLine","display":"wait","position":[0,12,0,0,0]},{"type":"sLine","display":"immediate","position":[0,12,0,100,0]}]}' > temp/neopixel.inp
   would set neopixle device status to "Long"
   added states:
      trigger      --> Dist,Time, distanceEvent
      distanceEvent --> VeryLong,Long,Medium,Short,VeryShort,Stop
 

3. added line type sLine for neopixel, same as "line" (2D) but just 1D, reduces the number or parameters to be specified
4. reduced key length for specifc commands (long form still works)
   sLine —> sl
   line —> l
   resetinitial -> res
   knightrider -> kr
   position -> p
   spoint -> sp
   rectangle —> r
   and
   repeat:1 is default, no need to add to command
   display:"immediate" is default, no need to add to command

5. added option to show distance as thermometer type on neopixel, executed locally on RPI
6. added action to pause any distance sensor. it simply "sleeps"  in the execution loop for the specified time
   this is useful if you have local display/neopixel commands and want to pause them due to eg garage door open...


and a lot of thanks go to John in the netherlands who patiently helped to debug the code.

Karl

Posted on
Tue Feb 21, 2023 11:17 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Added features / changes in v2022.162.53@ 2023-02-21
===================================================

1. added color knight rider option for neopixel: you can show swinging LEDS w different colors on a neopixel string
for detail see menu/print various info to logfile /print distance actions ..

2. fixed : undervoltage reporting, vcgencmd cmd has moved in new raspian image to /usr/bin/vcgencmd
it will check the old and new position of executable.

Posted on
Sun Mar 12, 2023 11:30 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Code: Select all
Added features / changes in v2022.163.56@ 2023-03-13
==================================================

1. added new dev type iTrack (Rinex,Vozni,Njoii,Musegear) BUTTON.
   iTrack types are regular beacon that can deliver battery info, can be beeped and can trigger any indigo action with the button press
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !!!!! FINALLY an ALL IN ONE device - after 8 years with this plugin: beacon position,  Battery level, beep, and action button. !!!!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   1. get a iTrack beacon, (amazon germany euro 25 for Musegear),
   2. click on the button for 5 secs to enable it
   3. add the eg musegear beacon to indigo:  menu/ accept/reject new beacons, select ITrack: Rinex,Vozni,Njoii,Musegear On Button as beacon type;  then a new beacon will be created within 30 secs. Copy the mac number
   4. add a new device type "BLE-iTrack (Musegear,Rinex,..) On Button", paste the mac number. Select which rpi should track the button sensor button On/off ( this is not the beacon data!!, that will continue as is)
   5. then you can press the button (5 secs) on the beacon and the status will go to "true/On" for 30 secs, then to false/off again, use this as a trigger to eg open door...

 =====
 now you can with this beacon type:
   1. know in which room the beacon is (requires one rpi per room, state= closest RPI ), or if it is away
      or if it moves - change in distances states, or dev state position of beacon
   2. you can see the battery level in the beacon dev state
   3. you can in indigo menu/action beep the beacon to find it
   4. press the button on the beacon and you can trigger any action in indigo
 ===== 

   The smallest version is 4mm x 35mm x 25mm
   There are regular, wallet, mini, rechargeable versions

2. added support for the new indigo 2022.2 http api w bearer id.
   the old http restfull api does not work under indigo 2022.2
   the new version will only work if your RPI is running bullseye or later and everything with py3
   BUT it will create a lot of logfile entries each time the rpis send data to indigo. with the old version there was a patch you could use to disable the logging.

   I strongly recommend to use the default socket communication rpi to indigo -  you select it in config.
   that works with all versions and combinations

3. worked on "fastDown" option for beacons. It is now stable down to 10 secs.
   Normal mode beacons take about 90 secs to go "down"/ off. They expire due to no signal receives from rpis in indigo
   In fastdown mode the rpi sends a signal (down rssi=-999) when it has not received a signal from the beacon for xx secs.
   After receiving a down signal the plugin sets the state to down - after all rpis have send the down signal.
   This works for fastDown times down to 15 secs and if you have several RPi that "see" the beacon down to 10 secs.
   this will create a lot more traffic from the RPIs to the plugin:   
     For fastDown time = 10 secs one message every 5 secs from each RPI for each of these fastDown beacons, so for 5 beacons and 5 rpi up to 5 message per second from rpis to indigo
     Indigo is able to handle this if you have a good sized mac -  my mac mini M1 2020 has 14% total load (and 10% pibeacon plugin load on one proc.) with that config with many other plugins running

4. fixed variable counters for devices Up/down for groups with beacon members (the group BEACON was correct). the other groups (Family ..) worked correctly for sensor devcies
   added 2 more optional groups you can use to count devices home/away, default are Family, guest, other1.. other5. If not assigned a name in config, the variables are not created.
   You need to edit a device and check the groups name you want it to be come a member of. Then the variables GroupName_Away and _Home counters will be updated

5. fixed: piBeacon Error 'local variable 'xx' referenced before assignment'

Posted on
Wed Mar 15, 2023 3:44 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Added features / changes in v2022.163.59@ 2023-03-15
==================================================

1. fixed some issues with new iTrack beacons.

Posted on
Tue Apr 18, 2023 2:51 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Code: Select all
Added features / changes in v2022.165.69@ 2023-04-01
==================================================


1. added support for thermobeacons. They are bluetooth temperature & humidity sensors w and w/o display
   they are sold under various brands like sensorBlue etc.

2. added some states to itrack button:
   state of beacon
   current and  last off event time stamp

3. for BLE-sensor devcies added pluginProp beaconDevId that is the corresponding beacon device to the sensor device
    eg for on off BLE sensor device like iTrack it has a corresponding beacon device that has the same MAC number
    this can be used in triggers etc to find which device triggered

4. added variables:
    lastButtonOnDevId         this is the device id of an on/off BLE sensor device that was off-> on
    lastButtonOnBeaconDevId   this is the corresponding dev id for the beacon device
    this can be used eg after receiving an On event from an iTrack sensor on/off device to send a message to the beacon to make it beep or get battery level
    like so in an action script:

############################################################################################################################################################
############################################################################################################################################################
############################################################################################################################################################
# this action:
# calls actiongroup to open door, but not more often than every 10 secs
# then send get battery command to rpi # 999 (closeset)  for corresponding beacon that triggered the button
# it has 3 lists of triggering devices, will do something else for group B, C
#


## this is the list of on/off button BLE devices that could have triggerd this action
# we have 2 lists, different actions for A and B
# you can use names or variables
devListA = ["button-musegear-1", "button-musegear-2", ]
devListB = [ "button-musegear-H",  ]
devListC = [ "button2"]

# if you want to use Ids
#devListA = [123,23524,56745,457457 ]
#devListB = [2453456,6475789,231234124]
#devListC = [2453456,6475789,231234124]

beep = True
getBattery = True

import time

# is everything running?:
try:
   plug = indigo.server.getPlugin("com.karlwachs.piBeacon")
except:
   indigo.server.log("plugin not running")
   return
if not plug.isEnabled():
   indigo.server.log("plugin not running")
   return

# get device that triggered this action:
try:
   triggerDevId = indigo.variables["lastButtonOnDevId"].value
   triggerDev = indigo.devices[int(triggerDevId)]
except:
   indigo.server.log("variable lastButtonOnDevId:{}  not correct".format(triggerDevId))
   return

if type(devListA[0]) == type(1):
   useTag = triggerDev.id
else:
   useTag = triggerDev.name


if useTag not in devListA + devListB + devListC:
   indigo.server.log("trigger device {} not in defined groups".format(triggerDev.name))
   return


# action for A list
if useTag in devListA or useTag in devListB:
   # get / setup last time stamp variable of last action for this action
   try:
      var = indigo.variables["lastDoorOpen"].value
   except:    
      indigo.variable.create("lastDoorOpen","0")
      var = indigo.variables["lastDoorOpen"].value
   lastOpen = float(var)

   if time.time() - lastOpen > 10: # too early for this action?
      indigo.actionGroup.execute("press door unlock button action")  # use your action here
      indigo.variable.updateValue("lastDoorOpen", value="{:.0f}".format(time.time())) # remember last action in variable
   else: # skip
      indigo.server.log("skipping open door, last open door event was {:.0f} secs ago".format(time.time()-lastOpen))
      return

   # now next action, beep and get battery level
   beacondevID = indigo.variables["lastButtonOnBeaconDevId"].value
   try:
      beaconDev = indigo.devices[int(beacondevID)]
   except:
      indigo.server.log("beacon {}  not defined in indigo".format(beacondevID))
      return

   if beep:   # server =-1: use closest, beepTime =-1: only beep off, >0 = beep
      plug.executeAction("beepBeacon", props ={"piServerNumber":"-1","selectbeacon": beacondevID,"beepTime":"1"})
      indigo.server.log("sending beep to dev:{}".format(beaconDev.name))
   if getBattery:   # must "set get battery mode" to interactive in config                     
      indigo.server.log("sending get battery to dev:{}".format(beaconDev.name))
      # all = use closest RPI, startAtDateTime set delay of start for command, 0 should work fine
      plug.executeAction("getONEiBeaconParameters", props ={"piServerNumber":"all","devIdOfBeacon": beacondevID, "startAtDateTime":0})

# action for C list do beep and then 9 sec ater get battery level
if useTag in devListC:
      beacondevID = indigo.variables["lastButtonOnBeaconDevId"].value
      beaconDev = indigo.devices[int(beacondevID)]
      plug.executeAction("beepBeacon", props ={"piServerNumber":"-1","selectbeacon": beacondevID,"beepTime":"1"})
      plug.executeAction("getONEiBeaconParameters", props ={"piServerNumber":"all","devIdOfBeacon": beacondevID, "startAtDateTime":0})

############################################################################################################################################################
############################################################################################################################################################
############################################################################################################################################################


Posted on
Mon May 08, 2023 8:14 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Added features / changes in v2022.166.70 @ 2023-05-06
==================================================

1. maintenance release
small bugs fixed, (format statements, beeping beacons ...)

2. added menu item to clean up ~/.ssh/know_hostsfile
if you have issues with ssh loging in to your RPIS, you can now reset the entries in ~/.ssh/konwn_hosts file

Posted on
Tue May 09, 2023 12:55 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Added features / changes in v2022.167.71 @ 2023-05-09
==================================================

1. added cut off values for distance sensors min/ max, added state distanceRaw (unmodified measured value)

Posted on
Sat Jun 03, 2023 4:31 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

Added features / changes in v2022.167.74 @ 2023-06-03
==================================================

1. bugfix:
"plugin.py", line 20656, in actionControlSensor type: name 'address' is not defined
2. added option to not print test logging at startup, set in config/ debug section

Who is online

Users browsing this forum: No registered users and 2 guests