State Trigger delivers false state

Hi all,

have a hardware state Display:

It turns leds on or off depends on specific MQTT Topic.

What i want is, that Home Assistant send a state, on or off, to this MQTT Topic if a Lamp turns on or off.

Therefor i created an automation:

- id: '1640938482751'
  alias: mqtt2disp
  description: ''
  trigger:
  - platform: state
    entity_id: light.somelight
  condition: []
  action:
  - service: mqtt.publish
    data:
      topic: house/state/light/{{trigger.entity_id|replace("light.","")}}
      payload_template: '{{trigger.to_state.state|upper}}'
      retain: true
  mode: single

Problem is, Tasmota devices are working flawless but it seems that Home Assistant or the MQTT Integration delivers false state values for Zigbee2MQTT devices most of the Time.

Means, if i turn an Zigbee2MQTT Lamp in Dashboard to off, Lamp is off, Dashboard state is even off but the “trigger.from_state.state” and “trigger.to_state.state” are both “on”?

How can it be?

Me again,

the Problem is, Zigbee2MQTT sends immediately 2 messages, one with old state and one with new one.

Possibly Solution is to use Zigbee2MQTT’s debounce function for this device.
https://www.zigbee2mqtt.io/guide/configuration/devices-groups.html#common-device-options

Cheers