Publish an analog value in MQTT by a custom slider row?

Hello,
I have an equipment (robot mower) which communicates with HA in MQTT. I have no problem sending simple values via the MQTT Publish on a topic in order to activate switches or retrieve values from sensors.
Today I want to send an analog value, a setpoint between 17000 and 18000 with a step of 100, on an MQTT topic via a custom slider row.
But I can’t figure out how to do it …
Who can tell me a lead?
thank you

In configuration.yaml :

input_number:
  slider1:
    name: Slider
    min: 17000 
    max: 18000 
    step: 100

In automations.yaml :

- id: '1587227266097'
  alias: robot mower
  description: ''
  trigger:
  - entity_id: input_number.slider1
    platform: state
  action:
  - data:
      payload_template: "{{ states("input_number.slider1") | int }}"
      topic: your_topic
      retain: false
    service: mqtt.publish

2 Likes


Thanks it works well.
I did not know this feature;)

g2_charge_batt:
  name: reglage charge batterie
  initial: 2200
  min: 1600
  max: 2600
  step: 100
  unit_of_measurement: mAh
  mode: slider


``
  - id: G2 charge batt
    alias: G2 Charge batt
    trigger:
      platform: state
      entity_id: input_number.g2_charge_batt
    action:
     - service: mqtt.publish
       data:
         topic: "Automower/AM_G2/Cmd/Cbattmax"
         payload_template: "{{ states('input_number.g2_charge_batt') | int }}"
         retain: false