LNM Components
Available as preview. The API is subject to change.
Available for Gen 2, Gen 3, Gen 4 devices.
For a step-by-step setup walkthrough, see the Local Network Messaging (LNM) — Setup Guide.
LNM (Local Network Messaging) components are a subset of dynamic components for broadcasting and receiving component status updates via UDP multicast on the local network.
Each LNM instance operates independently with its own multicast address, TX components, and UDP socket. Multiple instances can coexist on the same or different multicast groups.
The management is accomplished through RPC methods within the LNM namespace:
LNM.GetConfigto obtain the component's configurationLNM.SetConfigto update the component's configurationLNM.GetStatusto obtain the component's statusLNM.Createto create a new LNM componentLNM.Deleteto remove an existing LNM componentLNM.Callto send an RPC notification to the multicast group
Methods
LNM.GetConfig
Parameters:
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance. Required |
Find more about the config response properties in configuration section
LNM.SetConfig
Request
Parameters:
| Property | Type | Description |
|---|---|---|
| number | Id of the LNM component Required |
| object | Configuration that the method takes |
Find more about the config properties in config section
Response
On success, the response contains restart_required indicating whether a device restart is needed to apply the changes. Changing the addr property requires a restart.
LNM.GetStatus
Parameters:
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance. Required |
Find more about the status response properties in status section
LNM.Create
Request
Parameters:
| Property | Type | Description |
|---|---|---|
| object | Configuration to be used for the new component. Must contain |
| number | Id for the new component. Accepted range: |
Response
The result from calling this method is a JSON object with the id of the newly created component upon success, otherwise it will return an error.
Received attributes:
| Property | Type | Description |
|---|---|---|
| number | Id of the newly created component |
LNM.Delete
Request
Parameters:
| Property | Type | Description |
|---|---|---|
| number | The id of existing LNM component Required |
Response
The result from calling this method is an empty object on success, otherwise it will return an error.
LNM.Call
Send a fire-and-forget RPC notification to the multicast group. All devices on the group with rpc_enable: true will execute the method locally.
rpc_enable must be true on the LNM instance. tx.enable is NOT required for LNM.Call.
Request
Parameters:
| Property | Type | Description |
|---|---|---|
| number | Id of the LNM component. Required |
| string | RPC method name to invoke on remote devices (e.g., |
| object | Parameters for the method. Optional |
Response
| Property | Type | Description |
|---|---|---|
| number | Id of the LNM component that sent the notification |
Configuration
The LNM component configuration contains the multicast address, transmit settings, and receive settings.
Properties:
| Property | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| number | Id of the component instance | |||||||||
| string | Multicast group address in | |||||||||
| boolean | Whether RPC command delivery over multicast is enabled | |||||||||
| object | Transmit settings
| |||||||||
| object | Receive settings
|
Status
The LNM component status provides message statistics.
Properties:
| Property | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| number | Id of the component instance | ||||||||||||
| object | Messaging statistics
|
Wire Protocol
The binary wire protocol is not yet stable and may change in future firmware updates.
Each UDP datagram is prefixed with a 12-byte binary header (little-endian, packed):
| Offset | Size | Field | Description |
|---|---|---|---|
| 0 | 2 | magic | 0x53 0x4C ("SL") |
| 2 | 1 | version | Protocol version (currently 0) |
| 3 | 1 | payload_type | Payload type (1 = status/event) |
| 4 | 2 | payload_len | Payload length in bytes |
| 6 | 2 | meta_len | Meta block length (reserved, currently 0) |
| 8 | 4 | reserved | Reserved for future use |
The datagram layout is: [header (12 bytes)] [payload (payload_len bytes)] [meta (meta_len bytes)].
Example status/event payload
For payload_type 1 (status/event), the payload is JSON. Below is an example with 3 component statuses and 2 events (header stripped):
{
"device": "shellypro4pm-xxxxxxxxxxxx",
"ts": 1774350200.41,
"status": {
"switch:0": {"id": 0, "output": true, "apower": 120.3},
"switch:1": {"id": 1, "output": false, "apower": 0.0},
"em1:0": {"id": 0, "voltage": 237.1, "current": 1.136, "act_power": 269.5}
},
"events": [
{"component": "input:0", "id": 0, "event": "single_push", "ts": 1774350200.41},
{"component": "input:1", "id": 1, "event": "double_push", "ts": 1774350200.41}
]
}
device- Device ID of the senderts- UNIX timestamp of the messagestatus- Component statuses that changed (fullGetStatusoutput per component); omitted when emptyevents- Stateless events (e.g.single_push,double_push,long_push); omitted when empty
Examples
LNM.GetConfig example
- LNM.GetConfig HTTP GET Request
- LNM.GetConfig Curl Request
- LNM.GetConfig Mos Request
http://192.168.33.1/rpc/LNM.GetConfig?id=200
curl -X POST -d '{"id":1,"method":"LNM.GetConfig","params":{"id":200}}' http://${SHELLY}/rpc
mos --port ${PORT} call LNM.GetConfig '{"id":200}'
Response
- LNM.GetConfig HTTP GET Response
- LNM.GetConfig Curl Response
- LNM.GetConfig Mos Response
{
"id": 200,
"addr": "239.1.1.1:3333",
"rpc_enable": false,
"tx": {
"enable": true,
"components": [
"em1:0",
"em1:1",
"em1:2"
]
},
"rx": {
"enable": false
}
}
{
"id": 1,
"src": "shellypro3em-xxxxxxxxxxxx",
"params": {
"id": 200,
"addr": "239.1.1.1:3333",
"rpc_enable": false,
"tx": {
"enable": true,
"components": [
"em1:0",
"em1:1",
"em1:2"
]
},
"rx": {
"enable": false
}
}
}
{
"id": 200,
"addr": "239.1.1.1:3333",
"rpc_enable": false,
"tx": {
"enable": true,
"components": [
"em1:0",
"em1:1",
"em1:2"
]
},
"rx": {
"enable": false
}
}
LNM.SetConfig example
- LNM.SetConfig HTTP GET Request
- LNM.SetConfig Curl Request
- LNM.SetConfig Mos Request
http://192.168.33.1/rpc/LNM.SetConfig?id=200&config={"tx":{"enable":true,"components":["switch:0"]},"rx":{"enable":true}}
curl -X POST -d '{"id":1,"method":"LNM.SetConfig","params":{"id":200,"config":{"tx":{"enable":true,"components":["switch:0"]},"rx":{"enable":true}}}}' http://${SHELLY}/rpc
mos --port ${PORT} call LNM.SetConfig '{"id":200,"config":{"tx":{"enable":true,"components":["switch:0"]},"rx":{"enable":true}}}'
Response
- LNM.SetConfig HTTP GET Response
- LNM.SetConfig Curl Response
- LNM.SetConfig Mos Response
{
"restart_required": false
}
{
"id": 1,
"src": "shellypro3em-xxxxxxxxxxxx",
"params": {
"restart_required": false
}
}
{
"restart_required": false
}
LNM.GetStatus example
- LNM.GetStatus HTTP GET Request
- LNM.GetStatus Curl Request
- LNM.GetStatus Mos Request
http://192.168.33.1/rpc/LNM.GetStatus?id=200
curl -X POST -d '{"id":1,"method":"LNM.GetStatus","params":{"id":200}}' http://${SHELLY}/rpc
mos --port ${PORT} call LNM.GetStatus '{"id":200}'
Response
- LNM.GetStatus HTTP GET Response
- LNM.GetStatus Curl Response
- LNM.GetStatus Mos Response
{
"id": 200,
"stats": {
"tx_msgs": 42,
"rx_msgs": 100,
"since": 1774350141
}
}
{
"id": 1,
"src": "shellypro3em-xxxxxxxxxxxx",
"params": {
"id": 200,
"stats": {
"tx_msgs": 42,
"rx_msgs": 100,
"since": 1774350141
}
}
}
{
"id": 200,
"stats": {
"tx_msgs": 42,
"rx_msgs": 100,
"since": 1774350141
}
}
LNM.Create example
- LNM.Create HTTP GET Request
- LNM.Create Curl Request
- LNM.Create Mos Request
http://192.168.33.1/rpc/LNM.Create?config={"addr":"239.1.1.1:3333"}
curl -X POST -d '{"id":1,"method":"LNM.Create","params":{"config":{"addr":"239.1.1.1:3333"}}}' http://${SHELLY}/rpc
mos --port ${PORT} call LNM.Create '{"config":{"addr":"239.1.1.1:3333"}}'
Response
- LNM.Create HTTP GET Response
- LNM.Create Curl Response
- LNM.Create Mos Response
{
"id": 200
}
{
"id": 1,
"src": "shellypro3em-xxxxxxxxxxxx",
"params": {
"id": 200
}
}
{
"id": 200
}
LNM.Delete example
- LNM.Delete HTTP GET Request
- LNM.Delete Curl Request
- LNM.Delete Mos Request
http://192.168.33.1/rpc/LNM.Delete?id=200
curl -X POST -d '{"id":1,"method":"LNM.Delete","params":{"id":200}}' http://${SHELLY}/rpc
mos --port ${PORT} call LNM.Delete '{"id":200}'
Response
- LNM.Delete HTTP GET Response
- LNM.Delete Curl Response
- LNM.Delete Mos Response
{}
{
"id": 1,
"src": "shellypro3em-xxxxxxxxxxxx",
"params": {}
}
{}
LNM.Call example
- LNM.Call HTTP GET Request
- LNM.Call Curl Request
- LNM.Call Mos Request
http://192.168.33.1/rpc/LNM.Call?id=200&method="Switch.Set"¶ms={"id":0,"on":true}
curl -X POST -d '{"id":1,"method":"LNM.Call","params":{"id":200,"method":"Switch.Set","params":{"id":0,"on":true}}}' http://${SHELLY}/rpc
mos --port ${PORT} call LNM.Call '{"id":200,"method":"Switch.Set","params":{"id":0,"on":true}}'
Response
- LNM.Call HTTP GET Response
- LNM.Call Curl Response
- LNM.Call Mos Response
{
"id": 200
}
{
"id": 1,
"src": "shellypro3em-xxxxxxxxxxxx",
"params": {
"id": 200
}
}
{
"id": 200
}
Events
rx event
When RX is enabled and a message is received, an rx event is fired. These events are delivered to scripts only.
{
"component": "lnm:200",
"name": "lnm",
"id": 200,
"now": 1774422514.39,
"info": {
"component": "lnm:200",
"id": 200,
"event": "rx",
"device": "shellypro3em-xxxxxxxxxxxx",
"status": {
"em1:0": {
"id": 0,
"voltage": 224.6,
"current": 0.03,
"act_power": 0,
"aprt_power": 6.7,
"pf": 0,
"freq": 50,
"calibration": "factory"
}
}
}
}
To handle these events in a script:
Shelly.addEventHandler(function(ev) {
if (ev.name !== "lnm" || ev.info.event !== "rx") return;
print("Received from: " + ev.info.device);
print(JSON.stringify(ev.info.status));
});
Webhook Events
There are two events related to the LNM component that can trigger webhooks:
lnm.rx_status- produced when a status update is received from the multicast grouplnm.rx_event- produced for each event entry received from the multicast group (one webhook per event)
Both webhook events support attributes that can be used to compose conditional webhooks:
| Property | Type | Description |
|---|---|---|
| string | Device ID of the sender |
| object | Received status map (for |
| object | Received event object (for |
Webhook events require rx.enable: true on the LNM instance. The rpc_enable flag is independent and does not affect webhook delivery.