Mqtt.publish works from Developer Tools but not from automations (HA → Mosquitto → Domoticz)

My Setup / data flow
HA (publishes) → Mosquitto broker (running on HA) → Domoticz (subscribes)
Home Assistant with the Mosquitto broker add-on running.
Domoticz with “MQTT Auto Discovery Client Gateway with LAN interface” connected to the HA broker. Log confirms:
Home_Assistant-MQTT: Connected to: 192.xxx.x.xxx:1883
Marstek Venus 3.0 battery integrated in HA via Modbus (custom sensors).
Virtual sensors created in Domoticz (idx 181–202), one per HA sensor (Percentage for SoC, Custom Sensor for the rest).
HA publishes to topic domoticz/in. Domoticz listens on the same topic.

What works:
Publishing from Developer Tools → Actions using mqtt.publish, topic domoticz/in, payload {“idx”: 182, “nvalue”: 0, “svalue”: “{{ states(‘sensor.marstek_venus_modbus_batterijvermogen’) }}”}

What doesn’t work:

When the automation fires automatically (via time_pattern or state trigger), Domoticz receives nothing. Although I see by “When” the triggering.

if I click show tracing, I see no information

this is my automation yaml:

alias: Marstek Venus naar Domoticz
triggers:

  • entity_id:
    • sensor.marstek_venus_modbus_batterij_soc
    • sensor.marstek_venus_modbus_batterij_totale_energie
    • sensor.marstek_venus_modbus_batterijspanning
    • sensor.marstek_venus_modbus_batterijstroom
    • sensor.marstek_venus_modbus_batterijvermogen
    • sensor.marstek_venus_modbus_interne_temperatuur
    • sensor.marstek_venus_modbus_ac_stroom
    • sensor.marstek_venus_modbus_ac_vermogen
    • sensor.marstek_venus_modbus_totale_oplaadenergie
    • sensor.marstek_venus_modbus_totale_ontlaadenergie
    • sensor.marstek_venus_modbus_volledige_cycli_bms
    • sensor.marstek_venus_modbus_totaal_rendement
    • sensor.marstek_venus_modbus_maandelijks_rendement
    • sensor.marstek_venus_modbus_conversierendement
    • sensor.marstek_venus_modbus_opgeslagen_energie
    • sensor.marstek_venus_modbus_volledige_cycli_calc
    • sensor.slaapkamer_marstek_venus_modbus_marstek_productie_per_dag
    • sensor.venus_e_mini_state_of_charge_corrected
    • sensor.venus_e_mini_total_charge_corrected
    • sensor.venus_e_mini_c37c_charge_power
    • sensor.venus_e_mini_c37c_discharge_power
      trigger: state
      actions:
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 181, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_batterij_soc’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 182, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_batterijvermogen’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 183, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_batterij_totale_energie’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 184, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_batterijspanning’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 185, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_batterijstroom’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 186, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_interne_temperatuur’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 187, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_ac_stroom’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 188, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_ac_vermogen’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 189, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_totale_oplaadenergie’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 190, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_totale_ontlaadenergie’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 191, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_volledige_cycli_bms’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 192, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_totaal_rendement’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 193, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_maandelijks_rendement’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 194, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_conversierendement’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 195, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_opgeslagen_energie’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 196, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.marstek_venus_modbus_volledige_cycli_calc’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 197, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.slaapkamer_marstek_venus_modbus_marstek_productie_per_dag’)
    }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 199, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.venus_e_mini_state_of_charge_corrected’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 200, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.venus_e_mini_total_charge_corrected’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 201, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.venus_e_mini_c37c_discharge_power’) }}”}
    action: mqtt.publish
  • data:
    topic: domoticz/in
    payload: >-
    {“idx”: 202, “nvalue”: 0, “svalue”: “{{
    states(‘sensor.venus_e_mini_c37c_charge_power’) }}”}
    action: mqtt.publish
    mode: queued
    max: 25

Key observation:
Same topic and payload work perfectly from Developer Tools and manual “Run actions”, but an automatic trigger produces no MQTT message reaching Domoticz. The automation is confirmed to be enabled and firing.


When I run it manually it is succesfull and I see the change from the value in domotcz

Why would mqtt.publish work from Developer Tools and manual “Run actions”, but silently fail / does not change value in domotcz when triggered automatically?

Any suggestion what I’m doing wrong?

Please format your code correctly