Hi, I´m using a smartmaic energymeter (HACS integration) via MQTT on a location where sometimes to power is switched off. I’m searching now for a possibility to set the values to 0 if within 2minutes no new values are received. After a sensor loss HA is using the last received valid data whithout any expire-time…
Tried to insert an expire_after in developer tools/states but without success.
Any idea from you how to get that solved? I’m new to HA btw
state_class: measurement
unit_of_measurement: A
device_class: current
expire_after: 60
friendly_name: D103_2000A_1 Current 1
expire_after goes into the definition of the MQTT sensor.
If you don’t define it yourself but use the discovery feature, you have to check on the sending side if you can enable that feature when the “discovery” mqtt topic is set.
Hi,
In MQTT, the usual way a failure or disconnect is detected is with a Last Will and Testament (LWT) which the broker uses if there is no communication within a keepAlive timer:
Sending a LWT needs config on the client, so there is another way in the HASS MQTT Sensor:
Search is your friend - just expect to need several attempts as you learn better and better search terms and start to understand the features you’re homing in on.
Hi Koying,
understood now LWT and asking if anybody has implemented LWT to the smartmaic devices or can give me information how to implement that.
If that is not possible with that devices maybe some workaround is possible. HA knows when it received the last data, so checking that and set the data to zero could be an ugly but working solution. But I don’t know how to do that.
Seems like a web-page to configure the mqtt settings. I wonder if you could ping it from HA.
if so, if the ping sensor goes offline for 2 Minutes, you could publish a 0 value
That solved the problem. Created an automation which publishes at ping->disconnect the MQTT in the topic of that meter a payload with zero values for the voltage an current.
In parallel I contacted the creator of the integration. So maybe an LWT functionality will be implemented in future.
Hi all. I have a bit different problem. How to set value for Power sensor of Energy meter to 0, if no value changes for certain period?I have energy meter before my Solar inverter, and when grid outage is happen my esp32 on Easy Mega platform, keeps pushing last value. So values keep still. After grid back sensor continue to measure. Would be appreciated for any help and hints.