PM1
The PM1 component handles electrical power metering capabilities. It uses PM1 as the RPC namespace and provides the methods:
PM1.SetConfigto update the component's configurationPM1.GetConfigto obtain the component's configurationPM1.GetStatusto obtain the component's statusPM1.ResetCountersto reset component's energy counters
PM1 components are identified with PM1:<id> in objects containing multiple component payloads.
Methods
PM1.SetConfig
Parameters:
| Property | Type | Description |
|---|---|---|
| number | Id of the PM1 component instance |
| object | Configuration that the method takes |
Find more about the config properties in config section
PM1.GetConfig
Parameters:
| Property | Type | Description |
|---|---|---|
| number | Id of the PM1 component instance |
Find the PM1.GetConfig response properties in config section
PM1.GetStatus
Parameters:
| Property | Type | Description |
|---|---|---|
| number | Id of the PM1 component instance |
Find more about the status response properties in status section
PM1.ResetCounters
This method resets associated counters.
Request
Parameters:
| Property | Type | Description |
|---|---|---|
| number | Id of the PM1 component instance. Required |
| array of strings | Array of strings, selects which counter to reset Optional |
If no 'type' is provided, the method will reset all available counters.
Response
Attributes in the result:
| Property | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
| object | Information about the active energy counter prior to reset
| ||||||
| object | Information about the returned active energy counter prior to reset
|
Configuration
The configuration of the PM1 component contains information about the id and name of the component.
| Property | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| number | Id of the PM1 component instance | ||||||||||||
| string or null | Name of the PM1 instance | ||||||||||||
| bool | Reverse measurement direction of active power and energy for the PM1 component. setting the reverse option requires restart | ||||||||||||
| object | Settings for the alarm thresholds
'null' disables a threshold, setting the alarms option to 'null' disables all alarms |
Status
The status of the PM1 component contains information about the measured variables. To obtain the status of the PM1 component its id must be specified.
| Property | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| number | Id of the PM1 component instance | ||||||||||||
| number | Last measured voltage in Volts | ||||||||||||
| number | Last measured current in Amperes | ||||||||||||
| number | Last measured instantaneous active power (in Watts) delivered to the attached load | ||||||||||||
| number | Last measured instantaneous apparent power (in Volt-Amperes) delivered to the attached load (shown if applicable) | ||||||||||||
| number | Last measured power factor (shown if applicable) | ||||||||||||
| number | Last measured network frequency (shown if applicable) | ||||||||||||
| object | Information about the active energy counter
| ||||||||||||
| object | Information about the returned active energy counter *
| ||||||||||||
| array of type string | Error conditions occurred. May contain | ||||||||||||
| array of type string | Communicates present conditions, shown if at least one flag is set. May contain: |
ret_aenergy- the active energy added to this container is also added toaenergycontainer. All the consumed energy is collected inaenergyregardless of the direction(consumed or returned) of the active energy.
Webhook Events
PM1 component supports conditional webhooks.
Events related to the PM1 component that can trigger webhooks:
voltage_change- when the voltage has changed with at least 1V and 10% from the last reported value.voltage_changeevent supports attributes, that can be used to compose conditional webhooks:Property Type Description voltagenumber
New voltage in Volts
current_change- when the current has changed with at least 0.02A and 5% from the last reported value.current_changeevent supports attributes, that can be used to compose conditional webhooks:Property Type Description currentnumber
New current in Amps
apower_change- when the active power has changed with at least 1W and 5% from the last reported value.apower_changeevent supports attributes, that can be used to compose conditional webhooks:Property Type Description apowernumber
New active power in Watts
alarm_undervoltage- when the voltage drops below anunderthreshold.alarm_undervoltageevent supports attributes, that can be used to compose conditional webhooks:Property Type Description voltagenumber
Voltage below the
underthreshold in Volts
alarm_undervoltage_clear- when the voltage rises above anunderthreshold.alarm_undervoltage_clearevent supports attributes, that can be used to compose conditional webhooks:Property Type Description voltagenumber
Voltage above the
underthreshold in Volts
alarm_overvoltage- when the voltage rises above anoverthreshold.alarm_overvoltageevent supports attributes, that can be used to compose conditional webhooks:Property Type Description voltagenumber
Voltage above the
overthreshold in Volts
alarm_overvoltage_clear- when the voltage drops below anoverthreshold.alarm_overvoltage_clearevent supports attributes, that can be used to compose conditional webhooks:Property Type Description voltagenumber
Voltage below the
overthreshold in Volts
alarm_undercurrent- when the current drops below anunderthreshold.alarm_undercurrentevent supports attributes, that can be used to compose conditional webhooks:Property Type Description currentnumber
Current below the
underthreshold in Amps
alarm_undercurrent_clear- when the current rises above anunderthreshold.alarm_undercurrent_clearevent supports attributes, that can be used to compose conditional webhooks:Property Type Description currentnumber
Current above the
underthreshold in Amps
alarm_overcurrent- when the current rises above anoverthreshold.alarm_overcurrentevent supports attributes, that can be used to compose conditional webhooks:Property Type Description currentnumber
Current above the
overthreshold in Amps
alarm_overcurrent_clear- when the current drops below anoverthreshold.alarm_overcurrent_clearevent supports attributes, that can be used to compose conditional webhooks:Property Type Description currentnumber
Current below the
overthreshold in Amps
alarm_underpower- when the power drops below anunderthreshold.alarm_underpowerevent supports attributes, that can be used to compose conditional webhooks:Property Type Description powernumber
Power below the
underthreshold in Watts
alarm_underpower_clear- when the power rises above anunderthreshold.alarm_underpower_clearevent supports attributes, that can be used to compose conditional webhooks:Property Type Description powernumber
Power above the
underthreshold in Watts
alarm_overpower- when the power rises above anoverthreshold.alarm_overpowerevent supports attributes, that can be used to compose conditional webhooks:Property Type Description powernumber
Power above the
overthreshold in Watts
alarm_overpower_clear- when the power drops below anoverthreshold.alarm_overpower_clearevent supports attributes, that can be used to compose conditional webhooks:Property Type Description powernumber
Power below the
overthreshold in Watts
Alarms
Alarms provide a way to trigger custom behavior when a monitored variable reaches a certain threshold, without raising an error or activating defensive mechanisms.
There are six types of alarms across three variables, resulting in twelve available webhooks.
The monitored variables are voltage, current, and power. Each variable supports two thresholds:
- an under threshold
- an over threshold
For example, the voltage variable can trigger an undervoltage alarm when the measured value falls below the configured “under” threshold, or an overvoltage alarm when it exceeds the “over” threshold.
Each threshold can be configured with a numeric value, or disabled by setting it to null.
A triggered alarm will set a flag in the status, indicating the condition that triggered the alarm. The flag is cleared when the alarm condition is cleared.
A triggered
Examples
PM1.SetConfig example
- PM1.SetConfig HTTP GET Request
- PM1.SetConfig Curl Request
- PM1.SetConfig Mos Request
http://192.168.33.1/rpc/PM1.SetConfig?id=0&config={"name":"Meter","reverse":true}
curl -X POST -d '{"id":1,"method":"PM1.SetConfig","params":{"id":0,"config":{"name":"Meter","reverse":true}}}' http://${SHELLY}/rpc
mos --port ${PORT} call PM1.SetConfig '{"id":0,"config":{"name":"Meter","reverse":true}}'
Response
- PM1.SetConfig HTTP GET Response
- PM1.SetConfig Curl Response
- PM1.SetConfig Mos Response
{
"restart_required": true
}
{
"id": 1,
"params": {
"restart_required": true
}
}
{
"restart_required": true
}
- PM1.SetConfig HTTP GET Request
- PM1.SetConfig Curl Request
- PM1.SetConfig Mos Request
http://192.168.33.1/rpc/PM1.SetConfig?id=0&config={"alarms":{"voltage":[190,245.9],"current":[4.9,11],"power":[100,1200]}}
curl -X POST -d '{"id":1,"method":"PM1.SetConfig","params":{"id":0,"config":{"alarms":{"voltage":[190,245.9],"current":[4.9,11],"power":[100,1200]}}}}' http://${SHELLY}/rpc
mos --port ${PORT} call PM1.SetConfig '{"id":0,"config":{"alarms":{"voltage":[190,245.9],"current":[4.9,11],"power":[100,1200]}}}'
Response
- PM1.SetConfig HTTP GET Response
- PM1.SetConfig Curl Response
- PM1.SetConfig Mos Response
{
"restart_required": false
}
{
"id": 1,
"params": {
"restart_required": false
}
}
{
"restart_required": false
}
PM1.GetConfig example
- PM1.GetConfig HTTP GET Request
- PM1.GetConfig Curl Request
- PM1.GetConfig Mos Request
http://192.168.33.1/rpc/PM1.GetConfig?id=0
curl -X POST -d '{"id":1,"method":"PM1.GetConfig","params":{"id":0}}' http://${SHELLY}/rpc
mos --port ${PORT} call PM1.GetConfig '{"id":0}'
Response
- PM1.GetConfig HTTP GET Response
- PM1.GetConfig Curl Response
- PM1.GetConfig Mos Response
{
"id": 0,
"name": "PM1device",
"reverse": false,
"alarms": {
"voltage": [
200,
250
],
"current": [
0.2,
12
],
"power": [
20,
1200
]
}
}
{
"id": 1,
"params": {
"id": 0,
"name": "PM1device",
"reverse": false,
"alarms": {
"voltage": [
200,
250
],
"current": [
0.2,
12
],
"power": [
20,
1200
]
}
}
}
{
"id": 0,
"name": "PM1device",
"reverse": false,
"alarms": {
"voltage": [
200,
250
],
"current": [
0.2,
12
],
"power": [
20,
1200
]
}
}
PM1.GetStatus example
- PM1.GetStatus HTTP GET Request
- PM1.GetStatus Curl Request
- PM1.GetStatus Mos Request
http://192.168.33.1/rpc/PM1.GetStatus?id=0
curl -X POST -d '{"id":1,"method":"PM1.GetStatus","params":{"id":0}}' http://${SHELLY}/rpc
mos --port ${PORT} call PM1.GetStatus '{"id":0}'
Response
- PM1.GetStatus HTTP GET Response
- PM1.GetStatus Curl Response
- PM1.GetStatus Mos Response
{
"id": 0,
"voltage": 225.9,
"current": 0,
"apower": 0,
"freq": 50,
"aenergy": {
"total": 11.679,
"by_minute": [
0,
0,
0
],
"minute_ts": 1654511972
},
"ret_aenergy": {
"total": 4.126,
"by_minute": [
0,
0,
0
],
"minute_ts": 1654511318
},
"errors": [
"power_meter_failure",
"out_of_range:voltage",
"out_of_range:current",
"out_of_range:apower",
"out_of_range:aprtpower"
]
}
{
"id": 1,
"src": "shellyplus1pm-441793ce3f08",
"params": {
"id": 0,
"voltage": 225.9,
"current": 0,
"apower": 0,
"freq": 50,
"aenergy": {
"total": 11.679,
"by_minute": [
0,
0,
0
],
"minute_ts": 1654511972
},
"ret_aenergy": {
"total": 4.126,
"by_minute": [
0,
0,
0
],
"minute_ts": 1654511318
},
"errors": [
"power_meter_failure",
"out_of_range:voltage",
"out_of_range:current",
"out_of_range:apower",
"out_of_range:aprtpower"
]
}
}
{
"id": 0,
"voltage": 225.9,
"current": 0,
"apower": 0,
"freq": 50,
"aenergy": {
"total": 11.679,
"by_minute": [
0,
0,
0
],
"minute_ts": 1654511972
},
"ret_aenergy": {
"total": 4.126,
"by_minute": [
0,
0,
0
],
"minute_ts": 1654511318
},
"errors": [
"power_meter_failure",
"out_of_range:voltage",
"out_of_range:current",
"out_of_range:apower",
"out_of_range:aprtpower"
]
}
PM1.ResetCounters example
- PM1.ResetCounters HTTP GET Request
- PM1.ResetCounters Curl Request
- PM1.ResetCounters Mos Request
http://192.168.33.1/rpc/PM1.ResetCounters?id=0&type=["aenergy","ret_aenergy"]
curl -X POST -d '{"id":1,"method":"PM1.ResetCounters","params":{"id":0,"type":["aenergy","ret_aenergy"]}}' http://${SHELLY}/rpc
mos --port ${PORT} call PM1.ResetCounters '{"id":0,"type":["aenergy","ret_aenergy"]}'
Response
- PM1.ResetCounters HTTP GET Response
- PM1.ResetCounters Curl Response
- PM1.ResetCounters Mos Response
{
"aenergy": {
"total": 11.679
},
"ret_aenergy": {
"total": 5.817
}
}
{
"id": 1,
"src": "shellypluspmmini-44179bf90f08",
"params": {
"aenergy": {
"total": 11.679
},
"ret_aenergy": {
"total": 5.817
}
}
}
{
"aenergy": {
"total": 11.679
},
"ret_aenergy": {
"total": 5.817
}
}