Shelly 3em and resets

Hi,

I have a shelly 3em with the native integration.

Every time I reboot my wifi router, the Shelly drops off the network. Bringing it back seems to require a reset (10 seconds on the green LED), which retains all the settings apart from the main reason for the shelly’s existence – the accumulated used energy consumed.

I have a total energy template sensor with state_class: total_increasing summing the A+B+C energy, but this also get reset and then my energy monitoring scheme gets broken.

What am I supposed to do here? Is there a better way of rebooting the device, or should I be making copies of the energy sensors which would take care of these resets? How?

Any idea if this is a bug or really the wanted behavior in the stock firmware? Sounds very weird to me that the shelly just doesn’t connect back to the wifi ones it’s available again. :thinking:

Not sure exactly. Could probably install esphome on it and call it a day. :walking_man:

Alternatively you can work’a’round it probably by using utility meters directly in HA to accumulate the energy :slot_machine:

1 Like

I think it’s a timeout issues – the router takes 60s+ to re-establish the network, in the meantime the Shelly gives up and sets up its own hotspot, which then times out itself (I presume, I never find it once I am ready to deal with the 3em). I have a similar problem with a tapo wifi smart plug – it never gets the network back on its own without power cycling. It may be to do with the fact that there is an extender in my apartment which stays online, but doesn’t route, so the devices connect to the extender, get disappointed and get into a borked state.

The utility meters are indeed unaffected by the reset, but I actually do not want my sensors to ever reset and I can’t figure out how to do an infinite cycle on the utility meter…

I am thinking of doubling all my sensors and setting up some sort of non-decreasing template sensors summing up the positive changes to the energy meters but ignoring the resets.

That might be indeed the problem. If your shelly still has a old dhcp lease but your router gave already out new ones after the restart the shelly probably will only have (full) tcp/ip network access ones it asks for a new lease.

You can actually try it out quite easily if that is the problem by lowering the dhcp lease time in your router to a low value - like 2 minutes and see if the shelly then comes back.

Another way would be to give it a static lease so that your router always gives it the same IP address.

That would be a Riemann sum integral based on your power sensors:

But I would rather do this directly on the device because this way a very high internal update interval can be used which will make it more accurate

In esphome you would just active restore_from_flash for that - maybe the stock fw of your shelly also features such a setting?