Setting input_slider value from mqtt topic

Hi
I’ve searched a bit and found and adopted the following code

- alias: Set backdrop slider
  trigger:
    platform: mqtt
    topic: "lights/backdrop/status"
 action:
    service: input_slider.select_value
    data_template:
           entity_id: input_slider.backdrop
           value: '{{ trigger.payload.state | int }}'

My problem is I don’t have enough knowledge to decode the mqtt payload to set the slider using the state
part of the payload

the topic is lights/backdrop/status

it returns the following

{
“log”: “GPIO 5 Set PWM to 0”,
“plugin”: 1,
“pin”: 5,
“mode”: “PWM”,
“state”: 0
}

Any help would be much appreciated

I would create a MQTT sensor which extracts the needed data for the slider (maybe not the most elegant way).
Something like this maybe (not tested):

sensor:
  - platform: mqtt
    state_topic: 'lights/backdrop/status'
    name: 'Backdrop'
    value_template: '{{ value_json.state }}'

and then use this sensor in your automation

- alias: Set backdrop slider
  trigger:
    platform: mqtt
    topic: "lights/backdrop/status"
  action:
    service: input_slider.select_value
    data_template:
      entity_id: input_slider.backdrop
      value: '{{  states.sensor.backdrop.state  }}'

Thank you, I used this and is working well

Moved this topic to the configuration category.