BTHome Components
Available as preview since 1.3.0-beta1
. The API is subject to change.
Available only for Gen3 and Gen2 Pro* devices.
BTHome
components are a subset of dynamic components
for managing Bluetooth devices that emit data in BTHome format.
Both Bluetooth
and the observer
are required to be enabled. If either of them is disabled, an error will be displayed in the component's status.
The management is accomplished through RPC methods within the BTHome
namespace:
BTHome.GetConfig
to obtain the component's configurationBTHome.SetConfig
to update the component's configurationBTHome.GetStatus
to obtain the component's statusBTHome.AddDevice
to create new BTHomeDevice componentBTHome.DeleteDevice
to remove existing BTHomeDevice componentBTHome.AddSensor
to create new BTHomeSensor component (BTHomeDevice must be created first)BTHome.DeleteSensor
to remove existing BTHomeSensor componentBTHome.StartDeviceDiscovery
starts discovery processBTHome.GetObjectInfos
get static information forBTHomeSensor
Available BTHome components:
Methods
Request
BTHome.GetConfig
Does not own configuration at the moment.
BTHome.SetConfig
Does not own configuration at the moment.
BTHome.GetStatus
Find more about the status response properties in status section
BTHome.AddDevice
Properties:
Property | Type | Description |
---|---|---|
| object | Configuration to be used for the new component. Find the config properties in the config section |
| number | Id for the new component. Accepted range: |
Response
The result from calling this method is a JSON object, with the newly generated component key upon success, otherwise it will return an error.
Received attributes:
Property | Type | Description |
---|---|---|
| string | Key of the newly created component. (in format |
BTHome.DeleteDevice
Request
Properties:
Property | Type | Description |
---|---|---|
| number | The id of existing BTHomeDevice component Required |
Response
The result from calling this method is null on success, otherwise it will return an error.
BTHome.AddSensor
Request
Properties:
Property | Type | Description |
---|---|---|
| object | Configuration to be used for the new component. Find the config properties in the config section |
| number | Id for the new component. Accepted range: |
Response
The result from calling this method is a JSON object, with the newly generated component key upon success, otherwise it will return an error.
Received attributes:
Property | Type | Description |
---|---|---|
| string | Key of the newly created component. (in format |
BTHome.DeleteSensor
Request
Properties:
Property | Type | Description |
---|---|---|
| number | The id of existing BTHomeSensor component Required |
Response
The result from calling this method is null on success, otherwise it will return an error.
BTHome.StartDeviceDiscovery
Request
Starts active scan for discovery of BTHome devices
Properties:
Property | Type | Description |
---|---|---|
| number | duration for the scan in seconds, default value is 30s |
During the scanning process, device_discovered
events are emitted, providing information about the discovered device, see example at device_discovered
section. Upon completion of the scanning process, a discovery_done
event is dispatched, see example at discovery_done
.
Response
The result from calling this method is null on success, otherwise it will return an error.
BTHome.GetObjectInfos
Request
Retrieve info for BTHome objects
This method support the same paging mechanism as Shelly.GetComponents
method.
Properties:
Property | Type | Description |
---|---|---|
| number | Index of the component from which to start generating the result Optional |
Response
The result from calling this method is null on success, otherwise it will return an error.
Status
The BTHome component status provides details regarding the availability of a scanning process and errors.
Properties:
Property | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
| object | Available only when scan process is in progress
| |||||||||
| array of type string | Component error conditions. May contain |
Examples
BTHome.GetConfig example
- BTHome.GetConfig HTTP GET Request
- BTHome.GetConfig Curl Request
- BTHome.GetConfig Mos Request
http://192.168.33.1/rpc/BTHome.GetConfig
curl -X POST -d '{"id":1,"method":"BTHome.GetConfig"}' http://${SHELLY}/rpc
mos --port ${PORT} call BTHome.GetConfig
Response
- BTHome.GetConfig HTTP GET Response
- BTHome.GetConfig Curl Response
- BTHome.GetConfig Mos Response
{}
{
"id": 1,
"src": "shelly1pmminig3-84fce63fe000",
"params": {}
}
{}
BTHome.SetConfig example
- BTHome.SetConfig HTTP GET Request
- BTHome.SetConfig Curl Request
- BTHome.SetConfig Mos Request
http://192.168.33.1/rpc/BTHome.SetConfig
curl -X POST -d '{"id":1,"method":"BTHome.SetConfig"}' http://${SHELLY}/rpc
mos --port ${PORT} call BTHome.SetConfig
Response
- BTHome.SetConfig HTTP GET Response
- BTHome.SetConfig Curl Response
- BTHome.SetConfig Mos Response
null
{
"id": 1,
"src": "shelly1pmminig3-84fce63fe000",
"params": null
}
null
BTHome.GetStatus example
- BTHome.GetStatus HTTP GET Request
- BTHome.GetStatus Curl Request
- BTHome.GetStatus Mos Request
http://192.168.33.1/rpc/BTHome.GetStatus
curl -X POST -d '{"id":1,"method":"BTHome.GetStatus"}' http://${SHELLY}/rpc
mos --port ${PORT} call BTHome.GetStatus
Response
- BTHome.GetStatus HTTP GET Response
- BTHome.GetStatus Curl Response
- BTHome.GetStatus Mos Response
{
"errors": [
"observer_disabled"
]
}
{
"id": 1,
"src": "shelly1pmminig3-84fce63fe000",
"params": {
"errors": [
"observer_disabled"
]
}
}
{
"errors": [
"observer_disabled"
]
}
BTHome.AddDevice example
- BTHome.AddDevice HTTP GET Request
- BTHome.AddDevice Curl Request
- BTHome.AddDevice Mos Request
http://192.168.33.1/rpc/BTHome.AddDevice?config={"addr":"3c:2e:f5:71:d5:2a"}
curl -X POST -d '{"id":1,"method":"BTHome.AddDevice","params":{"config":{"addr":"3c:2e:f5:71:d5:2a"}}}' http://${SHELLY}/rpc
mos --port ${PORT} call BTHome.AddDevice '{"config":{"addr":"3c:2e:f5:71:d5:2a"}}'
Response
- BTHome.AddDevice HTTP GET Response
- BTHome.AddDevice Curl Response
- BTHome.AddDevice Mos Response
{
"added": "bthomedevice:201"
}
{
"id": 1,
"src": "shelly1pmminig3-84fce63fe000",
"params": {
"added": "bthomedevice:201"
}
}
{
"added": "bthomedevice:201"
}
BTHome.DeleteDevice example
- BTHome.DeleteDevice HTTP GET Request
- BTHome.DeleteDevice Curl Request
- BTHome.DeleteDevice Mos Request
http://192.168.33.1/rpc/BTHome.DeleteDevice?id=200
curl -X POST -d '{"id":1,"method":"BTHome.DeleteDevice","params":{"id":200}}' http://${SHELLY}/rpc
mos --port ${PORT} call BTHome.DeleteDevice '{"id":200}'
Response
- BTHome.DeleteDevice HTTP GET Response
- BTHome.DeleteDevice Curl Response
- BTHome.DeleteDevice Mos Response
null
{
"id": 1,
"src": "shelly1pmminig3-84fce63fe000",
"params": null
}
null
BTHome.AddSensor example
- BTHome.AddSensor HTTP GET Request
- BTHome.AddSensor Curl Request
- BTHome.AddSensor Mos Request
http://192.168.33.1/rpc/BTHome.AddSensor?config={"addr":"3c:2e:f5:71:d5:2a","obj_id":2,"obj_idx":3}
curl -X POST -d '{"id":1,"method":"BTHome.AddSensor","params":{"config":{"addr":"3c:2e:f5:71:d5:2a","obj_id":2,"obj_idx":3}}}' http://${SHELLY}/rpc
mos --port ${PORT} call BTHome.AddSensor '{"config":{"addr":"3c:2e:f5:71:d5:2a","obj_id":2,"obj_idx":3}}'
Response
- BTHome.AddSensor HTTP GET Response
- BTHome.AddSensor Curl Response
- BTHome.AddSensor Mos Response
{
"added": "bthomesensor:200"
}
{
"id": 1,
"src": "shelly1pmminig3-84fce63fe000",
"params": {
"added": "bthomesensor:200"
}
}
{
"added": "bthomesensor:200"
}
BTHome.DeleteSensor example
- BTHome.DeleteSensor HTTP GET Request
- BTHome.DeleteSensor Curl Request
- BTHome.DeleteSensor Mos Request
http://192.168.33.1/rpc/BTHome.DeleteSensor?id=200
curl -X POST -d '{"id":1,"method":"BTHome.DeleteSensor","params":{"id":200}}' http://${SHELLY}/rpc
mos --port ${PORT} call BTHome.DeleteSensor '{"id":200}'
Response
- BTHome.DeleteSensor HTTP GET Response
- BTHome.DeleteSensor Curl Response
- BTHome.DeleteSensor Mos Response
null
{
"id": 1,
"src": "shelly1pmminig3-84fce63fe000",
"params": null
}
null
BTHome.StartDeviceDiscovery example
- BTHome.StartDeviceDiscovery HTTP GET Request
- BTHome.StartDeviceDiscovery Curl Request
- BTHome.StartDeviceDiscovery Mos Request
http://192.168.33.1/rpc/BTHome.StartDeviceDiscovery?duration=25
curl -X POST -d '{"id":1,"method":"BTHome.StartDeviceDiscovery","params":{"duration":25}}' http://${SHELLY}/rpc
mos --port ${PORT} call BTHome.StartDeviceDiscovery '{"duration":25}'
Response
- BTHome.StartDeviceDiscovery HTTP GET Response
- BTHome.StartDeviceDiscovery Curl Response
- BTHome.StartDeviceDiscovery Mos Response
null
{
"id": 1,
"src": "shelly1pmminig3-84fce63fe000",
"params": null
}
null
BTHome.GetObjectInfos example
- BTHome.GetObjectInfos HTTP GET Request
- BTHome.GetObjectInfos Curl Request
- BTHome.GetObjectInfos Mos Request
http://192.168.33.1/rpc/BTHome.GetObjectInfos?obj_ids=[2,3,4]
curl -X POST -d '{"id":1,"method":"BTHome.GetObjectInfos","params":{"obj_ids":[2,3,4]}}' http://${SHELLY}/rpc
mos --port ${PORT} call BTHome.GetObjectInfos '{"obj_ids":[2,3,4]}'
Response
- BTHome.GetObjectInfos HTTP GET Response
- BTHome.GetObjectInfos Curl Response
- BTHome.GetObjectInfos Mos Response
{
"objects": [
{
"obj_id": 2,
"obj_name": "temperature",
"type": "sensor",
"unit": "° C"
},
{
"obj_id": 3,
"obj_name": "humidity",
"type": "sensor",
"unit": "%"
},
{
"obj_id": 4,
"obj_name": "pressure",
"type": "sensor",
"unit": "hPa"
}
],
"offset": 0,
"count": 3,
"total": 3
}
{
"id": 1,
"src": "shelly1pmminig3-84fce63fe000",
"params": {
"objects": [
{
"obj_id": 2,
"obj_name": "temperature",
"type": "sensor",
"unit": "° C"
},
{
"obj_id": 3,
"obj_name": "humidity",
"type": "sensor",
"unit": "%"
},
{
"obj_id": 4,
"obj_name": "pressure",
"type": "sensor",
"unit": "hPa"
}
],
"offset": 0,
"count": 3,
"total": 3
}
}
{
"objects": [
{
"obj_id": 2,
"obj_name": "temperature",
"type": "sensor",
"unit": "° C"
},
{
"obj_id": 3,
"obj_name": "humidity",
"type": "sensor",
"unit": "%"
},
{
"obj_id": 4,
"obj_name": "pressure",
"type": "sensor",
"unit": "hPa"
}
],
"offset": 0,
"count": 3,
"total": 3
}
Events
device_discovered
example
{
"component": "bthome",
"event": "device_discovered",
"device": {
"addr": "3c:2e:f5:71:d5:2a",
"local_name": "SBBT-002C",
"rssi": -59,
"encrypted": false,
"shelly_mfdata": {
"flags": 25,
"model_id": 1,
"mac": "3c:2e:f5:71:d5:2a"
}
},
"ts": 1706593991.91
}
discovery_done
example
{
"component": "bthome",
"event": "discovery_done",
"device_count": 1,
"ts": 1706593991.91
}