[Node-RED] BLE Presence Detection flow

Post Reply
User avatar
Posts: 849
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy

[Node-RED] BLE Presence Detection flow

Post by emme » Friday 07 September 2018 16:27


Here is my brand new flow for detecting BLE presence and apply changes to domoticz server.

  • NodeRed
  • node-red-contrib-bleacon installed via palette management
  • MQTT server installed
  • MQTT Hardware installed in Domoticz (and setted to receive domoticz/in)
  • Domoticz server (of course ;) )
Cattura-4.jpg (87.92 KiB) Viewed 122 times
node Seek and set HOME is the current backup configuration, it will not appear in the final release :P :P

On NodeRed startup the inject Config will create the needed context variables and config (you don't need to press it for now).
You will need to edit the Initial Config node to include the correct configuration of your BLE devices (see CONFIG section). After each change you will need to deploy the flow to commit the changes

From this point on the flow is completely automated:
The inject Impulse will send a signal every 45 seconds (you can edit the node and set) that scan Toggle convert to a true/false toggle (nomen omen). This is used to start and stop the BLE Scan.

BLE Scan will discover EVERY BLE device in range and will send a message for each device detected (with no duplicates) and pass it to the new_MqttSetHome node. It will look for the device mac address and if it match with the configuration it will prepare the MQTT telegram to be sent to domoticz

When scan Toggle send False the BLE Scan sto scanning and new_MqttSetAway check the configuration and look for those devices that have not been found during the last scan.
If so, it will send the OFF telegrams to Domoticz via MQTT

That's all...

Initial Config needs to be edited with the array of BLE you want to seek for and you have to follow this structure:

Code: Select all

var deviceConfig = [
        ["BLE Mac Address", "DeviceNameWithNoSpaces",  Domoticz Switch IDX, Domoticz Switch Update, Domoticz Variable IDX, Domoticz Variable Update, Domoticz Variable Update with RSSI]

Code: Select all

var deviceConfig = [
        ["001122334455", "nut1Device",  10, true, 0, false, false],
        ["AABBCCDDEE", "nut2Device",  11, true, 1, true, true],
        ["AABBCCDDEE", "nut3Device",  11, false, 2, true, false]
With this configuration we can say that:
nut1Device: switch ON/OFF device 10, no variable working
nut2Device: switch ON/OFF device 11, update variable 1 with RSSI value (when found it will have RSSI value, when not it will show AWAY)
nut2Device: no switch operation (idx is useless at this point), update variable 2 only with HOME/AWAY value (note last parameter is false)

This is it!
I'm now finalizing few things and clean up the code... then I will update this topic with the flow to paste to nodeRed
Hope you will enjoy it and willing to ear your opinion about :P

of course this can be applied to any BLE device, not only related to personal presence...
ie: check if a ble smartTV is on... a BLE tag on the car key in in the house... and stuff like that...
The most dangerous phrase in any language is:
"We always done this way"

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest