The Shelly Pro 3EM has a status page here: http://10.3.50.133/rpc/Shelly.GetStatus
It also pushes data to MQTT (see below).
This project creates an nginx
# install required software
sudo apt install nginx jq
# git deploy key
mkdir -p /usr/shhm/.ssh/
ssh-keygen -f /usr/shhm/.ssh/pro3em-deploy-key
export GIT_SSH_COMMAND="ssh -i /usr/shhm/.ssh/pro3em-deploy-key"
git clone [email protected]:sheffieldhackspace/shellypro3em-mqtt-prometheus-exporter.git /usr/shhm/shelly_pro3em_exporter
cd /usr/shhm/shelly_pro3em_exporter
# install nginx configuration
sudo cp shellypro3em.conf /etc/nginx/sites-available/shellypro3em.conf
sudo ln -s /etc/nginx/sites-available/shellypro3em.conf /etc/nginx/sites-enabled/shellypro3em.conf
sudo systemctl restart nginx
# create user to run service
sudo useradd -r -s /bin/false shellypro3em
sudo usermod -aG shellypro3em $USER
sudo chmod -R g+w .
sudo chown -R shellypro3em:shellypro3em /usr/shhm/shelly_pro3em_exporter
# install systemd service
sudo cp shelly_pro3em_exporter.service /etc/systemd/system/shelly_pro3em_exporter.service
sudo systemctl enable shelly_pro3em_exporter
sudo systemctl start shelly_pro3em_exporter
sudo systemctl status shelly_pro3em_exporter
# add to Prometheus listeners
cat > > /usr/shhm/prometheus/prometheus.yaml << EOYAML
- job_name: "shelly_pro3em_exporter"
static_configs:
- targets: ['localhost:8814']
EOYAMLMQTT messages look like
# NotifyStatus (power)
SHHNoT/shellypro3em/events/rpc {"src":"shellypro3em-08f9e0e99640","dst":"SHHNoT/shellypro3em/events","method":"NotifyStatus","params":{"ts":1763582704.84,"em:0":{"a_act_power":1698.4,"a_aprt_power":1703.9,"a_current":7.157,"a_freq":50.0,"a_pf":1.00,"a_voltage":237.9,"b_act_power":183.2,"b_aprt_power":244.4,"b_current":1.022,"b_freq":50.0,"b_pf":0.75,"b_voltage":239.0,"c_act_power":153.8,"c_aprt_power":262.8,"c_current":1.096,"c_freq":50.0,"c_pf":0.58,"c_voltage":239.8,"n_current":null,"total_act_power":2035.383,"total_aprt_power":2211.146,"total_current":9.275}}}
# NotifyStatus (energy)
SHHNoT/shellypro3em/events/rpc {"src":"shellypro3em-08f9e0e99640","dst":"SHHNoT/shellypro3em/events","method":"NotifyStatus","params":{"ts":1763585640.86,"emdata:0":{"a_total_act_energy":229324.53,"a_total_act_ret_energy":0.00,"b_total_act_energy":184249.39,"b_total_act_ret_energy":0.00,"c_total_act_energy":150795.77,"c_total_act_ret_energy":0.00,"total_act":564369.69,"total_act_ret":0.00}}}
# NotifyEvent
SHHNoT/shellypro3em/events/rpc {"src":"shellypro3em-08f9e0e99640","dst":"SHHNoT/shellypro3em/events","method":"NotifyEvent","params":{"ts":1763582820.88,"events":[{"component":"emdata:0","id":0,"event":"data","ts":1763582760.00,"data":{"ts": 1763582760,"period": 60,"values":[[35.3170,35.2458,0.0000,0.0000,0.0000,1.1546,4383.2,1696.9,4383.4,1702.3,238.129,237.692,237.953,18.421,7.153,9.031,3.1352,3.1468,0.0000,0.0000,0.0000,1.7122,203.5,182.5,269.5,242.8,239.585,239.124,239.327,1.125,1.014,1.051,2.6343,2.6679,0.0000,0.0000,0.0000,1.1541,163.6,152.2,281.4,263.5,240.274,239.719,239.969,1.173,1.099,1.134,0.028,0.026,0.027]]}}]}}
expanded, it's
{
"src": "shellypro3em-08f9e0e99640",
"dst": "SHHNoT/shellypro3em/events",
"method": "NotifyStatus",
"params": {
"ts": 1763582704.84,
"em:0": {
"a_act_power": 1698.4,
"a_aprt_power": 1703.9,
"a_current": 7.157,
"a_freq": 50,
"a_pf": 1,
"a_voltage": 237.9,
"b_act_power": 183.2,
"b_aprt_power": 244.4,
"b_current": 1.022,
"b_freq": 50,
"b_pf": 0.75,
"b_voltage": 239,
"c_act_power": 153.8,
"c_aprt_power": 262.8,
"c_current": 1.096,
"c_freq": 50,
"c_pf": 0.58,
"c_voltage": 239.8,
"n_current": null,
"total_act_power": 2035.383,
"total_aprt_power": 2211.146,
"total_current": 9.275
}
}
}{
"src": "shellypro3em-08f9e0e99640",
"dst": "SHHNoT/shellypro3em/events",
"method": "NotifyStatus",
"params": {
"ts": 1763585640.86,
"emdata:0": {
"a_total_act_energy": 229324.53,
"a_total_act_ret_energy": 0,
"b_total_act_energy": 184249.39,
"b_total_act_ret_energy": 0,
"c_total_act_energy": 150795.77,
"c_total_act_ret_energy": 0,
"total_act": 564369.69,
"total_act_ret": 0
}
}
}we ignore this as it's just writing to the SD card – use the NotifyStatus events above.
- https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/EMData/#notifications
- https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/EMData/#notifications-example
{
"src": "shellypro3em-08f9e0e99640",
"dst": "SHHNoT/shellypro3em/events",
"method": "NotifyEvent",
"params": {
"ts": 1763582820.88,
"events": [
{
"component": "emdata:0",
"id": 0,
"event": "data",
"ts": 1763582760,
"data": {
"ts": 1763582760,
"period": 60,
"values": [
[35.317,35.2458,0,0,0,1.1546,4383.2,1696.9,4383.4,1702.3,238.129,237.692,237.953,18.421,7.153,9.031,3.1352,3.1468,0,0,0,1.7122,203.5,182.5,269.5,242.8,239.585,239.124,239.327,1.125,1.014,1.051,2.6343,2.6679,0,0,0,1.1541,163.6,152.2,281.4,263.5,240.274,239.719,239.969,1.173,1.099,1.134,0.028,0.026,0.027]
]
}
}
]
}
}the data here corresponds to keys (from https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/EMData/#emdatagetdata-example)
{"keys":["a_total_act_energy","a_fund_act_energy","a_total_act_ret_energy","a_fund_act_ret_energy","a_lag_react_energy","a_lead_react_energy","a_max_act_power","a_min_act_power","a_max_aprt_power","a_min_aprt_power","a_max_voltage","a_min_voltage","a_avg_voltage","a_max_current","a_min_current","a_avg_current","b_total_act_energy","b_fund_act_energy","b_total_act_ret_energy","b_fund_act_ret_energy","b_lag_react_energy","b_lead_react_energy","b_max_act_power","b_min_act_power","b_max_aprt_power","b_min_aprt_power","b_max_voltage","b_min_voltage","b_avg_voltage","b_max_current","b_min_current","b_avg_current","c_total_act_energy","c_fund_act_energy","c_total_act_ret_energy","c_fund_act_ret_energy","c_lag_react_energy","c_lead_react_energy","c_max_act_power","c_min_act_power","c_max_aprt_power","c_min_aprt_power","c_max_voltage","c_min_voltage","c_avg_voltage","c_max_current","c_min_current","c_avg_current","n_max_current","n_min_current","n_avg_current"]}