Modbus
The Modbus component provides Modbus-TCP communication protocol on tcp port 502 for supported Shelly devices.
The Modbus component uses Modbus
as RPC namespace and implements the following methods:
Modbus.GetConfig
to obtain the component's configurationModbus.SetConfig
to update the component's configurationModbus.GetStatus
to obtain the component's status
Methods
Modbus.SetConfig
Properties:
Property | Type | Description |
---|---|---|
| object | Configuration that the method takes |
Find more about the config properties in config section
Modbus.GetConfig
Find the Modbus.GetConfig response properties in config section
Modbus.GetStatus
Find more about the status response properties in status section
Configuration
The configuration of the Modbus component enables or disables the server.
Properties:
Property | Type | Description |
---|---|---|
| boolean | Set |
Status
The status of the Modbus component shows whether the server is successfully enabled.
Property | Type | Description |
---|---|---|
| boolean |
|
Registers
Every Shelly component that supports Modbus has its own set of registers, listed in its documentation:
Device info registers:
Address | Type | Description |
---|---|---|
30000 | ASCII string | Device MAC (6 registers / 12 bytes) |
30006 | ASCII string | Device model (10 registers / 20 bytes zero padded) |
30016 | ASCII string | Device name (32 registers / 64 bytes zero padded) |
Modbus.SetConfig example
- Modbus.SetConfig HTTP GET Request
- Modbus.SetConfig Curl Request
- Modbus.SetConfig Mos Request
http://192.168.33.1/rpc/Modbus.SetConfig?config={"enable":true}
curl -X POST -d '{"id":1,"method":"Modbus.SetConfig","params":{"config":{"enable":true}}}' http://${SHELLY}/rpc
mos --port ${PORT} call Modbus.SetConfig '{"config":{"enable":true}}'
Response
- Modbus.SetConfig HTTP GET Response
- Modbus.SetConfig Curl Response
- Modbus.SetConfig Mos Response
{
"restart_required": false
}
{
"id": 1,
"params": {
"restart_required": false
}
}
{
"restart_required": false
}
Modbus.GetConfig example
- Modbus.GetConfig HTTP GET Request
- Modbus.GetConfig Curl Request
- Modbus.GetConfig Mos Request
http://192.168.33.1/rpc/Modbus.GetConfig?
curl -X POST -d '{"id":1,"method":"Modbus.GetConfig","params":{}}' http://${SHELLY}/rpc
mos --port ${PORT} call Modbus.GetConfig '{}'
Response
- Modbus.GetConfig HTTP GET Response
- Modbus.GetConfig Curl Response
- Modbus.GetConfig Mos Response
{
"enable": true
}
{
"id": 1,
"params": {
"enable": true
}
}
{
"enable": true
}
Modbus.GetStatus example
- Modbus.GetStatus HTTP GET Request
- Modbus.GetStatus Curl Request
- Modbus.GetStatus Mos Request
http://192.168.33.1/rpc/Modbus.GetStatus?
curl -X POST -d '{"id":1,"method":"Modbus.GetStatus","params":{}}' http://${SHELLY}/rpc
mos --port ${PORT} call Modbus.GetStatus '{}'
Response
- Modbus.GetStatus HTTP GET Response
- Modbus.GetStatus Curl Response
- Modbus.GetStatus Mos Response
{}
{
"id": 1,
"params": {}
}
{}
Useful Tools
Many tools can be used to send MODBUS TCP requests to and receive responses from Shelly devices. Some of them are:
modbus_cli
This Python modbus client, as stated in it's documentation can Read and write registers of Modbus devices
. GitHub link
Example 1:
Reading timestamp of last update of EM componentmodbus -B mixed 192.168.2.48 i@1000/I
Parsed 0 registers definitions from 1 files
1000: 1669379021 0x6380b3cd
Example 2:
Reading voltage on Phase Amodbus -B mixed 192.168.2.48 i@1020/f
Parsed 0 registers definitions from 1 files
1020: 232.2854461669922