How to check presence of Beacon ?

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.
jmleglise
Posts: 192
Joined: Tuesday 13 January 2015 0:27
Target OS: Raspberry Pi
Domoticz version: V3.5113
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Postby jmleglise » Thursday 20 October 2016 22:16

@sbisbilo

For your question about the log :

* Do you notice that the python script can output some log depending of the "logLevel" variable ?
logLevel=logging.DEBUG
#logLevel=logging.CRITICAL
#logOutFilename='/var/log/check_beacon_presence.log'

* If you'd rather prefer to manage your log in LUA, you can do a :
variable script "script_variable_yourname.lua"

with something like that (not tested) :

Code: Select all

commandArray = {}
fileLog ='/var/log/domoticz.beacon.log'

if uservariablechanged['your uservariable of your beacon'] then
    os.execute('echo '..os.date("%Y-%m-%d %H:%M:%S",os.time())..' - beacon :'..uservariables['your uservariable of your beacon']..' >>'..fileLog)   
end
return commandArray


And you have several usefull examples of Lua script in the thread to inspire you.
Raspberry Pi2 + RFXTRX433E + KMTronic USB relay card
Blinds Somfy RTS, Blinds Bubendorff, Portal Somfy Evolvia 400, IP Video Doorbell ATZ-DBV01P, chacon IO, Oregon THN132ES, THN122N, Chinese PIR sensor PT2262, Bluetooth low energy dongle, iBeacon

sbisbilo
Posts: 11
Joined: Monday 07 March 2016 18:23
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: How to check presence of Beacon ?

Postby sbisbilo » Friday 21 October 2016 15:29

Thank you so much jmleglise You made my day ! :)
I didn't know the filelog option and It will be very useful in my case !

nillix
Posts: 6
Joined: Tuesday 29 December 2015 11:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: How to check presence of Beacon ?

Postby nillix » Saturday 22 October 2016 19:52

Hi,

I orderes two of the nut minis and I think they are working better.
But there is a problem with the script now:

When I run it, it detects the first beacon (I have two) and it updates the uservariable for that beacon. After a few seconds the script runs in an error:


Code: Select all

[email protected]:~$ sudo python check_beacon_presence.py
2016-10-22 19:46:54,606 - root - DEBUG - Ok hci0 interface Up n running !
2016-10-22 19:46:54,610 - root - DEBUG - Connect to bluetooth device 0
2016-10-22 19:46:54,705 - root - DEBUG - Tag Tag_Nils Detected xx:xx:xx:xx:xx:xx - RSSI (-64,) - DATA unknown (-102,)
2016-10-22 19:46:54,712 - root - DEBUG - Tag Tag_Nils is still there with an RSSI of -64  : update presence with RSSI
2016-10-22 19:46:54,825 - urllib3.connectionpool - INFO - Starting new HTTP connection (1): 192.168.1.3
2016-10-22 19:46:54,844 - urllib3.connectionpool - DEBUG - "GET /json.htm?type=command&param=updateuservariable&idx=6&vname=Tag_Nils&vtype=2&vvalue=-64 HTTP/1.1" 200 58
2016-10-22 19:46:54,858 - root - DEBUG -  <Thread(Thread-2, started -1246759840)> -> <Response [200]>
Traceback (most recent call last):
  File "check_beacon_presence.py", line 190, in <module>
    le_handle_connection_complete(pkt)
NameError: name 'le_handle_connection_complete' is not defined



could anybody help?

Thanks

nillix
Posts: 6
Joined: Tuesday 29 December 2015 11:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: How to check presence of Beacon ?

Postby nillix » Saturday 22 October 2016 21:19

Update:

I just did a test on my laptop where I not get this error.
I don't yet know why, but maybe it has something to to with the different version of python or something...
My domoticz Installation where the script shall run on is a raspberry pi (Model B)

....

jmleglise
Posts: 192
Joined: Tuesday 13 January 2015 0:27
Target OS: Raspberry Pi
Domoticz version: V3.5113
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Postby jmleglise » Sunday 23 October 2016 11:31

Hi,

I've never had your case so my script doesn't manage it... I'm not @home. Can you experiment ?

Please add this code in my script, for example just above the line "def request_thread(idx,cmd, name):"
Do you have some base in python ? (=you must respect carefully the nuimber of space in front of line)

Code: Select all

def le_handle_connection_complete(pkt):
    status, handle, role, peer_bdaddr_type = struct.unpack("<BHBB", pkt[0:5])
    device_address = packed_bdaddr_to_string(pkt[5:11])
    interval, latency, supervision_timeout, master_clock_accuracy = struct.unpack("<HHHB", pkt[11:])
    print "le_handle_connection output"
    print "status: 0x%02x\nhandle: 0x%04x" % (status, handle)
    print "role: 0x%02x" % role
    print "device address: ", device_address


Run it in a console and report the output please,
Raspberry Pi2 + RFXTRX433E + KMTronic USB relay card
Blinds Somfy RTS, Blinds Bubendorff, Portal Somfy Evolvia 400, IP Video Doorbell ATZ-DBV01P, chacon IO, Oregon THN132ES, THN122N, Chinese PIR sensor PT2262, Bluetooth low energy dongle, iBeacon

nillix
Posts: 6
Joined: Tuesday 29 December 2015 11:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: How to check presence of Beacon ?

Postby nillix » Sunday 23 October 2016 17:54

Hi jmleglise,

thanks for your feedback. I tried to define that function before in a similar way but without success.
Now with your code provided it worked.
I think that was the trick and it should then be ok now. The user variables are set correctly and I can go ahead and play with some nice scenes and functions.

Thanks for your help!
Nils

jmleglise
Posts: 192
Joined: Tuesday 13 January 2015 0:27
Target OS: Raspberry Pi
Domoticz version: V3.5113
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Postby jmleglise » Tuesday 25 October 2016 23:56

Hi,

Could you please publish (or send me a PM) the display of this new function ?
Raspberry Pi2 + RFXTRX433E + KMTronic USB relay card
Blinds Somfy RTS, Blinds Bubendorff, Portal Somfy Evolvia 400, IP Video Doorbell ATZ-DBV01P, chacon IO, Oregon THN132ES, THN122N, Chinese PIR sensor PT2262, Bluetooth low energy dongle, iBeacon

dfranco
Posts: 6
Joined: Wednesday 05 August 2015 11:17
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: How to check presence of Beacon ?

Postby dfranco » Friday 09 December 2016 17:44

joshimosh wrote:
Raspberry Piet wrote:
joshimosh wrote:Hi paulD,
I've got a couple of those:

http://www.aliexpress.com/item/NEW-1pcs ... 39b73c957a

Cost me 1,52€ at the time I have ordered. In the meantime the Euro went up against USD :-)

Cheers
Josh



Doesn't these BLE-tags power themselves off when there is no connection? (I think these tags were mentioned before in this thread and/or in the wiki)


I have one of them running for a couple of days. The tiny blue LED keeps blinking ...



I joshimosh

I have also two of this units, and everything works ok. My only problem is the battery of the beacons. In my two units the new batterys as drain after 3 days of working.

Do you have also this problem?

deennoo
Posts: 826
Joined: Wednesday 10 December 2014 14:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: How to check presence of Beacon ?

Postby deennoo » Tuesday 13 December 2016 23:32

Hi there,

I try to use BLE for 2 kind of devices :
Beacon & Xiaomi Mi Flora ( viewtopic.php?f=56&t=13306 )

Running alone Beacon run fine
Running alone Myflora run fine
But running both on the same time handel HCI device to the first who need it.

Anyway to get a real BLE Scanner who can be use to reconize various devices (beacon, scale, flora, flowerpower etc etc etc) ?
Any one got some source ?
Have to wait for Domoticz Python Plugin interface to arrive ?
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / ESP8266 / MQTT / BLE
http://domo-attitude.fr

tuspam
Posts: 36
Joined: Friday 25 December 2015 1:19
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: How to check presence of Beacon ?

Postby tuspam » Saturday 17 December 2016 13:05

Please help with configuration:

TAG_DATA = [
["Tag_Mirek","F2:FB:9F:D4:3E:F0",30,0,336,REPEAT_MODE]
]


336 in my case is correct?

Any suggestions?


Error log:
2016-12-17 12:04:52,982 - root - DEBUG - Ok hci0 interface Up n running !
2016-12-17 12:04:52,983 - root - DEBUG - Connect to bluetooth device 0
2016-12-17 12:04:55,574 - root - DEBUG - Tag Tag_Mirek Detected f2:fb:9f:d4:3e:f0 - RSSI (-65,) - DATA unknown (-16,)
2016-12-17 12:04:55,628 - root - DEBUG - Tag Tag_Mirek is still there with an RSSI of -65 : update presence with RSSI
2016-12-17 12:04:55,631 - requests.packages.urllib3.connectionpool - INFO - Starting new HTTP connection (1): localhost
2016-12-17 12:04:55,655 - requests.packages.urllib3.connectionpool - DEBUG - "GET /json.htm?type=command&param=updateuservariable&idx=336&vname=Tag_Mirek&vtype=2&vvalue=-65 ('HTTP/1.1',)" 200 58
2016-12-17 12:04:55,657 - root - DEBUG - <Thread(Thread-2, started 1977799792)> -> <Response [200]>
2016-12-17 12:04:59,437 - root - DEBUG - Tag Tag_Mirek Detected f2:fb:9f:d4:3e:f0 - RSSI (-71,) - DATA unknown (-16,)
2016-12-17 12:04:59,442 - root - DEBUG - Tag Tag_Mirek is still there with an RSSI of -71 : update presence with RSSI
2016-12-17 12:04:59,444 - requests.packages.urllib3.connectionpool - INFO - Starting new HTTP connection (1): localhost
2016-12-17 12:04:59,469 - requests.packages.urllib3.connectionpool - DEBUG - "GET /json.htm?type=command&param=updateuservariable&idx=336&vname=Tag_Mirek&vtype=2&vvalue=-71 ('HTTP/1.1',)" 200 58
2016-12-17 12:04:59,472 - root - DEBUG - <Thread(Thread-3, started 1977799792)> -> <Response [200]>


Error from domoticz:

Code: Select all

2016-12-17 12:10:35.289 Error: EventSystem: in TAG: [string "x = tonumber(uservariables['Tag_Mirek'])..."]:11: attempt to concatenate global 'x' (a nil value)
Attachments
2.jpg
2.jpg (92.43 KiB) Viewed 729 times
1.jpg
1.jpg (69.59 KiB) Viewed 729 times

xavierlp
Posts: 7
Joined: Tuesday 01 November 2016 17:22
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: How to check presence of Beacon ?

Postby xavierlp » Tuesday 03 January 2017 12:57

jnoel68 wrote:
jumbotroll wrote:
jnoel68 wrote:Unfortunately, still unable to install bluez on my synology
in fact, there is a package available for optware/entware (which are tools to allow install standard linux package) but the bluez version is 3.36, and the team don't want to upgrade to bluez 5 for compatibilty reason with other packages ...
Still trying to install it :oops:


I have compiled spk package Bluez version 5.41 for DS1511+ arch-x86 for DSM 6.0 for you to test . Binary files are located in /usr/local/bluez .
I have not tested this package even when I do not use bluetooth.
http://www.jadahl.com/synology6/?arch=x86

Thanks Jumbotroll, installation went fine -> Bluez is well installed in folder /usr/local/bluez
But still unable to import "bluetooth" or "bluez" in the python script provided by jmleglise, always the same issue :
No module named bluetooth._bluetooth

I'm not fine with python, so I'm not sure that the import can look in /usr/local/bluez, so I've tried to copy this folder in one of the PYTHONPATH, but still not working ... si maybe the bluez module should be compiled for python before ...
@jmleglise, if you have any idea, thanks to help




Hello

I'm currently trying to setup Synology and Beacon.
I could read your post this summer.
And I would like to know if you find a solution.

thanks a lot

happy new year 2017

best regards

Xavier

User avatar
jadon
Posts: 9
Joined: Monday 07 November 2016 15:59
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Tiel, Netherlands
Contact:

Re: How to check presence of Beacon ?

Postby jadon » Wednesday 04 January 2017 11:52

I don't know if these were already mentioned, but I can confirm these beacons are working:

https://nl.aliexpress.com/item/Bluetoot ... 49350.html

Very cheap :) Aprox. EUR 4,-

Edit: I added the link to the wiki page

Stewie3112
Posts: 2
Joined: Wednesday 11 January 2017 11:27
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: How to check presence of Beacon ?

Postby Stewie3112 » Wednesday 11 January 2017 11:29

xavierlp wrote:
jnoel68 wrote:
jumbotroll wrote:
I have compiled spk package Bluez version 5.41 for DS1511+ arch-x86 for DSM 6.0 for you to test . Binary files are located in /usr/local/bluez .
I have not tested this package even when I do not use bluetooth.
http://www.jadahl.com/synology6/?arch=x86

Thanks Jumbotroll, installation went fine -> Bluez is well installed in folder /usr/local/bluez
But still unable to import "bluetooth" or "bluez" in the python script provided by jmleglise, always the same issue :
No module named bluetooth._bluetooth

I'm not fine with python, so I'm not sure that the import can look in /usr/local/bluez, so I've tried to copy this folder in one of the PYTHONPATH, but still not working ... si maybe the bluez module should be compiled for python before ...
@jmleglise, if you have any idea, thanks to help




Hello

I'm currently trying to setup Synology and Beacon.
I could read your post this summer.
And I would like to know if you find a solution.

thanks a lot

happy new year 2017

best regards

Xavier


following this too, it would be great to have this on synology

Guiggess
Posts: 5
Joined: Tuesday 17 January 2017 21:50
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: How to check presence of Beacon ?

Postby Guiggess » Tuesday 17 January 2017 21:56

Hi everyone,

I ran across the entire tutorial and everything is working like a charm, up to starting the deamon automatically at reboot...

I get that naughty "active (exited)" message with any solving attempts...

- Changing user in the deamon from root to pi and the other way
- Adding root hciconfig hci0 up in cron @reboot

I have a Raspberry Pi 3 and I assume that bluetooth is not ready when the daemon starts. Any other thoughts ? Any chance someone has a solution ?

Thanks !

bigpea
Posts: 44
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: How to check presence of Beacon ?

Postby bigpea » Thursday 02 February 2017 18:07

Hi all,
I'm using this script and it's fantastic.
I'm trying to get from the data also the level of the battery in order to receive a notify and change the battery but without success.
Anybody have done this?

Thanks.

korniza
Posts: 180
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi
Domoticz version: V3.6028
Location: Greece
Contact:

Re: How to check presence of Beacon ?

Postby korniza » Sunday 19 February 2017 2:25

Great news guys!
As I follow FHEM community also, I discovered that NUT 3 can get battery level!!! No more alarms in the night because of dead NUT!
the command is the following:

Code: Select all

gatttool -t random -b XX:XX:XX:XX:XX:XX --char-read --uuid 0x2A19

where xxx.. are the address of the beacon!

Be careful not to use this command every time you detect the presence because it drains the battery on NUT.
The best is to tested once a day.
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)

korniza
Posts: 180
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi
Domoticz version: V3.6028
Location: Greece
Contact:

Re: How to check presence of Beacon ?

Postby korniza » Sunday 19 February 2017 2:30

also i like to add with bold letters

stay away from TrackR Bravo ( https://www.thetrackr.com/bravo ). The range is limited and they do not stay awake all the time! No other support is provided from the manufacturer
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)

bigpea
Posts: 44
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: How to check presence of Beacon ?

Postby bigpea » Sunday 19 February 2017 15:30

korniza wrote:Great news guys!
As I follow FHEM community also, I discovered that NUT 3 can get battery level!!! No more alarms in the night because of dead NUT!
the command is the following:

Code: Select all

gatttool -t random -b XX:XX:XX:XX:XX:XX --char-read --uuid 0x2A19

where xxx.. are the address of the beacon!

Be careful not to use this command every time you detect the presence because it drains the battery on NUT.
The best is to tested once a day.


It's fantastic!
Do you know if is possible to know the level also for Mini Nut?
If it isn't possible I will buy the Nut3 but in this moment i have a Mini Nut and this code doesn't work.
Thanks.

korniza
Posts: 180
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi
Domoticz version: V3.6028
Location: Greece
Contact:

Re: How to check presence of Beacon ?

Postby korniza » Sunday 19 February 2017 19:35

bigpea wrote:
korniza wrote:Great news guys!
As I follow FHEM community also, I discovered that NUT 3 can get battery level!!! No more alarms in the night because of dead NUT!
the command is the following:

Code: Select all

gatttool -t random -b XX:XX:XX:XX:XX:XX --char-read --uuid 0x2A19

where xxx.. are the address of the beacon!

Be careful not to use this command every time you detect the presence because it drains the battery on NUT.
The best is to tested once a day.


It's fantastic!
Do you know if is possible to know the level also for Mini Nut?
If it isn't possible I will buy the Nut3 but in this moment i have a Mini Nut and this code doesn't work.
Thanks.


I think you need to check this using an android app from nodric https://play.google.com/store/apps/deta ... ndroid.mcp
and check if battery service is available for any ble beacon you have.
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)

bigpea
Posts: 44
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: How to check presence of Beacon ?

Postby bigpea » Tuesday 21 February 2017 17:37

Hi,
I followed your advice and i downloaded the app.
Mini Nut have the battery status info with the code 0x180F.

I try to execute your command:

Code: Select all

gatttool -t random -b de:ab:5b:00:60:7c --char-read --uuid 0x180F


But I receive this error:
connect error: Transport endpoint is not connected (107)


When i try to execute this command the Mini Nut is associated at the raspberry and the association with these device go down but i don't receive the expected value.

Could you help me?


Return to “Other questions and discussions”

Who is online

Users browsing this forum: No registered users and 3 guests