Possible workaround to turn off light MQTT payload_off

I have light I controll with MQTT.
I don’t get any state back so I need to send commands blind.

This is not really a problem.
To turn off light I basically set 0 with some parameter as payload_off

However there are certain conditions when the light will not turn off when sending 0 directly but I actually needs to send a higher value first and then 0.

So my idea was if I could setup so payload_off would first set commands to set light to 1 and then send a second payload to set the light to 0.

Here are my setup for on/off now which works but not under certain conditions.

command_topic: "casambi/0/set/scene_level"
payload_on: '{"scene": 12, "level": 254, "duration": 50}'
payload_off: '{"scene": 12, "level": 0, "duration": 50}'

So basically if would want

payload_off_1: ‘{“scene”: 12, “level”: 1, “duration”: 50}’
payload_off_2: ‘{“scene”: 12, “level”: 0, “duration”: 50}’

Is there anyway I could send two payloads as off?

If I cannot send two payloads I can solve it with automation.
However it would be nice not to be able to make a generic automation for all lights instead of making one that works for all.

For my MQTT device I now have set
payload_off: '{"scene": 12, "level": 1, "duration": 50}'

I have managed to solve an automations that triggers no matter which light I turn off by listening to MQTT topic.

Can I use the payload from the trigger as part of the action?

Basically take the payload that trigger:
"{\"scene\": 12, \"level\": 1, \"duration\": 2}"
and change to:
"{\"scene\": 12, \"level\": 0, \"duration\": 2}"

Here is what I have done so far:

alias: Casambi Force turn off
triggers:
  - trigger: mqtt
    options:
      topic: casambi/0/set/scene_level
      payload: "1"
      value_template: "{{ value_json.level }}"
actions:
  - action: mqtt.publish
    metadata: {}
    data:
      evaluate_payload: false
      qos: 0
      topic: casambi/0/set/scene_level
      payload: "{\"scene\": 12, \"level\": 0, \"duration\": 2}"
    enabled: true
mode: single

And that was quite easily solved. Thanks Gemini for that :slight_smile:
Used the following as payload

  payload: >
    {
      "scene": {{ trigger.payload_json.scene }},
      "level": 0,
      "duration": {{ trigger.payload_json.duration }}
    }