• Nov 25, 2026
  • 3 min read

Home Energy From a Shelly Pro EM: Trust the Counters

The platform measured temperature, humidity and a solar panel. The next question was the house itself: how much energy, and where does it go? A Shelly Pro EM-50 sits in the panel with two current clamps: channel 0 on the mains, channel 1 on the kitchen circuit. It speaks MQTT natively.

Adding it took no new ingester code. That was the test of the config-driven design.

What the Shelly sends

A Gen 2 Shelly publishes NotifyStatus RPC messages on <device-id>/events/rpc:

{
  "method": "NotifyStatus",
  "params": {
    "ts": 1793175010.89,
    "em1:0": { "act_power": -87.1, "aprt_power": 227.7, "current": 0.989,
               "voltage": 229.1, "pf": 0.36, "freq": 50.0 }
  }
}
ObjectContains
params.em1:0 / em1:1instantaneous: active and apparent power, current, voltage, power factor, frequency
params.em1data:0 / em1data:1cumulative counters: total_act_energy, total_act_ret_energy (Wh)

The keys have colons in them. The ingester’s dotted path lookup handles params.em1:0.act_power as-is, so each field is one line of route config, mapped to stable signal ids like power.house_active and power.kitchen_energy.

One choice: the Shelly includes its own timestamp (params.ts), but the platform stores the broker receipt time for everything. Every device then has the same meaning of “fresh”, which matters for the stale-data alerts.

The clamp that was on backwards

Channel 0 reported negative active power. The house wasn’t exporting energy at night; the clamp had been installed facing the wrong way. Two fixes, both in config:

  • An optional multiplier per field: { "path": "params.em1:0.act_power", "multiplier": -1 }. A reading of −216.6 W is stored as +216.6 W. Every other route defaults to 1 and is unaffected.
  • The counters swap meaning too. On this installation the counter that grows with consumption is total_act_ret_energy, so that’s the one mapped to house energy, and total_act_energy becomes “returned”.

Historical rows aren’t rewritten. And if the clamp is ever turned around, the swap has to be reverted; that’s written down next to the route.

Don’t integrate power. Read the counter.

The tempting way to get kilowatt-hours is to add up power readings over time. It’s also the way to be wrong: every MQTT gap, restart or irregular interval becomes missing or doubled energy.

The Shelly already counts energy in its own memory. So the platform stores the counters directly and computes a period’s energy as a difference:

house energy       = last house counter   − first house counter
kitchen energy     = last kitchen counter − first kitchen counter
everything else    = house energy − kitchen energy

Two readings in the selected range are enough. A gap in the middle doesn’t matter: the counter kept counting while nobody was listening.

That’s the Home energy panel: house, kitchen and “everything else” for any range, plus live power per channel.

A nightly summary on the phone

At 23:55 local time, the ingester’s optional notification job sends one ntfy message with the day’s house, kitchen, non-kitchen and returned energy, from the same counter differences. If there aren’t two readings for the day yet, it says so plainly instead of sending a zero.

Takeaways

  • Config-driven ingestion passes its test when a new device type needs no code.
  • Expect hardware to be installed backwards. A per-field multiplier is a tiny feature that saves rewriting data.
  • Energy comes from counters, not from integrating power. Let the meter count.
  • One timestamp meaning across devices keeps freshness checks honest.

Next in this series: The Dashboard Looked Healthy. It Wasn’t Writing Anything.

Part 7 of 8. Start with the series overview.