Python plugin: Bluetooth Beacon Presence Detection
Moderator: leecollings
Re: Python plugin: Bluetooth Beacon Presence Detection
latest beta is working again.
-
- Posts: 5
- Joined: Tuesday 12 December 2017 16:17
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
I have bought a bunch of nut3 for every member of my family. I would like to use the plugin with the stable v4.97 version. The nut3 are correctly detected but I got an error when checking battery
After running “sudo ./ble_scanner.py” when battery is checked I got
INFO - start battery check xx:xx:xx:xx:xx:xx
ERROR - battery service: LE connect error [xx:xx:xx:xx:xx:xx] [Could not create connection: Connection timed out
Config.ini is
[Settings]
; Use different scanner_name if you have several instances for better debugging
scanner_name=Allarme
; By default hci0 in RPI3, but you can check with "hciconfig" command
bt_interface=hci0
; Domoticz IP and UDP port where plugin runs
server_ip=127.0.0.1
server_port=2221
; Check battery if signal strength >= setting
; Connection will not be established if signal is very low
battery_check_rssi_threshold=-75
; Time to check battery. 24h. Interval check_time + 30min
battery_check_time=03:00
; Attempts to check in time interval when beacon available
battery_check_attempts=2
; Beacon MAC address
[xx:xx:xx:xx:xx:xx]
; For better debug
label=Guido
; Supports battery check for nut3 and miband2
; Can be empty (battery check disabled)
battery_service_type=nut3
; Signal strength threshold,
; When signal lower the setting -> beacon info will not send to the plugin
; Can be empty (threshold disabled)
rssi_threshold=
I also wonder how the battery level is copied to Domoticz. Should I add a variable?
Any help would be appreciated
Thanks
Guido
After running “sudo ./ble_scanner.py” when battery is checked I got
INFO - start battery check xx:xx:xx:xx:xx:xx
ERROR - battery service: LE connect error [xx:xx:xx:xx:xx:xx] [Could not create connection: Connection timed out
Config.ini is
[Settings]
; Use different scanner_name if you have several instances for better debugging
scanner_name=Allarme
; By default hci0 in RPI3, but you can check with "hciconfig" command
bt_interface=hci0
; Domoticz IP and UDP port where plugin runs
server_ip=127.0.0.1
server_port=2221
; Check battery if signal strength >= setting
; Connection will not be established if signal is very low
battery_check_rssi_threshold=-75
; Time to check battery. 24h. Interval check_time + 30min
battery_check_time=03:00
; Attempts to check in time interval when beacon available
battery_check_attempts=2
; Beacon MAC address
[xx:xx:xx:xx:xx:xx]
; For better debug
label=Guido
; Supports battery check for nut3 and miband2
; Can be empty (battery check disabled)
battery_service_type=nut3
; Signal strength threshold,
; When signal lower the setting -> beacon info will not send to the plugin
; Can be empty (threshold disabled)
rssi_threshold=
I also wonder how the battery level is copied to Domoticz. Should I add a variable?
Any help would be appreciated
Thanks
Guido
-
- Posts: 7
- Joined: Tuesday 28 August 2018 10:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
Hey. I installed everything according to the instructions. When I run sudo ./ble_scanner.py finds my tags. But in Domoticz with the switches nothing happens.
In the bootloader ble_scanner also does not fall.
In the Domoticz logs only the following message character:
Domoticz version 4.9957
Tell me what could be the problem.
Thank you!!!
In the bootloader ble_scanner also does not fall.
In the Domoticz logs only the following message character:
Code: Select all
2018-09-01 21: 33: 30.461 (Bluetooth Beacon Presence) Pushing 'onHeartbeatCallback' on to queue
2018-09-01 21: 33: 30.466 (Bluetooth Beacon Presence) Processing 'onHeartbeatCallback' message
2018-09-01 21: 33: 30.466 (Bluetooth Beacon Presence) Calling message handler 'onHeartbeat'.
2018-09-01 21: 33: 32.462 (Bluetooth Beacon Presence) Pushing 'onHeartbeatCallback' on to queue
2018-09-01 21: 33: 32.471 (Bluetooth Beacon Presence) Processing 'onHeartbeatCallback' message
2018-09-01 21: 33: 32.471 (Bluetooth Beacon Presence) Calling message handler 'onHeartbeat'.
2018-09-01 21: 33: 34.462 (Bluetooth Beacon Presence) Pushing 'onHeartbeatCallback' on to queue
2018-09-01 21: 33: 34.475 (Bluetooth Beacon Presence) Processing 'onHeartbeatCallback' message
2018-09-01 21: 33: 34.475 (Bluetooth Beacon Presence) Calling message handler 'onHeartbeat'.
2018-09-01 21: 33: 36.463 (Bluetooth Beacon Presence) Pushing 'onHeartbeatCallback' on to queue
2018-09-01 21: 33: 36.480 (Bluetooth Beacon Presence) Processing 'onHeartbeatCallback' message
2018-09-01 21: 33: 36.481 (Bluetooth Beacon Presence) Calling message handler 'onHeartbeat'.
Domoticz version 4.9957
Tell me what could be the problem.
Thank you!!!
-
- Posts: 179
- Joined: Friday 12 July 2013 13:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta Ch
- Location: The Netherlands
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
The moment I start the ble_scanner, domoticz crashes.
See below.
Anyone encountered that problem also?
2018-09-03 10:00:13.813 Error: Domoticz(pid:4679, tid:4706('PluginMgr_IO')) received fatal signal 11 (Segmentation fault)
2018-09-03 10:00:13.813 Error: siginfo address=0x15, address=0x7617d044
I also noticed that Domoticz crashes, the moment anything is adjusted within the hardware setting of the plugin.
Version: 4.9980
Build Hash: 291b22ab
Compile Date: 2018-09-02 17:46:27
dzVents Version: 2.4.7
Python Version: 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170124]
I opened an issue at github: https://github.com/mrin/domoticz-bt-presence/issues/5
See below.
Anyone encountered that problem also?
2018-09-03 10:00:13.813 Error: Domoticz(pid:4679, tid:4706('PluginMgr_IO')) received fatal signal 11 (Segmentation fault)
2018-09-03 10:00:13.813 Error: siginfo address=0x15, address=0x7617d044
I also noticed that Domoticz crashes, the moment anything is adjusted within the hardware setting of the plugin.
Version: 4.9980
Build Hash: 291b22ab
Compile Date: 2018-09-02 17:46:27
dzVents Version: 2.4.7
Python Version: 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170124]
I opened an issue at github: https://github.com/mrin/domoticz-bt-presence/issues/5
-
- Posts: 7
- Joined: Tuesday 28 August 2018 10:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
At me as it was found out a problem with Domotikz not only with this plugin, but also with a script from this branch viewtopic.php?f=28&t=10640&p=190282#p190282
Those. as soon as the search for bluetooth tags begins, Domoticz immediately begins to behave inadequately.
Those. as soon as the search for bluetooth tags begins, Domoticz immediately begins to behave inadequately.
-
- Posts: 179
- Joined: Friday 12 July 2013 13:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta Ch
- Location: The Netherlands
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
@Grinders
Thanks for the link.
I tested it with multiple setups on different raspberry machines, but the moment the ble scanner starts and sends the first packet to the raspberry with the plugin running, domoticz crashes.
A question, is it possible to change anything within the plugin, or does it crash also in your setup? The moment I change something, (e.g ip address), domoticz crashes.
Thanks for the link.
I tested it with multiple setups on different raspberry machines, but the moment the ble scanner starts and sends the first packet to the raspberry with the plugin running, domoticz crashes.
A question, is it possible to change anything within the plugin, or does it crash also in your setup? The moment I change something, (e.g ip address), domoticz crashes.
- Ascari
- Posts: 30
- Joined: Thursday 28 September 2017 21:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9
- Location: Belgium
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
Hello,
I try with new rpi 3b+ but not working.
I use the other methode before but I like your layout and more WAF.
I work with the last stable domoticz and I don't see the puglin in my hardware list.
I try with new rpi 3b+ but not working.
I use the other methode before but I like your layout and more WAF.
I work with the last stable domoticz and I don't see the puglin in my hardware list.
-
- Posts: 179
- Joined: Friday 12 July 2013 13:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta Ch
- Location: The Netherlands
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
@Ascari
Check your log when Domoticz starts. Likely you will see an error that the libpython3.x library is not installed.
Check the following threat; http://www.domoticz.com/forum/viewtopic ... 2&start=20
Install per;
Check your log when Domoticz starts. Likely you will see an error that the libpython3.x library is not installed.
Check the following threat; http://www.domoticz.com/forum/viewtopic ... 2&start=20
Install per;
Code: Select all
sudo apt-get install libpython3.5-dev
- Ascari
- Posts: 30
- Joined: Thursday 28 September 2017 21:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9
- Location: Belgium
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
@Holland
Thx now I see the plugin in my hardware.
The port is ok 2221 with netstat -a but I don't have update.
My logs
pi@raspberrypi:~/domoticz/plugins/bt-presence $ sudo ./ble_scanner.py
2018-09-05 16:58:33 - INFO - Ok hci0 interface Up n running !
2018-09-05 16:58:34 - DEBUG - new bt socket
2018-09-05 16:58:34 - DEBUG - Connected to bluetooth device hci0
Thx now I see the plugin in my hardware.
The port is ok 2221 with netstat -a but I don't have update.
My logs
- Spoiler: show
pi@raspberrypi:~/domoticz/plugins/bt-presence $ sudo ./ble_scanner.py
2018-09-05 16:58:33 - INFO - Ok hci0 interface Up n running !
2018-09-05 16:58:34 - DEBUG - new bt socket
2018-09-05 16:58:34 - DEBUG - Connected to bluetooth device hci0
-
- Posts: 179
- Joined: Friday 12 July 2013 13:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta Ch
- Location: The Netherlands
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
Assuming you have BlueZ 5.43 installed, please try to compile BlueZ 5.50. I have it running, and my scanner is working fine. But that is only the scanner part, my plugin still crashes, the moment it receives the first scanner packages. I'm still working on that to get it resolved.
See below the compile steps
Code: Select all
2018-09-05 21:24:44 - INFO - Ok hci0 interface Up n running !
2018-09-05 21:24:45 - DEBUG - new bt socket
2018-09-05 21:24:45 - DEBUG - Connected to bluetooth device hci0
2018-09-05 21:24:49 - INFO - dd:48:14:dc:44:68 RSSI -86 - key tag
2018-09-05 21:24:53 - INFO - dd:48:14:dc:44:68 RSSI -87 - key tag
2018-09-05 21:24:56 - INFO - dd:48:14:dc:44:68 RSSI -81 - key tag
2018-09-05 21:25:00 - INFO - dd:48:14:dc:44:68 RSSI -87 - key tag
etc
Code: Select all
sudo systemctl stop bluetooth
sudo apt-get update
sudo apt-get install libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev
# latest http://www.bluez.org/download/ (User Space Package)
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.50.tar.xz
tar xf bluez-5.50.tar.xz
cd bluez-5.50
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-library
make
sudo make install
sudo ln -svf /usr/libexec/bluetooth/bluetoothd /usr/sbin/
sudo install -v -dm755 /etc/bluetooth
sudo install -v -m644 src/main.conf /etc/bluetooth/main.conf
sudo systemctl daemon-reload
sudo systemctl start bluetooth
bluetoothd --version
# should now print 5.50
-
- Posts: 179
- Joined: Friday 12 July 2013 13:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta Ch
- Location: The Netherlands
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
Update.
I'm a few steps further on, as the crash problem has been resolved for now.
I removed the whole domoticz directory, and reinstalled the stable version (4.9700) of domoticz.
Version: 4.9700
Build Hash: a3a45906
Compile Date: 2018-06-23 16:24:51
dzVents Version: 2.4.6
Python Version: 3.4.4 (default, Apr 17 2016, 16:02:33) [GCC 5.3.1 20160409]
Uptime: 15 Hours, 30 seconds
The Bluetooth Beacon Presence Detection plugin is running as expected, and the switch responds to the scanner.
Now further testing
I'm a few steps further on, as the crash problem has been resolved for now.
I removed the whole domoticz directory, and reinstalled the stable version (4.9700) of domoticz.
Version: 4.9700
Build Hash: a3a45906
Compile Date: 2018-06-23 16:24:51
dzVents Version: 2.4.6
Python Version: 3.4.4 (default, Apr 17 2016, 16:02:33) [GCC 5.3.1 20160409]
Uptime: 15 Hours, 30 seconds
The Bluetooth Beacon Presence Detection plugin is running as expected, and the switch responds to the scanner.
Now further testing
Last edited by Holland on Friday 07 September 2018 8:52, edited 1 time in total.
-
- Posts: 7
- Joined: Tuesday 28 August 2018 10:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
Hmm ... Holland - it's a completely coordinated way to solve the problem))))
Can you please tell me how, when reinstalling the gateway Xiaomi began to work? Simply, I somehow tried to rearrange Domoticz so I had problems, the gateway ceased to be visible. Therefore, I think I will refrain from such coordinative measures))), but maybe I will have time for the weekend, I will try and reinstall (just a lot of things have already been done in Domoticz).
Thanks for the help !!!
- Ascari
- Posts: 30
- Joined: Thursday 28 September 2017 21:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9
- Location: Belgium
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
Always same issue.
I install in rpi3 b Jessie it's work when I update to Strech and pi 3b+ nothing work.
I think I keep my old Pi
I install in rpi3 b Jessie it's work when I update to Strech and pi 3b+ nothing work.
I think I keep my old Pi
-
- Posts: 179
- Joined: Friday 12 July 2013 13:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta Ch
- Location: The Netherlands
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
@Grinders.
Had no choice, than to delete the whole thing, as almost every plugin ran unstable, e.g the standard examples, like Ping and UDP. So I don't know what the problem was, but at least its running stable now.
I have not installed the Xiaomi gateway
Had no choice, than to delete the whole thing, as almost every plugin ran unstable, e.g the standard examples, like Ping and UDP. So I don't know what the problem was, but at least its running stable now.
I have not installed the Xiaomi gateway
-
- Posts: 7
- Joined: Tuesday 28 August 2018 10:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
Hey. I also decided to completely demolish domoticz and put a stable version, but when I restored the copy, the system refused to start it. I blame everything on the melcloud plugin, which I initially remembered worked only in the beta version. And the whole topic with domoticz just because of him and started originally. So I had to upgrade to beta and only then everything worked except for bluetooth labels. How to make that when scanning the domoticz system does not slow down. I have no idea. What is most interesting is that there are no errors, but the system brakes and falls off the sensors.Holland wrote: ↑Thursday 06 September 2018 22:38 @Grinders.
Had no choice, than to delete the whole thing, as almost every plugin ran unstable, e.g the standard examples, like Ping and UDP. So I don't know what the problem was, but at least its running stable now.
I have not installed the Xiaomi gateway
-
- Posts: 42
- Joined: Wednesday 13 September 2017 13:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Location: France
- Contact:
Re: Python plugin: Bluetooth Beacon Presence Detection
Hello
This plugin is working great so far but it's flooding my log file. It seems that the script is searching for the beacon every 4 seconds. Thats a lot and I fear that the script will drain the beacon battery very fast.
Is there a way to change the presence check interval ? It could be for example every 15 seconds when the beacon has been last detected, and every 30 seconds when the beacon has not been anymore (away from range)
Thanks
This plugin is working great so far but it's flooding my log file. It seems that the script is searching for the beacon every 4 seconds. Thats a lot and I fear that the script will drain the beacon battery very fast.
Is there a way to change the presence check interval ? It could be for example every 15 seconds when the beacon has been last detected, and every 30 seconds when the beacon has not been anymore (away from range)
Thanks
Re: Python plugin: Bluetooth Beacon Presence Detection
Same problem here: hardware update from RPI 3 to RPI 3 B+ and it does not detect nuts anymore.
I can see them with hcitool lescan but ble_scanner does not see them....
Bluez updated to 5.50 but no luck....
I can see them with hcitool lescan but ble_scanner does not see them....
Bluez updated to 5.50 but no luck....
Re: Python plugin: Bluetooth Beacon Presence Detection
No news about this?
Who is online
Users browsing this forum: No registered users and 0 guests