Page 12 of 19
Re: How to check presence of Beacon ?
Posted: Thursday 20 October 2016 22:16
by jmleglise
@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.
Re: How to check presence of Beacon ?
Posted: Friday 21 October 2016 15:29
by sbisbilo
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 !
Re: How to check presence of Beacon ?
Posted: Saturday 22 October 2016 19:52
by nillix
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
pi@raspberrypi:~$ 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¶m=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
Re: How to check presence of Beacon ?
Posted: Saturday 22 October 2016 21:19
by nillix
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)
....
Re: How to check presence of Beacon ?
Posted: Sunday 23 October 2016 11:31
by jmleglise
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,
Re: How to check presence of Beacon ?
Posted: Sunday 23 October 2016 17:54
by nillix
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
Re: How to check presence of Beacon ?
Posted: Tuesday 25 October 2016 23:56
by jmleglise
Hi,
Could you please publish (or send me a PM) the display of this new function ?
Re: How to check presence of Beacon ?
Posted: Friday 09 December 2016 16:44
by dfranco
joshimosh wrote:Raspberry Piet wrote:
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?
Re: How to check presence of Beacon ?
Posted: Tuesday 13 December 2016 22:32
by deennoo
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 ?
Re: How to check presence of Beacon ?
Posted: Saturday 17 December 2016 12:05
by tuspam
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¶m=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¶m=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)
Re: How to check presence of Beacon ?
Posted: Tuesday 03 January 2017 11:57
by xavierlp
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
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
Re: How to check presence of Beacon ?
Posted: Wednesday 04 January 2017 10:52
by jadon
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
Re: How to check presence of Beacon ?
Posted: Wednesday 11 January 2017 10:29
by Stewie3112
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
Re: How to check presence of Beacon ?
Posted: Tuesday 17 January 2017 20:56
by Guiggess
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 !
Re: How to check presence of Beacon ?
Posted: Thursday 02 February 2017 17:07
by bigpea
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.
Re: How to check presence of Beacon ?
Posted: Sunday 19 February 2017 1:25
by korniza
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.
Re: How to check presence of Beacon ?
Posted: Sunday 19 February 2017 1:30
by korniza
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
Re: How to check presence of Beacon ?
Posted: Sunday 19 February 2017 14:30
by bigpea
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.
Re: How to check presence of Beacon ?
Posted: Sunday 19 February 2017 18:35
by korniza
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.
Re: How to check presence of Beacon ?
Posted: Tuesday 21 February 2017 16:37
by bigpea
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?