Sonoff with tasmota LWT message

I have a sonoff POW with tasmota installed and it works great. I want to use the LWT message to turn the switch off and reset some of the reading to 0 (ie voltage, current, power)

I found example to use Automation to trigger on the LWT message and send a new “OFF” message to the switch state topic (POWER) this also works great.

My problem is sending a second message to a second topic from the same trigger. I have tied several syntaxes but can’t find one that works.

I currently am trying

  hide_entity: True 
  trigger:
    platform: mqtt
    topic: "tele/Caravan_Input/LWT"
    payload: "Offline"
  action:
    service: mqtt.publish
    data:
      topic : "stat/Caravan_Input/POWER"
      payload : "OFF"
    data:
      topic : "tele/Caravan_Input/ENERGY"
      payload : "OFF"   

but this only send the second message to “ENERGY”

also to note the second message should be a Json message ie {“power”:0,“voltage”:0,}

Hope it is clear what I am trying to do.

Can anyone help

Try this:

- alias: Respond to Sonoff LWT message
  hide_entity: True 
  trigger:
    platform: mqtt
    topic: "tele/Caravan_Input/LWT"
    payload: "Offline"
  action:
    - service: mqtt.publish
      data:
        topic : "stat/Caravan_Input/POWER"
        payload : "OFF"
    - service: mqtt.publish
      data:
        topic : "tele/Caravan_Input/ENERGY"
        payload : "{\"power\":0,\"voltage\":0,}"

Worked like a dream

Just need to remove the last , from the second pay load

should read

payload : "{\"power\":0,\"voltage\":0}"

Thanks for the quick responce