Skip to content

Commit

Permalink
[BT] Device Tracker & Room Presence separation and clarification
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiH committed Jan 25, 2024
1 parent a7f43ed commit 5c2ddf3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/integrate/home_assistant.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ template:

### MQTT Room Presence

The publication into presence topic needs to be activated [here is the command](../use/ble.md)
For the publication into the presence topic the following needs to be activated - [here is the command](../use/ble.html#setting-if-the-gateway-publish-into-home-assistant-home-presence-topic-default-false-available-with-ha-discovery)

```yaml
sensor:
Expand Down
20 changes: 10 additions & 10 deletions docs/use/ble.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Versatile BLE gateway that scans and decodes data from various Blue
# BLE gateway

The manufacturer agnostic BLE gateway acts as a powerful BLE scanner and decoder of [Bluetooth devices](https://compatible.openmqttgateway.com/index.php/devices/ble-devices/), allowing you to visualize and analyze information from a wide range of sensors.
It can also act as a presence detection gateway by reading the nearby BLE tags or tracker.
It can also act as a device tracker and room presence detection gateway by receiving nearby BLE devices and trackers.

Data are transmitted to an MQTT broker, where it can be used to trigger events and rules, as well as displayed, stored and processed in your favorite controller (Home Assistant, OpenHAB, Jeedom, Domoticz, ioBroker or any MQTT compatible software).

Expand All @@ -19,7 +19,8 @@ With the ability to monitor and analyze data such as temperature, humidity, mois
* BLE to MQTT gateway, tens of [Bluetooth devices](https://compatible.openmqttgateway.com/index.php/devices/ble-devices/) supported thanks to Theengs Decoder library. The plug uses an ESP32 acting as a BLE to Wifi gateway to scan, decode and forward the data of the nearby sensors,
* Smart plug that can be controlled remotely,
* Energy consumption monitoring,
* Presence detection (beta).
* Device tracker
* Room presence detection (beta).

[![Theengs plug view](../img/Theengs-Plug-OpenMQTTGateway.png)](https://shop.theengs.io/products/theengs-plug-smart-plug-ble-gateway-and-energy-consumption)

Expand Down Expand Up @@ -55,12 +56,10 @@ Once the data has been transmitted to the MQTT broker, it can be easily integrat

Examples of compatible sensors among [our list](https://decoder.theengs.io/devices/devices_by_brand.html: Mi Flora, Mi jia, LYWDS02, LYWSD03MMC, ClearGrass, Mi scale, iBBQ, TPMS

## Receiving signals from BLE tracker devices for Presence detection
The gateway can detect BLE trackers from Tile, Nut, TagIt and iTag, as well as other devices with additional properties decoding like Mi Band, Amazfit, RuuviTag and others indicated as Presence Trackers in the [compatible BLE devices list](https://decoder.theengs.io/devices/devices.html), and automatically creates a device tracker entity following the Home Assistant discovery convention (if auto discovery is activated).
To do this activate the "BT: Publish HASS presence" switch in your controller or send the following MQTT command to your broker:
`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m '{"hasspresence":true}'`
## Receiving signals from BLE devices for Device Tracker Presence detection
The gateway will detect BLE trackers from Tile, Nut, TagIt and iTag, as well as other devices with additional properties decoding like Mi Band, Amazfit, RuuviTag and others indicated as Device Trackers in the [compatible BLE devices list](https://decoder.theengs.io/devices/devices.html), and automatically creates a device tracker entity following the Home Assistant discovery convention (if auto discovery is activated).

The entity created can be attached to a person to leverage presence detection. The `away` or `not home` state is triggered if the BLE tracker is not detected during the timer defined by `presenceawaytimer`.
The devicen tracker entity created can be attached to a person to leverage presence detection. The `away` or `not home` state is triggered if the BLE tracker is not detected during the timer defined by `presenceawaytimer`.

![Away home Home assistant view](../img/OpenMQTTGateway-BLE-tracker-Home-Assistant.png)

Expand All @@ -72,16 +71,17 @@ By default `presenceawaytimer` is set to 120s, you can change it from the slider

Generally BLE devices will not broadcast if they are paired so you may need to ensure your beacons is unpaired/disconnected before it will be seen by the gateway.

Consider the distance estimation as a beta feature.

Note that you can find apps to simulate beacons and do some tests like [Beacon simulator](https://play.google.com/store/apps/details?id=net.alea.beaconsimulator)

iOS version >=10 devices advertise without an extra app MAC address, nevertheless this address [changes randomly](https://github.com/1technophile/OpenMQTTGateway/issues/71) and cannot be used for presence detection. You must install an app to advertise a fixed MAC address.
Apple iOS version >=10 devices advertise without an extra app MAC address, nevertheless this address [changes randomly](https://github.com/1technophile/OpenMQTTGateway/issues/71) and can currently only be used with [Theengs Gateway](https://gateway.theengs.io/) and its [Identity MAC Address and Identity Resolving Key](https://gateway.theengs.io/use/use.html#getting-identity-resolving-key-irk-for-apple-watch-iphone-and-ipad) feature.

::: tip INFO
The `presenceawaytimer` is also used to reset the state of the PIR/motion sensors to `off` when using HA MQTT discovery convention. If the Sensor does not detect a motion, its state will be automatically set to `off` after the `presenceawaytimer`.
:::

## Receiving signals from BLE devices for Room Presence detection
To do this activate the "BT: Publish Room presence" switch in your controller or send the following MQTT command to your broker: mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m '{"hasspresence":true}'

## Receiving signals from BLE devices with accelerometers for movement detection
The gateway is designed to detect BLE trackers from BlueCharm and automatically create a binary sensor entity in accordance with the Home Assistant discovery convention, provided that auto discovery is enabled.

Expand Down
2 changes: 1 addition & 1 deletion main/ZmqttDiscovery.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ void pubMqttDiscovery() {
btPresenceParametersDiscovery();

createDiscovery("switch", //set Type
subjectBTtoMQTT, "BT: Publish HASS presence", (char*)getUniqueId("hasspresence", "").c_str(), //set state_topic,name,uniqueId
subjectBTtoMQTT, "BT: Publish Room presence", (char*)getUniqueId("hasspresence", "").c_str(), //set state_topic,name,uniqueId
will_Topic, "", "{{ value_json.hasspresence }}", //set availability_topic,device_class,value_template,
"{\"hasspresence\":true,\"save\":true}", "{\"hasspresence\":false,\"save\":true}", "", //set,payload_on,payload_off,unit_of_meas,
0, //set off_delay
Expand Down
2 changes: 1 addition & 1 deletion main/config_BT.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ extern String stateBTMeasures(bool);
#endif

#ifndef HassPresence
# define HassPresence false //false if we publish into Home Assistant presence topic
# define HassPresence false //true if we publish into Home Assistant presence topic
#endif

#define HMSerialSpeed 9600 // Communication speed with the HM module, softwareserial doesn't support 115200
Expand Down

0 comments on commit 5c2ddf3

Please sign in to comment.