piBeacon: 3- presence monitoring download

Posted on
Fri Jan 13, 2017 5:01 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted v 7-37-38

fixed:
in Line '5889' has error=''key TxPower not found in dict'' in version 7.37.37.

Should also fix BLE not updating.

Don't know how this thing/bug/code got there. Must have been sometime after midnight... :roll:


Karl

Posted on
Sat Jan 14, 2017 6:01 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted v 7-37-39

fixed/ improved:

for CAR type devices: added some timers and more checks to make sure states change in the right sequence
--> leaving only after > 60 seconds home
--> arriving only after > 120 seconds away from home

Fixed multiple keys away/ home:
Logic: if n keys are defined, all n keys must be home to set Keys = home: if ONE key is gone the car ( and batteryBeacon and USBbeacon are off) is away.
This means that if you have eg 2 sets of car keys and one of them is gone and the car is still there it might lead to false AWAYs as it assumes that the car key beacon is used only for CARs.

fixed: device edit for keys did not work properly

Parameters set by the plugin:
properties for each beacon that is used for CARs:
- fastdown = 15 seconds (you can change that up or down if you like and test the limits)
- seconds before signal, distance, etc gets updated AGAIN set to immediate. This is used to reduce the number of changes. But here we need the most recent info. hence it is set to react quickly.
this can not be changed by the user. The plugin will overwrite it to immediate even if you set it otherwise.

looks stable to me now.. no error in > 24 hours. ... but someone will likely find one..


Karl

Posted on
Sun Jan 15, 2017 10:43 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted v 7-37-40

fixed/improved:
- reduced # of updates in indigo DB. A lot of the temporary values (i.e. signal & last update ) are now handled in temporary variables and not written too often to indigo. That reduces stress on the indigo server and the sql logger.
- added a state: "location" = home/away
- state "status" now can be selected from the 3 different states: motion/engine/location. this field is shown in the "state" column
- fixed some sequences of when things go to home/away arriving/stop/leaving/left ...

Karl

Posted on
Tue Jan 17, 2017 11:56 am
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted v 7-37-41

fixed:
map iPhone UUID to a fixed MAC#. It was using the UUID nickname instead of the real UUID
added an error check to catch >> "piBeacon in Line '920' has error=''key note not found in dict'' ...piBeacon unknown error<<, don't know why this one occurs, but now it will give more info.

added
1. the py program on the RPI now does a boot disk check :"dosfsck -w -r -l -a -v -t /dev/mmcblk0p1" of the SSD every time it boots
It will to try to fix any bad files/ sectors etc. This has helped me with some RPIs that did not always boot - get stuck while booting.
2. the py program on the RPI does a sync once every 30 secs (write files to SSD to make sure that files are consistent)
3. added a feature that allows to change the MAC number of an iBeacon in indigo device edit.
use this to eg replace a tile beacon when your battery runs out. I tried it several times and it should work, but if you make a mistake here things might get screwy as the MAC id is THE key in the program eg put in a MAC number of another active beacon that already exists. It will do a basic check (length of MAC number), nothing else
You could use this to also create a beacon manually: crete a device pibeacon/ibeacon and will fill out the fields (most defaults are ok) and add the MAC number of your new beacon.
You will beed to push "config" to the RPIs manually after this (I will need to automate this)


Karl

Posted on
Wed Jan 18, 2017 12:43 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted v 7-38-41

added:
state: closestRPIText
will have values: closestRPI=-1,closestRPI=0 .... closestRPI=9

this can be used to set up a control page with image files
r0+.png
r0+closestRPI=0.png
...
r9+.png
r9+closestRPI=9.png

0...9 = room numbers

with
rX+.png is empty
rX+cosestRPI=X is eg a green dot. (X =0...9)
Then put for each beacon/state=closestRPIText an image into each room using above image files "as Image = rX+" (X = 0...9 for each room if you have 10 RPI, one per room)

you can then show either as text or image in which room the beacon currently is ..

The reverse is also possible:
use a rectangle with color of background to hide the text if the beacon is not present.
the rX+.png would be the rectangle and the other one would be an empty image.
you then need 2 display objects: one for the beacon text = eg device name and the other the rectangle overlaying the text


Karl

Posted on
Thu Jan 19, 2017 6:58 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted v 7-39-41

added:
to make it easier to trigger on any important change the following two events and two variables you can trigger on / use were added:

Variables: the following variables get updated when
-- iBeacon-With-ClosestRPI-Change == the state "clostestRPI" in ANY ibeacon gets changed (-1,0,1,2,3,...9)
-- iBeacon-With-Status-Change == state state "status" in ANY ibeacon gets changed (up/donw/expired)
Events:
-- the status of at least one beacon has changed == same as variable
-- the status of at least one CLOSEST RPI has changed == same as variable
events are almost the same as the variables, but if eg two changes in a row happen to the same iBeacon the variable contents (name of beacon) will not change, but the trigger will fire
eg closestRPI goes from 1 to 2 to 1 would change the 2. trigger but would not update the variable.

You can use this to replace the more taxing indigo system methods if any device/state has changed (variableUpdated or deviceUpdated) , which is called for ANY device / states change. This will reduce the amount of action in your script significantly
usage:
trigger on piBeacon / "iBeacon-With-ClosestRPI-Change" events and then look up the value in variable "iBeacon-With-ClosestRPI-Change".
That will give you the name of the iBeacon that had a change in state "closestRPI"


Karl

ps
The variables get recycled at midnight= deleted and re-created as they are not useful in the SQL logger and they might be updated frequently... That will delete the old tables and create new empty ones. -- same as with the pi_IN_xx
so don't use the variable ID but the variable name. It is fixed anyway..

Posted on
Fri Jan 20, 2017 8:02 am
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted v 7-39-44

fixed:
creating new beacons had a problem:
'6887' has error='cannot concatenate 'str' and 'int' objects'


Karl

Posted on
Sun Jan 22, 2017 10:50 am
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted v 7-39-47

fixed:
using %%v:xxx%% resulted in a wrong JSON string when the variable xxx contained a +-/*. That was supposed to be a feature that you can use: eg 2 variables and show the difference (eg: var1 - var2)the program used:
Code: Select all
textIn = unicode(eval(textIn))
That creates a problem when the conversion does not work eg you don't just have 2 variables in the text string but also some text ("the result is var1 - var2"). The fallback exception handling then replaced " with ', which bombs JSON.LOADS ...

That "highly sophisticated feature" is now disabled. need to dig a bit deeper how to properly do this.

Karl

Posted on
Sun Jan 29, 2017 10:15 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted v 7-39-48

minor changes:
1. format of numbers in states are now 1 digit after . (ie. distance) instead of sometimes 10+
2. some small improvements in when states get updated (signal must change by more than 4 dBm) to reduce frequent updates ... that has an impact when you have 10 RPI and 30 beacons ( up to 10*30* 4 values get updated per minute = 200 / second, with 2 RPI and 5 beacons that is max 2 / second ). With this addition it is down by 50%. You can keep the old setting by setting "update immediately" in device edit for each beacon.
Distance are though calculated with the last values and also only updated if > 5% or 0.5 m change
3. on RPI get "my Ip number": added some code in case it has 2 IP numbers (e.g. ethernet and wifi) to pick the better one.


Karl

Posted on
Sun Feb 05, 2017 10:49 am
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted v 7-39-50

fixed:
- the option to reboot or not reboot the RPIs at midnight was actually overwritten by a hard coded statement. It now will use these settings
- changed the way how start/stop devices is implemented. Should add stability to devices. -- very technical, should not impact day to day usage, but will be better in exception cases e.g. plugin was down for 30 minutes and restarting: devices should not go to down ....

Karl

Posted on
Thu Feb 09, 2017 10:33 am
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted v 7-39-51

http://forums.indigodomo.com/viewtopic.php?f=187&t=15152

added:
1. CARS
new states for device model CAR
the location can be: home away
the Motion can be: arriving, stop, leaving,
the engine = on/off/unknown
in addition the location is shown in the address field as home/away
added 2 states:" last arrival a thome" and "last leave from home" = time stamps YYY-MM-DD HH:MM:SS from when the car came home or left last
this is how the states would look like leaving / arriving home:
Code: Select all
 id |             ts             |  lastarrivalathome  |  lastleavefromhome  | engine  | location |  motion  |      status       
----+----------------------------+---------------------+---------------------+---------+----------+----------+-------------------
  1 | 2017-02-07 22:34:09.511881 |                     |                     |         |          |          |
  2 | 2017-02-07 22:37:09.565165 | 2017-02-07 22:37:09 |                     | off     | home     | stop     | home/off/stop
  3 | 2017-02-08 11:40:50.499639 |                     |                     | on      |          | leaving  | home/on/leaving
  4 | 2017-02-08 11:41:28.730227 |                     |                     | off     |          | stop     | home/off/stop
  5 | 2017-02-08 11:41:35.9926   |                     | 2017-02-08 11:41:35 | unknown | away     | left     | away/unknown/left
  6 | 2017-02-08 13:47:44.185121 | 2017-02-08 13:47:44 |                     | off     | home     | arriving | home/off/arriving
  7 | 2017-02-08 13:47:51.149195 |                     |                     | on      |          |          | home/on/arriving
  8 | 2017-02-08 13:48:30.508188 |                     |                     | off     |          | stop     | home/off/stop
  9 | 2017-02-08 14:20:58.171321 |                     | 2017-02-08 14:20:58 | unknown | away     | left     | away/unknown/left
 10 | 2017-02-08 14:21:13.700842 | 2017-02-08 14:21:13 |                     | off     | home     | unknown  | home/off/unknown
 11 | 2017-02-08 14:21:39.404607 |                     |                     |         |          | stop     | home/off/stop
 12 | 2017-02-08 14:41:48.127854 |                     | 2017-02-08 14:41:48 | unknown | away     | left     | away/unknown/left
 13 | 2017-02-08 14:42:05.06825  | 2017-02-08 14:42:05 |                     | off     | home     | unknown  | home/off/unknown
 14 | 2017-02-08 14:42:29.183145 |                     |                     |         |          | stop     | home/off/stop
 15 | 2017-02-08 18:32:14.255388 |                     | 2017-02-08 18:32:14 | unknown | away     | left     | away/unknown/left
 16 | 2017-02-08 18:32:40.475219 | 2017-02-08 18:32:40 |                     | off     | home     | unknown  | home/off/unknown
 17 | 2017-02-08 18:33:07.925744 |                     |                     |         |          | stop     | home/off/stop


3. replacement of an RPI server
2 options (a) automatically replace an RPI server devices when you e.g. manually(or through the "basic initial setup" menu) put the proper config on the RPI and (b) you can replace an RPI in the menu - for this both RPI devices have to exist.
The purpose of this is to keep the indigo history (i.e. the indigo device id) when you replace an RPI. The rpis are normally automatically created when they first show up. Their indigo ID is linked to the BLE-MAC#

2. Several smaller things
improvement in formats, help texts, some more error / exception control


Karl
Attachments
Screen Shot 2017-02-09 at 11.44.27.png
Screen Shot 2017-02-09 at 11.44.27.png (5.8 KiB) Viewed 4023 times
Screen Shot 2017-02-09 at 11.43.40.png
Screen Shot 2017-02-09 at 11.43.40.png (28.86 KiB) Viewed 4023 times

Posted on
Sat Feb 11, 2017 12:27 am
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted v 7-50-52

added:
- some typos in help and menus
- action for display now can have up to 10 line items, up from 6
- with debug_output = on an action will be converted to a python script you can use as an action script in an action group, e.g.:
Code: Select all
=======use this as a python script in an action group action :=====
plug = indigo.server.getPlugin("com.karlwachs.piBeacon")
plug.executeAction("Display" ,   props ={
   "outputDev":"s-14-displayrgb"
  ,"device":"OUTPUT-Display"
  ,"restoreAfterBoot":False
  ,"intensity":100
  ,"repeat":2
  ,"resetInitial":""
  ,"scrollxy":"left"
  ,"showDateTime":"0"
  ,"scrollPages":3
  ,"scrollDelay":0.02
  ,"scrollDelayBetweenPages":1
  ,"command":'['+
      '{"reset": "", "postion": [0, 32, 256], "width": "64", "type": "hBar", "display": "wait", "fill": "[0, 0, 0]"}'+
     ',{"reset": "", "text": "......", "postion": [0, 1], "font": "6x9.pil", "type": "text", "display": "wait", "fill": "[50, 50, 50]"}'+
     ',{"reset": "", "text": "......", "postion": [0, 16], "font": "8x13.pil", "type": "text", "display": "wait", "fill": "[50, 50, 50]"}'+
     ',{"reset": "", "text": " Temp[C]", "postion": [64, 1], "font": "6x9.pil", "type": "text", "display": "wait", "fill": "[0, 255, 0]"}'+
     ',{"reset": "", "text": " 21.4", "postion": [64, 16], "font": "8x13.pil", "type": "text", "display": "wait", "fill": "[0, 255, 0]"}'+
     ',{"reset": "", "text": "  Hum[%]", "postion": [128, 1], "font": "6x9.pil", "type": "text", "display": "wait", "fill": "[0, 0, 255]"}'+
     ',{"reset": "", "text": "   33", "postion": [128, 16], "font": "8x13.pil", "type": "text", "display": "wait", "fill": "[0, 0, 255]"}'+
     ',{"reset": "", "text": "P[mBar]", "postion": [192, 1], "font": "6x9.pil", "type": "text", "display": "wait", "fill": "[255, 0, 0]"}'+
     ',{"reset": "", "text": "-0.6", "postion": [192, 16], "font": "8x13.pil", "type": "text", "display": "immediate", "fill": "[255, 0, 0]"}]'
  })
=======   end    =====
will be printed to the indigo logfile

If you copy this script into an action group action the 8 lines of text will be send to the display "s-14-displayrgb"

This is meant to give you a jumpstart in editing complicated text, histograms, etc you want to send to your displays with a python script instead of a static action.

Karl

Posted on
Fri Mar 03, 2017 11:14 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted v 7-40-55

fixed:
1. member of group-x in beacon device edit saves now correctly
2. fixed "no-ip-number" in master.py on the RPI
3. output devices (relays etc) work again

Karl

Posted on
Sun Mar 05, 2017 5:09 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted V 7-40-60

fixed:
1. with short IP number e.g. 10.1.0.1 it rejected them as invalid (tested for length < 9)
2. fixed some details after I switched to more python like structure (i.e. classes for logging)
3. fixed some details for analog sensors and ultrasound

added:
you now can replace an iBeacon in device edit, e.g. if you get a new Tile. But you must know the MAC number of the new beacon. In device edit at the bottom update the current MAC number with the new one. the rest should automatic. This is to keep the history of the beacon and not create a new device.

As for BLE connect not doing anything.. one part was the short IP number.
In addition, if the state goes to down to often try to shorten the repeat rate in BLE device edit , e.g. set to 3 secs instead of default 10 second. That seems to help.
BUT in general BLEconnect is not 100% reliable as the iPhone might go to sleep and does not answer BLE pinging

Karl

Posted on
Tue Mar 07, 2017 3:03 pm
kw123 offline
User avatar
Posts: 8363
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 3- presence monitoring download

posted V 7-41-61

fixed:
one small issue on the RPI with sensor, had a typo in the code. no major impact

added:
1. The one thing that is missing with the RPI is the Analog read capability. The new plugin now supports PCF8591 AD/DA analog sensor/ analog output. You can get them for $2.50 https://www.amazon.com/gp/product/B00TK0TIEU/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1 with ~ 3 weeks delivery. They have 4 Analog IN (8Bit) one Analog OUT (8Bit). There are version with different form factors. Most of them come with a light sensor wired to Ain2 and a potentiometer to Ain1, I guess thats for testing. So for $2.50 you get 3 Analog in, 1 light sensor and 1 analog out -- but only 8 Bit(0-255) - though that is probably ok for most applications.

2. when you replace an RPI with a new BLE you can now use the old SSD put it into the new RPi and the plugin should recognize that and set most of the parameters automatically. You might need to manually set the IP number for the new RPI.

Karl

Page 8 of 21 1 ... 5, 6, 7, 8, 9, 10, 11 ... 21

Who is online

Users browsing this forum: No registered users and 39 guests

cron