How to check presence of Beacon ?
Moderators: leecollings, remb0
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: How to check presence of Beacon ?
welcome to my world!!!
there are weeks I'm struggling (and my domobuddies either) on this issue!!!
First of all the uuid for battery is 0x2A19 (0x180F is the Battery service, but the percentage is the 2 bit at 2a19 )
thena... it looks like the nut mini does not reply to standard calls OR... gatttool is not able to...
I tries to use Bluez stack from 5.3 to 5.48 (latest) with no success....
based on almost all forums... it looks it is a kernel issue and the best stack to use was bluez 5.11
...but it does not support the internal bt chip (brc43xx)
I was unable to use external BT dongles due to an enumeration error (could it be broken or a kernel issue?!) so the device is not loaded correctly
As per now... I only able to get connection error 107 (endpoint not connected) 111 (connection refused)
MORE... if you bound the nut to its app... it disappear from the network
and least but not last... usign nRF app you're able to see almost all the characteristics... so it's defenetly a software issue!
there are weeks I'm struggling (and my domobuddies either) on this issue!!!
First of all the uuid for battery is 0x2A19 (0x180F is the Battery service, but the percentage is the 2 bit at 2a19 )
thena... it looks like the nut mini does not reply to standard calls OR... gatttool is not able to...
I tries to use Bluez stack from 5.3 to 5.48 (latest) with no success....
based on almost all forums... it looks it is a kernel issue and the best stack to use was bluez 5.11
...but it does not support the internal bt chip (brc43xx)
I was unable to use external BT dongles due to an enumeration error (could it be broken or a kernel issue?!) so the device is not loaded correctly
As per now... I only able to get connection error 107 (endpoint not connected) 111 (connection refused)
MORE... if you bound the nut to its app... it disappear from the network
and least but not last... usign nRF app you're able to see almost all the characteristics... so it's defenetly a software issue!
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
-
- Posts: 157
- Joined: Thursday 27 August 2015 18:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3.6028
- Location: Greece
- Contact:
Re: How to check presence of Beacon ?
possible the errors are coming from the script you use to monitor presence. I have a second ble dongle and use it for non-dedicated uses (1st is just for scanning the beacons using FHEM).
>>>> 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)
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)
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: How to check presence of Beacon ?
a small step ahead...
It could be that the new kernel helps (4.4.38 and 4.9)... but this is what I was able to do:
First of all... the hci interface must be shutdown and restart...
then you can issue the following commands:
this should return a string like:
the command should look like:to return only the value (64)
the problem is that after few tentatives the beacon disappear and it is no longer reachable.... (privacy/ddos prevention?!)
=== UPDATE ===
Ok... this would be probably the last update with the final script...
I'm testing it and it works as it is supposed to.
It still miss the Domoticz sensors/variable/whatever, but it would be a simple curl request (I'll work on this this evening)
here it is!
save it and have it executable
test it... if you get a timeout error retry
this code SHOULD NOT run with the beacon presence scrit/service running... you have first to disable it, run the script and reenable the presence beacon
It could be that the new kernel helps (4.4.38 and 4.9)... but this is what I was able to do:
First of all... the hci interface must be shutdown and restart...
then you can issue the following commands:
Code: Select all
sudo hcitool lewladd --random <beaconMacAddress>
sudo gatttool -b <beaconMacAddress> -t random --char-read --uuid 0x2a19
for a script purpuse... and willing to implement the value in domoticz (remember it is hex!)handle: 0x00017 value: 64 00
the command should look like:
Code: Select all
sudo gatttool -b <beaconMacAddress> -t random --char-read --uuid 0x2a19 | grep value | awk '{print $4}'
the problem is that after few tentatives the beacon disappear and it is no longer reachable.... (privacy/ddos prevention?!)
=== UPDATE ===
Ok... this would be probably the last update with the final script...
I'm testing it and it works as it is supposed to.
It still miss the Domoticz sensors/variable/whatever, but it would be a simple curl request (I'll work on this this evening)
here it is!
of course replace the 00:... with your NUT Mini Mac address$ sudo nano nutbattery.sh
Code: Select all
#!/bin/bash
NUTMAC=$"00:00:00:00:00:00"
HCIIF=$"hci0"
sudo hciconfig $HCIIF down
sudo hciconfig $HCIIF up
HANDLE=$(sudo hcitool lecc --random $NUTMAC | awk '{print $3}')
sleep 2
sudo hcitool ledc $HANDLE
BATHEX=$(sudo gatttool -t random --char-read --uuid 0x2a19 -b $NUTMAC | awk '{print $4}')
BATDEC=$((0x$BATHEX))
echo "BATTERY HEX:" $BATHEX "CONVERTED:" $BATDEC "%"
Code: Select all
$ sudo chmod +x nutbattery.sh
this code SHOULD NOT run with the beacon presence scrit/service running... you have first to disable it, run the script and reenable the presence beacon
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
-
- Posts: 91
- Joined: Thursday 11 August 2016 12:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: IT
- Contact:
Re: How to check presence of Beacon ?
You are a genius!
Thanks emme!
Thanks emme!
-
- Posts: 1
- Joined: Thursday 23 February 2017 12:24
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to check presence of Beacon ?
Suggestion for jmleglise: https://github.com/jmleglise/mylittle-d ... resence.py
If you change line 232 to...
elif tag[5]==REPEAT_MODE and (elapsed_time>3 or int(time.time())%3==0): # in continuous, Every 3 seconds
...it will update the user variable for beacons that are sending at least every single second.
If you change line 232 to...
elif tag[5]==REPEAT_MODE and (elapsed_time>3 or int(time.time())%3==0): # in continuous, Every 3 seconds
...it will update the user variable for beacons that are sending at least every single second.
- darlomrh
- Posts: 35
- Joined: Monday 23 May 2016 8:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: UK
- Contact:
Re: How to check presence of Beacon ?
I have a query around the NUT2 tag. It appears the tag is only broadcasting when I press the button on the device.
Do I have to pair it with something to start the device broadcasting.
I have used LightBlue Explorer on iPhone and sudo hcitool lescan and only when the button is pressed the nut will broadcast
Faulty device?
Do I have to pair it with something to start the device broadcasting.
I have used LightBlue Explorer on iPhone and sudo hcitool lescan and only when the button is pressed the nut will broadcast
Faulty device?
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: How to check presence of Beacon ?
My poor experience with NUT teches me that nut should be NEVER paired with anything, niether (especially) its app!
if you do that it will become unaccessible and hides from scan...
If you have previously paired... remove NUT from the device and switch off the BT radio.
try to:
sudo hciconfig hci0 down
sudo hciconfig hci0 up
sudo hcitool lescan
(chech if it becomes available)
sudo hcitool lecc --random <nut mac address>
(if the command is successful it will return something like: Conenction Handle xx
sudo hcitool ledc <handle from previous command>
gatttool -t random -b <nut mac address> --characteristics
to get information
gatttool -t random -b <nut mac address> --char-read --uuid 0x2a19
to read the battery
this works for my nut mini
if you do that it will become unaccessible and hides from scan...
If you have previously paired... remove NUT from the device and switch off the BT radio.
try to:
sudo hciconfig hci0 down
sudo hciconfig hci0 up
sudo hcitool lescan
(chech if it becomes available)
sudo hcitool lecc --random <nut mac address>
(if the command is successful it will return something like: Conenction Handle xx
sudo hcitool ledc <handle from previous command>
gatttool -t random -b <nut mac address> --characteristics
to get information
gatttool -t random -b <nut mac address> --char-read --uuid 0x2a19
to read the battery
this works for my nut mini
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
- darlomrh
- Posts: 35
- Joined: Monday 23 May 2016 8:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: UK
- Contact:
Re: How to check presence of Beacon ?
NUT2 Only visible if I push the button into pair mode.sudo hcitool lescan
That scan reports and the script works with my fitbit One (perhaps should have just used that )
So i'm going to conclude broken device.
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: How to check presence of Beacon ?
what if you skip hcitool lescan and go straight to hcitool lecc <mac address> ?
you can either try to add the mac to the whitelist:
sudo hcitool lewladd <mac address> --random
and see if it start to be accessible
you can either try to add the mac to the whitelist:
sudo hcitool lewladd <mac address> --random
and see if it start to be accessible
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
- darlomrh
- Posts: 35
- Joined: Monday 23 May 2016 8:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: UK
- Contact:
Re: How to check presence of Beacon ?
Did a sudo hcitool lewladd --random <mac address> and it returned nothingemme wrote:what if you skip hcitool lescan and go straight to hcitool lecc <mac address> ?
you can either try to add the mac to the whitelist:
sudo hcitool lewladd <mac address> --random
and see if it start to be accessible
Did a sudo hcitool lecc <mac address> ? and got Could not create connection: Connection timed out
- darlomrh
- Posts: 35
- Joined: Monday 23 May 2016 8:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: UK
- Contact:
Re: How to check presence of Beacon ?
Yup definitely the NUT2. Ordered a NUT mini and worked straight off. Should have suspected as the NUT2 was a warehouse deal from Amazon.
-
- Posts: 157
- Joined: Thursday 27 August 2015 18:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3.6028
- Location: Greece
- Contact:
Re: How to check presence of Beacon ?
My next concept is to read the press button on the NUT/ any ble device so to trigger an action. does anybody tried?
>>>> 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)
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)
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: How to check presence of Beacon ?
I did...
I have 2 different services running handling beacons:
the first one is only presence detection (a simple lescan) using the script in this thread (switch mode) sets or unsets a user variable
than I have a cron job running once a day that check the battery status
Actually I have 3 beacons that arms alarm if away for more than 3 minutes...
if a NUT is seen in the network disarm the alarm ad switch on a light.
but you can do almost what you want... at the end they are variables and switches
I have 2 different services running handling beacons:
the first one is only presence detection (a simple lescan) using the script in this thread (switch mode) sets or unsets a user variable
than I have a cron job running once a day that check the battery status
Actually I have 3 beacons that arms alarm if away for more than 3 minutes...
if a NUT is seen in the network disarm the alarm ad switch on a light.
but you can do almost what you want... at the end they are variables and switches
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
- darlomrh
- Posts: 35
- Joined: Monday 23 May 2016 8:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: UK
- Contact:
Re: How to check presence of Beacon ?
Hi,
I have had to abandon the use of nut minis. Not sure if bad luck or house construction or placement of pi. Over a couple of hours today I had 100+ variable updates on a tag that was sitting on a table in the room next door to my RPI. Not great when I plan to hang a number of commands off the Home and Away status changes.
Thanks to all that have helped me and keep up the good work. Back to IFTTT (IFTTT is currently down as I type this ho-hum) maker applets via geolocation I think.
I have had to abandon the use of nut minis. Not sure if bad luck or house construction or placement of pi. Over a couple of hours today I had 100+ variable updates on a tag that was sitting on a table in the room next door to my RPI. Not great when I plan to hang a number of commands off the Home and Away status changes.
Thanks to all that have helped me and keep up the good work. Back to IFTTT (IFTTT is currently down as I type this ho-hum) maker applets via geolocation I think.
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: How to check presence of Beacon ?
if you are running on a PI3 just give him the last chance in replacing the BT Radio with a CSR4.0 dongle
I've seen that it is much more fast and reliable than the onboard radio
of course it will create a new interface (hci1) but I think that for a couple of € you can eventfix your problems...
....try my battery script
I've seen that it is much more fast and reliable than the onboard radio
of course it will create a new interface (hci1) but I think that for a couple of € you can eventfix your problems...
....try my battery script
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
- darlomrh
- Posts: 35
- Joined: Monday 23 May 2016 8:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: UK
- Contact:
Re: How to check presence of Beacon ?
Yeah.... never was able to get onboard BT to work so I purchased.
https://www.amazon.co.uk/gp/product/B00 ... UTF8&psc=1
Ran your battery script both 100%.
I am running RFXcom and uzb1 off the same PI so that may be it.
Thanks again great forum...
https://www.amazon.co.uk/gp/product/B00 ... UTF8&psc=1
Ran your battery script both 100%.
I am running RFXcom and uzb1 off the same PI so that may be it.
Thanks again great forum...
- Mooseknuckle
- Posts: 43
- Joined: Sunday 08 March 2015 9:24
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to check presence of Beacon ?
Hi,
Thank you for the BT presence script. I had a Xiaomi mi band v1 lying around and tried it as a beacon with the presence script. After you make it discoverable in the Mi fit app the band is found with 'hcitool lescan' and can be used as a beacon.
Greetings,
Thank you for the BT presence script. I had a Xiaomi mi band v1 lying around and tried it as a beacon with the presence script. After you make it discoverable in the Mi fit app the band is found with 'hcitool lescan' and can be used as a beacon.
Greetings,
RPI 3, Philips Hue,Toon Thermostat, Harmony Smart Control, Yeelights
Mysensors wifi gateway + sensors, RFXtrx433E, Kaku stuff, Xiaomi gateway + sensors
Domoticz controlled DIY ambilight, Selectplus chime, Mi-light led controller
Mysensors wifi gateway + sensors, RFXtrx433E, Kaku stuff, Xiaomi gateway + sensors
Domoticz controlled DIY ambilight, Selectplus chime, Mi-light led controller
-
- Posts: 6
- Joined: Tuesday 17 January 2017 20:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to check presence of Beacon ?
Hi everyone,
I still have my service starting issue at reboot. It works fine when I start it manually, but stay as "Active (exited) when I reboot my Pi.
Any suggestion ?
I still have my service starting issue at reboot. It works fine when I start it manually, but stay as "Active (exited) when I reboot my Pi.
Any suggestion ?
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: How to check presence of Beacon ?
in the .service file you created with the specification of the cmdline...
try to add:
Restart=always
RestartSec=3
in the [Service] section
this helped me with the telegram CLI service that fails at atartup, but runs if restarted
try to add:
Restart=always
RestartSec=3
in the [Service] section
this helped me with the telegram CLI service that fails at atartup, but runs if restarted
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
-
- Posts: 6
- Joined: Tuesday 17 January 2017 20:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to check presence of Beacon ?
Hi emme,
Thanks for answer. I didn't wrote any part of that daemon, and I'm a total noob in service/daemon writing...
Anyway, I don't have a .service file nor a [Service] section in the daemon file...
Where should I add the lines you suggest ?
Thanks for answer. I didn't wrote any part of that daemon, and I'm a total noob in service/daemon writing...
Anyway, I don't have a .service file nor a [Service] section in the daemon file...
Where should I add the lines you suggest ?
Who is online
Users browsing this forum: No registered users and 1 guest