Page 2 of 3

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Tuesday 05 December 2017 21:01
by EddyG
I tried TCP/IP, but the same problem exists with the 127.0.0.1 address.

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Saturday 09 December 2017 1:54
by lamouette
works like a charm, many thanks !

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Saturday 09 December 2017 11:47
by schulpr
Hi,

For some reason I can't get auto starting to work after a reboot of my pi (with stretch lite).

After a manual start it works flawless.

I hope that someone can help me further with this.

Kind regards, Rob

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Saturday 09 December 2017 20:31
by mrinner
@schulpr

ble_scanner.sh added as service?
If yes, try to update locally this line in ble_scanner.py to 10+ attempts.
https://github.com/mrin/domoticz-bt-pre ... er.py#L177
By default ~ 25sec (5 attempts * 5sec sleep) for check hci is RUNNING.

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Saturday 09 December 2017 21:37
by schulpr
@mrinner

I increased the setting to 25 but that doesn't help. I just followed the steps as described. I didn't add any lines to a script. Do I need to?

Thanks for your help!

Rob

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Sunday 10 December 2017 8:11
by mrinner
Can you see which status when service not started:
sudo service ble_scanner status

Also then try to run "hciconfig" without "sudo" and check string "RUNNING" in output.

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Sunday 10 December 2017 15:00
by schulpr
Hi,

This is the output with "sudo service ble_scanner status":
Dec 10 14:47:08 raspberrypi sudo[389]: pam_unix(sudo:session): session closed for user root
Dec 10 14:47:09 raspberrypi sudo[412]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/local/bin/hciconfig hci0 up
Dec 10 14:47:09 raspberrypi sudo[412]: pam_unix(sudo:session): session opened for user root by (uid=0)
Dec 10 14:47:10 raspberrypi sudo[412]: pam_unix(sudo:session): session closed for user root
Dec 10 14:47:10 raspberrypi sudo[423]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/local/bin/hciconfig hci0 down
Dec 10 14:47:10 raspberrypi sudo[423]: pam_unix(sudo:session): session opened for user root by (uid=0)
Dec 10 14:47:10 raspberrypi sudo[423]: pam_unix(sudo:session): session closed for user root
Dec 10 14:47:11 raspberrypi sudo[481]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/local/bin/hciconfig hci0 up
Dec 10 14:47:11 raspberrypi sudo[481]: pam_unix(sudo:session): session opened for user root by (uid=0)
Dec 10 14:47:12 raspberrypi sudo[481]: pam_unix(sudo:session): session closed for user root

hciconfig gives:
hci0: Type: BR/EDR Bus: USB
BD Address: 00:15:83:EE:93:F0 ACL MTU: 310:10 SCO MTU: 64:8
UP RUNNING
RX bytes:3162 acl:0 sco:0 events:132 errors:0
TX bytes:1932 acl:0 sco:0 commands:99 errors:0

In the domoticz log I see a lot of lines with:
Calling message handler 'onHeartbeat'.

But the switches are staying off.

Does this info tell you something?

Regards, Rob

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Monday 11 December 2017 11:07
by mrinner
In logs I see several attempts to startup and seems like hci0 was not ready.
In the domoticz log I see a lot of lines with:
Calling message handler 'onHeartbeat'.
in Debug plugin mode this is ok. Plugin checks timeout expiration on each heartbeat.

I will add debug logging in file as option for ble_scanner, maybe on this week.

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Thursday 14 December 2017 13:48
by mrinner
@schulpr

Logging in file added. Just git pull updates and uncomment lines in ble_scanner.sh

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Friday 15 December 2017 7:55
by schulpr
@ mrinner,

My knowledge is between noob and hard learning beginner. Can you please help me a bit further? Were do I add this command? In the folder were the plugin is it doesn't work.

Thanks for your help!

Rob

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Friday 15 December 2017 10:33
by mrinner
Go to the plugin folder "bt-presence", then "git pull"
Then "nano ble_scanner.sh" and uncomment lines + check path to log file:

Code: Select all

DAEMON_ARGS="$DAEMON_ARGS --log /home/pi/domoticz/plugins/bt-presence/ble_scanner.log"
DAEMON_ARGS="$DAEMON_ARGS --loglevel debug"

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Friday 15 December 2017 11:29
by schulpr
Hi again,

That was easy :-). I got an error in the update process because it refused to override my config file. I decided to delete the current version and start all over again. Something strange happened, it worked!

So I tried another reboot and it didn't worked anymore. In the log everything seems fine, the process is running correct.

What it doesn't do is switch the switch that is created. I renamed it but that should be the problem I think? This is the content of the log file:

2017-12-15 11:25:26 - INFO - Ok hci0 interface Up n running !
2017-12-15 11:25:28 - DEBUG - new bt socket
2017-12-15 11:25:28 - DEBUG - Connected to bluetooth device hci0
2017-12-15 11:25:35 - INFO - ed:6a:79:4d:7f:76 RSSI -74 - NUT1
2017-12-15 11:25:35 - INFO - ed:6a:79:4d:7f:76 RSSI -78 - NUT1
2017-12-15 11:25:43 - INFO - ed:6a:79:4d:7f:76 RSSI -69 - NUT1
2017-12-15 11:25:47 - INFO - ed:6a:79:4d:7f:76 RSSI -78 - NUT1
2017-12-15 11:26:03 - INFO - ed:6a:79:4d:7f:76 RSSI -75 - NUT1
2017-12-15 11:26:07 - INFO - ed:6a:79:4d:7f:76 RSSI -75 - NUT1
2017-12-15 11:26:15 - INFO - ed:6a:79:4d:7f:76 RSSI -78 - NUT1
2017-12-15 11:26:23 - INFO - ed:6a:79:4d:7f:76 RSSI -69 - NUT1
2017-12-15 11:26:30 - INFO - ed:6a:79:4d:7f:76 RSSI -75 - NUT1
2017-12-15 11:26:34 - INFO - ed:6a:79:4d:7f:76 RSSI -70 - NUT1
2017-12-15 11:26:38 - INFO - ed:6a:79:4d:7f:76 RSSI -78 - NUT1
2017-12-15 11:26:42 - INFO - ed:6a:79:4d:7f:76 RSSI -75 - NUT1
2017-12-15 11:26:46 - INFO - ed:6a:79:4d:7f:76 RSSI -69 - NUT1
2017-12-15 11:26:50 - INFO - ed:6a:79:4d:7f:76 RSSI -79 - NUT1
2017-12-15 11:26:53 - INFO - ed:6a:79:4d:7f:76 RSSI -75 - NUT1
2017-12-15 11:26:57 - INFO - ed:6a:79:4d:7f:76 RSSI -69 - NUT1

I doesn't grow any further than this.

This is the log when I start the process in terminal:

pi@raspberrypi:~/domoticz/plugins/bt-presence $ sudo ./ble_scanner.py
2017-12-15 11:37:05 - INFO - Ok hci0 interface Up n running !
2017-12-15 11:37:07 - DEBUG - new bt socket
2017-12-15 11:37:07 - DEBUG - Connected to bluetooth device hci0
2017-12-15 11:37:15 - INFO - ed:6a:79:4d:7f:76 RSSI -78 - NUT1
2017-12-15 11:37:19 - INFO - ed:6a:79:4d:7f:76 RSSI -74 - NUT1
2017-12-15 11:37:27 - INFO - ed:6a:79:4d:7f:76 RSSI -74 - NUT1
2017-12-15 11:37:30 - INFO - ed:6a:79:4d:7f:76 RSSI -74 - NUT1
2017-12-15 11:37:38 - INFO - ed:6a:79:4d:7f:76 RSSI -80 - NUT1
2017-12-15 11:37:42 - INFO - ed:6a:79:4d:7f:76 RSSI -69 - NUT1
2017-12-15 11:37:50 - INFO - ed:6a:79:4d:7f:76 RSSI -74 - NUT1
2017-12-15 11:37:54 - INFO - ed:6a:79:4d:7f:76 RSSI -69 - NUT1
2017-12-15 11:37:57 - INFO - ed:6a:79:4d:7f:76 RSSI -78 - NUT1
2017-12-15 11:38:01 - INFO - ed:6a:79:4d:7f:76 RSSI -75 - NUT1
2017-12-15 11:38:05 - INFO - ed:6a:79:4d:7f:76 RSSI -69 - NUT1
2017-12-15 11:38:09 - INFO - ed:6a:79:4d:7f:76 RSSI -78 - NUT1
2017-12-15 11:38:13 - INFO - ed:6a:79:4d:7f:76 RSSI -75 - NUT1
2017-12-15 11:38:17 - INFO - ed:6a:79:4d:7f:76 RSSI -69 - NUT1
2017-12-15 11:38:21 - INFO - ed:6a:79:4d:7f:76 RSSI -78 - NUT1
2017-12-15 11:38:24 - INFO - ed:6a:79:4d:7f:76 RSSI -75 - NUT1
2017-12-15 11:38:28 - INFO - ed:6a:79:4d:7f:76 RSSI -69 - NUT1
2017-12-15 11:38:32 - INFO - ed:6a:79:4d:7f:76 RSSI -79 - NUT1
2017-12-15 11:38:36 - INFO - ed:6a:79:4d:7f:76 RSSI -75 - NUT1
2017-12-15 11:38:40 - INFO - ed:6a:79:4d:7f:76 RSSI -69 - NUT1
2017-12-15 11:38:44 - INFO - ed:6a:79:4d:7f:76 RSSI -78 - NUT1
2017-12-15 11:38:48 - INFO - ed:6a:79:4d:7f:76 RSSI -74 - NUT1
2017-12-15 11:38:51 - INFO - ed:6a:79:4d:7f:76 RSSI -80 - NUT1
2017-12-15 11:38:55 - INFO - ed:6a:79:4d:7f:76 RSSI -80 - NUT1
2017-12-15 11:38:59 - INFO - ed:6a:79:4d:7f:76 RSSI -74 - NUT1

This turns my switch on and doesn't stop.

I hope this helps to find a solution.

Thanks once more!

Rob

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Friday 15 December 2017 11:46
by deennoo
Have you try to use a synology as a "scanner" ?

Thanks for this plug in, will try it on serval device (rooted android tv box)

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Friday 15 December 2017 20:21
by mrinner
@schulpr

You can rename created devices as you want, plugin does not relying on name.
First log was immediately after the reboot and log did not grow anymore and "sudo service ble_scanner status" is "active (running)"?
Check what you not run 2 services on the one machine, or some other process maybe use BT.. Discovering can be stopped when hci going down, or bt connecting to some device by other process...

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Monday 08 January 2018 16:59
by EddyG
At the battery check one of my Nut3 came back with only 2 chars.
I had to add/change:

Code: Select all

        bin_value = gatt_output[gatt_output.find("value:") + 6:]
        if len(bin_value) == 2:
             bin_value = bin_value + "00"
        bin_value = bin_value.decode("hex")

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Wednesday 24 January 2018 15:19
by chrispazz
Which is the correct configuration for having correct battery charge reporting with a NUT2?

Thanks

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Thursday 25 January 2018 11:26
by chrispazz
With latest domoticz beta BLE device are no more updating from BLE Scanner....

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Friday 26 January 2018 21:19
by chrispazz
I am the only using this plugin with latest beta?

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Friday 26 January 2018 21:36
by mrinner
@chrispazz

I'm on 3.8805 - my setup works perfect.
Many people have problems with the python plugin system on latest beta...

Re: Python plugin: Bluetooth Beacon Presence Detection

Posted: Friday 26 January 2018 22:32
by chrispazz
@mrinner

thank you for answering me :)

I am on 3.8850 and plugin is running ok looking at logs.
It only seems not to update the devices....

2018-01-26 22:32:00.995 (BLE Presence) Update NUT Green: nValue 1 - sValue 100 - BatteryLevel 255
2018-01-26 22:32:01.598 (BLE Presence) Update NUT White: nValue 1 - sValue 100 - BatteryLevel 255
2018-01-26 22:32:04.855 (BLE Presence) Update NUT Green: nValue 1 - sValue 100 - BatteryLevel 255
2018-01-26 22:32:05.459 (BLE Presence) Update NUT White: nValue 1 - sValue 100 - BatteryLevel 255
2018-01-26 22:32:08.717 (BLE Presence) Update NUT Green: nValue 1 - sValue 100 - BatteryLevel 255
2018-01-26 22:32:09.371 (BLE Presence) Update NUT White: nValue 1 - sValue 100 - BatteryLevel 255