Skip to main content
Version: 1.0

Bluetooth Low Energy

The Bluetooth Low Energy component is called BLE. It handles bluetooth services of a device. The Bluetooth Low Energy component uses BLE as RPC namespace and provides the methods:

It uses the key ble when enumerated in objects including multiple component payloads, like Shelly.GetStatus.

Observer

To support Shelly Bluetooth peripheral devices, the BLE component can act as a perpetual BT LE Observer. When bluetooth is enabled via the enable flag and at least one peripheral device is added to Cloud Relay, or if BTHome functionality is available on the Shelly device and there is at least one created BTHome device, the Shelly device will run a constant passive Bluetooth LE scan and relay received advertisement packets to Shelly Cloud service, to enable scene triggers.

note

Enabling the observer relay functionality might impact BLE advertisement scanner in scripts. A requested interval and window for scanning in scripting might get adjusted to allow for the coexistence of both functionalities.

note

Observer is not applicable for battery-operated devices.

CloudRelay

CloudRelay is a feature of the BLE component supporting Shelly BLU devices managed by the Shelly Cloud, providing information advertised by these devices to the Cloud. It publicly exports List and ListInfos methods, while other functions are internal only.

Methods

BLE.SetConfig

Properties:

PropertyTypeDescription

config

object

Configuration that the method takes

Find more about the config properties in config section

BLE.GetConfig

Find the BLE.GetConfig response properties in config section

BLE.GetStatus

Find more about the status response properties in status section

BLE.CloudRelay.List

Returns a list of MAC adresses for the devices managed by the Cloud.

Request:

The method doesn't take any paramters.

Response:

PropertyTypeDescription

rev

number

Internal revision of the list

addrs

array of strings

The list of MAC addresses for the managed devices

BLE.CloudRelay.ListInfos

Returns extended information about data received from the devices managed by the Cloud. The response is paginated.

Request:

PropertyTypeDescription

offset

number

optional offset of the first item to return, defaults to 0

Response:

PropertyTypeDescription

ts

number

Unix timestamp of the repsonse

offset

number

Offset in the list of the first item in the current page

count

number

Number of items in the current page

total

number

Total number of items in the list

devices

array of objects

PropertyTypeDescription

MAC

object

Information about the device received in its last received advertisement. Device MAC address is used as the object key

PropertyTypeDescription

name

string or null

Device name from the advertisement taken from localname. Will be populated only during active scans

model

number

Internal model id of the device. Will be populated only during active scans, otherwise will show 0 which is invalid model id

sdata

object

Service data from the advertisement. Object keys are UUIDs of the service data and values are their base64 encoded contents. If not present object will be empty.

mdata

object

Manufacturer data from the advertisement. Object keys are manufacturer UUIDs and values are the base64 encoded contents of the data. If not present object will be empty.

last_seen

number

Unix timestamp of the last recieved advertisement

BLE.StartBluTrvAssociations

note

Available only on devices that support BLUTRV devices. Currently Shelly BLU Gateway Gen3

Associate BLUTRV device with the gateway or associate already associated BLUTRV device with BTHome temperature and/or window sensors (BLUHT, BLUDW) which can either be existing or will be added.

Request:

PropertyTypeDescription

blutrv_id

number

optional If not specified discover and associate new BLUTRV device with the gateway or Id of the BluTrv component instance to perform sensor associations (device doesn't need to be in pairing mode in this case)

duration

number

optional Max discovery duration, seconds. Defaults to 30 if not provided.

rssi_thr

number

optional Defaults to -80 if not provided.

Response:

null on success or error

StartBluTrvAssociations will add a status entry when active and will emit status change notifications on start and end.

AssociationsStarted status change:

{"blutrv_assoc":{"duration":30,"started_at":1729259344}}

AssociationsEnded status change:

{"blutrv_assoc":null}

Configuration

The configuration of the Bluetooth Low Energy component shows whether the bluetooth connection is enabled.

PropertyTypeDescription

enable

boolean

True if bluetooth is enabled, false otherwise

rpc

object

Configuration of the rpc service

PropertyTypeDescription

enable

boolean

True if rpc service is enabled, false otherwise

note

Currently only rpc service is implemented, but a global enable flag is maintained for possible other future BLE functionality implementation. If either of the enable flags is set to false the device is not advertised. Changing the configuration requires restart.

Status

PropertyTypeDescription

blutrv_assoc

object

BluTrvAssociations information, present only when associations are active

PropertyTypeDescription

duration

integer

Duration of the current associations proecdure in seconds

started_at

integer

Unix timestamp of the start of the associations procedure

Examples

BLE.GetStatus example

http://192.168.33.1/rpc/BLE.GetStatus

Response

{}

BLE.GetConfig example

http://192.168.33.1/rpc/BLE.GetConfig

Response

{
"enable": true,
"rpc": {
"enable": true
}
}

BLE.SetConfig example

http://192.168.33.1/rpc/BLE.SetConfig?config={"enable":true,"rpc":{"enable":true}}

Response

{
"restart_required": true
}

BLE.CloudRelay.List example

http://192.168.33.1/rpc/BLE.CloudRelay.List

Response

{
"rev": 8,
"addrs": [
"5c:c7:c1:f0:db:60"
]
}

BLE.CloudRelay.ListInfos example

http://192.168.33.1/rpc/BLE.CloudRelay.ListInfos

Response

{
"ts": 1732804839,
"offset": 0,
"count": 1,
"total": 1,
"devices": [
{
"5c:c7:c1:f0:db:60": {
"name": null,
"model": 0,
"sdata": {
"fcd2": "RAAVAWQ6AQ=="
},
"mdata": {},
"last_seen": 1732804835
}
}
]
}

BLE.StartBluTrvAssociations example

http://192.168.33.1/rpc/BLE.StartBluTrvAssociations?blutrv_id=200&duration=120&rssi_thr=-80

Response

null