1.1.0 • Published 10 months ago

@mschaeffler/node-red-bthome v1.1.0

Weekly downloads
-
License
LGPL-2.1
Repository
github
Last release
10 months ago

@mschaeffler/node-red-bthome

A Node Red node to decrypt and decode raw data frames from BT-Home sensors.

image of example flow

At the moment these sensors are implemented and tested:

  • Shelly BLU Door/Window
  • Shelly BLU H&T
  • Shelly BLU Button 1
  • Shelly BLU Button Tough 1
  • Shelly BLU RC Button 4
  • Shelly BLU Wall Switch 4
  • Shelly BLU Motion

Capture of Raw Frames

The raw data frames are captured by Shelly devices with Bluetooth (Gen2 up to Gen4) and then sent via MQTT to Node-Red.

This is the script to be used.

Encryption

This node can decrypt encrypted messages, if the AES key is set in the devices parameter.

Install

$ npm install @mschaeffler/node-red-bthome

Input

msg.typedescription
payloadobjectdata from Shelly script

msg.payload

Only the first two values are needed, the others are optional.

msg.payloadtypedescription
addrstringmac of the BT-Home device (needed)
dataarray of bytesraw BT-Home message (needed)
rssinumbersignal strength
timenumberJavscript timestamp of the reception
gatewaystringname of the geteway

This is an example of such a message payload:

{
    "addr":    "11:22:33:44:55:66",
    "rssi":    -85,
    "time":    1745395033113,
    "gateway": "Shelly Gateway",
    "data":    [68,0,164,1,100,46,56,69,43,255]
}

Outputs

There are two output ports: 1. one for meassurement values (states) 2. one for actions done with the devices (events)

State

msg.typedescription
topicstringState-Prefix + name of the device
payloadobjectdecoded state data

Events

msg.typedescription
topicstringEvent-Prefix + name of the device
payloadobjectdata of the decoded event

Parameters

configtypedescription
DevicesJSONconfiguration of the BT-Home devices
counter is timeBooleanthe counter in encrypted messages is checked again the actual time
Status-Prefixstringprefix for the topic for state output
Event-Prefixstringprefix for the topic for event output
Context-Variablestringname of the variable in flow context storage
Contextstorestringcontext store to be used

Device-Configuration

With this JSON string the installed BT-Home devices are configured:

{
    "<mac address of the device>": { "topic": "<name of the device>", "key": "<encryption key, if device is encrypted>" }
}

An example for such a config from the unit tests:

{
    "11:22:33:44:55:66": { "topic": "dev_unencrypted_1" },
    "00:01:02:03:04:05": { "topic": "dev_unencrypted_2" },
    "00:10:20:30:40:50": { "topic": "dev_encrypted_1", "key": "00112233445566778899AABBCCDDEEFF" },
    "00:00:00:00:00:00": { "topic": "dev_encrypted_2", "key": [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] }
}

Context storage

All recorded data can be stored in a flow context variable for

  • initialisation
  • statistics
  • visualisation

Example:

{
    "dev_unencrypted_1":
    {
        "pid":       164,
        "time":      1745395033113,
        "encrypted": false,
        "battery":   100,
        "gw":        { "Shelly Gateway": { "time": 1745395033113, "rssi":-85 } },
        "data":      { "humidity":56, "temperature":-21.3 }
    }
}

If content storage is active, statistical data is also stored in a variable with the suffix -stat:

{ ok:0, err:0, old:0, dup:0 }

Example Flow

example flow

Author

Mathias Schäffler

License

LGPL-2.1

1.1.0

10 months ago

1.0.0

10 months ago

0.5.1

11 months ago

0.5.0

11 months ago

0.4.4

12 months ago

0.4.1

12 months ago

0.4.0

12 months ago

0.3.1

12 months ago

0.3.0

12 months ago

0.2.3

12 months ago

0.2.2

12 months ago

0.2.1

12 months ago

0.2.0

12 months ago

0.1.3

12 months ago

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago