MQTT Shelly: Possible to check consumption periodically?

Hello everyone,
I have multiple shelly devices (Shelly 2.5 and Shelly 1 PM) which I also use to monitor power consumption.
If I am not mistaken, the shelly actively sends any change in power consumption and does not send any information if there is no change to the previous value.

To ensure that the shelly is actually online and the values are truly unchanged (and not just a problem due to wifi being down, shelly being down etc.), I would like to make sure that all data is updated every e.g. 30 min. Is this possible? Can this be set somewhere in HA?

Shellys are all connected by MQTT.

Thank you for your help

to ensure the device is online you can set expire_after attribute of mqtt sensor.
It must be accompanied by setting of update_period for mqtt on Shelly side. it might be set only using http api only.
This period ensures resending current value to mqtt regardless it has changed or not.

this way you can set expire to 30min, and the period to 15min. If mqtt will not be updated during 30min the status will turn into ‘unavailable’

Also worth to note, there is some threshold a measured value must reach to be sent to mqtt. it’s 0.5W or 1W (not sure right now). afaik the threshold is not configurable


Thank you @maxym

But how does it work then? The update period is already set to 60. So every 60 min there should be an update, correct?
Is this update frequency being ignored because the value is 0 and if so, does HA ignore the 0 value or does the Shelly not send a 0 as a new value?

IMO it should send the value every 60 mins.
How have you found that it doesn’t?
Do you expect non-zero values but HA shows zero all the time? Or if you expecting zero, how fo you know new messages don’t reach HA?

IMO to make sure, connect to mqtt with MQTT Explorer and look at a topic reported by the device. Imo you should see there every message (even if value doesn’t change).

But who knows, maybe there is a bug in Shelly or somewhere else. Experiment above should tell us more

I will check out MQTT explorer this weekend.
I am pretty sure that either HA/influxDB or Shelly is not registering hourly.
I am tracking energy consumption and on the Shelly graphs I sometimes have empty graphs because there is no data. Tasmota plugs however periodically report 0 W, so I get a graph with constant value. But for the Shelly devices this is not the case.

So clearly there is something wrong somewhere between the consumer and the Grafana graph.
Only three possible culprits are Shelly (2.5 and 1 PM), Home Asistant MQTT Server, InfluxDB (which should be passive) and Grafana (which works for non Shelly devices and should also be passive).

What I do get is an hourly call from the Shellys
“[Shellies Discovery] has been triggered by mqtt topic shellies/announce”
for each Shelly.
But that looks like a keep alive and not data reporting to me.

Let’s wait for result of investigation using mqtt explorer.
My 2.5s are reporting the power consumption constantly. So maybe it’s mistake in sensors configuration?
You will see once you will be able to see the device topic content in the Explorer.

Do you have mqtt sensors configure manually or using discovery script from Bieniu? Ahh and assume you are using original firmware (is it something recent?

I just updated to the latest firmware. All Shellies are new and are running latest firmwares.

I disabled cloud and CoIT support and only enabled MQTT on the Shellies.
In HA I basically did nothing and just started the MQTT server/broker which then recognized the Shellies and added them. I am NOT using the shelly integration. Only pure MQTT (mosquitto broker).

@maxym : Apologies, I was swamped the last two weekends. I finally managed to install the MQTT explorer and connect it to my Home Assistant MQTT server. May I ask how I can find out the information needed?