MQTT items not reading value 0 from broker

Dear all,

I have a problem with mqtt items from my DSRM meter monitor program. It pushes the current power usage from my electricity meter to my mqtt broker.

I have configured these items in my config files:

- platform: mqtt
    state_topic: "dsmr/reading/electricity_currently_returned"
    unit_of_measurement: "KW"
    name: DSMR Returned
    device_class: power

  - platform: mqtt
    state_topic: "dsmr/reading/electricity_currently_delivered"
    unit_of_measurement: "KW"
    name: DSMR Delivered
    device_class: power

The problem is that a value of 0 does not work? If I restart home assistant and it connects it uses values bigger than 0 immediately, but topics that have a value of 0 stay on unknow until it changes and then the sensor picks it up.

Also, if my installation is returning power to the grid (for example 1KW). And i put something on like a electric heater, the delivered value shoots up. And in MQTT returned goes immediately to 0. But the sensor does not pick the 0 up and thus stays on 1KW returning while the other sensor says 2KW delivered for instance.

Could this be a problem in my home assistant config, or the way my dsmr monitor pushed values to MQTT?

Many thanks for any hint.

Best regards,
Wouter

First thing to do would be to use MQTT Explorer to see what values are being published an in what format. You may need a value_template.

Thanks,

I did that and the value 0 is posted there.
image

I also set the flag “force_update: true” on my mqtt items. This seems to be a little better, It receives the 0 value now, but sometimes takes a while to receive it.

I also have a filter on it that limit it on 1 update per minute (the original values update 1 time per second and are excluded from the recorder)

  - platform: filter
    name: DSMR Returned 1min
    entity_id: sensor.dsmr_returned
    filters:
    - filter: range
      lower_bound: 0.0
      upper_bound: 10000.0
    - filter: time_throttle
      window_size: 00:01

This filter has now a value of 0.004 KW last changed 30 min ago. The last change from the original item is also from 30 min ago but last change is to a value of 0.

image

I’m using the 1min filtered items on a graph, but they almost never go to 0. (another problem than the one above, but i think if I fix the 0 value problem this might also get fixed)

Thanks for the input.

Wouter