MQTT, tasmota and expire_after

I’ve got a number of tasmota power sensors (current meter and switch). Right now they publish onto an MQTT server, and pass values along, including daily usage. Unfortunately, if the plug is disconnected, all the values go to ‘unavailable’. While this is fine and good for most settings, its very annoying for daily usage, since it’s value effectively drops to zero.

Is there an easy way to make home assistant just use the last received value, if none are available? I believe the “expire_after” setting is the culprit , but can’t figure out how to change it, other than manually creating all the sensors myself.

I’m still quite green with home assistant, so my apologies if it is obvious somewhere.

Hi there, Its better that you share the configuration of the sensor. From what you said you can set an expire_after to a larger value like 300 or so

but if you have configured availability with the sensor, this could also push the sensor to unavailable state if the sensor goes offline.

I think that is the only real solution.

Unfortunately, I can’t figure out how to set the expire_after value.

The entities are being auto-generated by the auto discovery. I can’t figure out if I can put an override somewhere to add it in.

While I could manually add all the devices in, it would be both tedious and incredibly brittle. The system is for a charity’s building, with a lot of older members, to manage heating. I’m hoping to keep it as simple as possible to make basic changes, unfortunately it seems to be turning into a rat’s nest of magic code, which would render it useless if I’m not careful.

If your Tasmota devices are using Home Assistant’s MQTT Discovery feature, there’s a way to override a device’s configuration (by manually publishing a new discovery payload to overwrite the device’s existing one). However, this discovery method has been deprecated by Tasmota’s development team in favor of their own discovery method (which requires the use of the Tasmota integration). So chances are your devices are being discovered via Tasmota’s own method.

Tasmota - Home Assistant