How to create an MQTT slider?

I want to add a slider to the GUI that sends MQTT messages when being dragged. From the docs I added the following code to the configuration file:

input_number:
  myslider:
    name: myslider
    initial: 30
    min: -20
    max: 35
    step: 1
    
automation:
  - alias: "Temp slider moved"
    trigger:
      platform: state
      entity_id: input_number.myslider
    action:
      service: mqtt.publish
      data:
        topic: "setTemperature"
        retain: true
        payload: "{{ states('input_number.target_temp') | int }}"

Now I can add “myslider” to the GUI. But dragging it around triggers no MQTT message at all.
What could be the issue?

Did you solve it?