Bluetooth - general help

Hi everyone,

[RaspberryPi 3B+ and openhabian 1.5 running OH stable 2.5.7]

I would like to use bluetooth for presence detection and I know there are a lot of threads about this here.
Unfortunately I did not find what I was looking for.

First of all:
I used the 3rd party bluetooth from @vkolotov uccesfully with my FlowerCare (Xiaomi).
However, the connection is unreliable, so I decided to use the “official” OH bluetoth binding for presence detection.

Now my questions:
I have installed the bluetooth binding and used this help to make it run:

I can see multiple devices running
sudo hcitool lescan

I also see these in PaperUI some as Bluetooth Device (Apple, Inc.) - none of mine though - possibly the neighbours’.

So why don’t I see my MAC adresses there? And what kind of Device is the iphone (BLE, Beacon, Generic, …)

So it seems bluetooth is working, but I dont see my devices (except My Sony TV)

EDIT:
I was able to discover my iPhone (with the right MAC) automatically in PaperUI, but there is no MAC visible in the config!?

If I want to add it manually ther are too many choices for me - which is the right one?
Bluethooth Deivce / Connected BT Device?

When trying to connect with bluetoothctl I get:

[bluetooth]# connect D0:C5:F3:xx:xx:xx
Attempting to connect to D0:C5:F3:xx:xx:xx
Failed to connect: org.bluez.Error.Failed

Presence monitoring works only moderately well with iOS devices and will probably never satisfy you.

After a long test with iOS devices, I bought Bluetooth tags as a key fob (Gigaset G-Tags) and I am very happy with the solution.

Thanks Kevin

I would be happy if my iPhone is detected somehow (just once not permanently and stable).
In general I work with the Fritzbox TR064 binding, which checks whether my phone is connected to the Wifi. That’s working fine, but takes a while until it’s recognized.

So I hope to get BT work faster for verification and to unlock the door with Danalock.

It seems to work with thevery old bindings from @vkolotov mentioned above:

However, this can not be the (long term) solution and I wonder, if anyone made use of the integrated BT binding?

by the way:
Do you use the BT binding which comes with OH?
If so, what kind of device is the Gigaset configured to?
Beacon?
BLE enabled?
Generic?

No … Shell Script and MQTT.

#########################################
# MQTT presence detection using BT-Tags #
#                           version 0.3 #
#               copyright by eiGelbGeek #
#########################################

#configuration
mqtt_broker_ip="XXX.XXX.XXX.XXX"
mqtt_broker_port="1883"
mqtt_topic="/topic/presence/"
mqtt_items=("GTag_1" "GTag_2" "GTag_3")
BTtag_ids=("XX:XX:XX:XX:XX:XX" "XX:XX:XX:XX:XX:XX" "XX:XX:XX:XX:XX:XX")

#From here changes can lead to loss of function!
filename=/tmp/bluetooth_devices.$$
hcitool lescan > $filename & sleep 15
pkill --signal SIGINT hcitool
sleep 1

for ((i=0;i<${#BTtag_ids[@]};++i)); do
  searchresult=$(grep -c ${BTtag_ids[i]} $filename)
  if [ $searchresult -gt 0 ]; then
      mosquitto_pub -h $mqtt_broker_ip -p $mqtt_broker_port -t $mqtt_topic${mqtt_items[i]}/status -m ON
  else
      mosquitto_pub -h $mqtt_broker_ip -p $mqtt_broker_port -t $mqtt_topic${mqtt_items[i]}/status -m OFF
  fi
done
rm $filename

Alright - thanks for sharing.
I will consider to use this instead, because it seems a lot of people here prefer the scripting approach.
Possibly for a reason :wink: