Sensor unavailable, MQTT sends "0"

My setup: HA with a temperature sensor using ESPhome. I have a automation which publishes to Domoticz. Sometimes the sensor is unavailable because of Wifi interference and the Domoticz recieves a “0”. This messes up my graphs in Domoticz, which I have to remove by hand.

What to do? (And I know better Wifi is also a solution, but it is in my backyard which is pretty tricky).

The YAML config of the automation:

alias: Publiceer vijvertemperatuur MQTT
description: ""
trigger:
  - platform: time_pattern
    seconds: "20"
condition: []
action:
  - service: mqtt.publish
    metadata: {}
    data:
      qos: "0"
      retain: true
      topic: domoticz/in
      payload_template: >-
        { "command": "udevice", "idx": 108, "nvalue": 0, "svalue": "{{
        states('sensor.vijver_temperatuur') }}"}
mode: single

Any thoughts?

Add a condition that sensor.vijver_temperatuur is numeric (or not “unavailable”).

Is it a Domoticz requirement that you send a value every 20 seconds, even if the value did not actually change?

I’ll try that, thanks!

Is it a Domoticz requirement that you send a value every 20 seconds, even if the value did not actually change?

Nope, it’s not a requirement. I like a high resolution of data points :).

A high resolution of identical values is just a waste of resources :wink:
If you trigger on the state of the sensor, a value will only be sent if it actually changed.