I am using the template below
I am using it a progress bar (playing a video from 0-100%)
I have an MQTT updating progress of the video.
I want to use the slider to jump to a “percentage”
The problem is, when the MQTT message updates the number the, automation sends that number out via MQTT (on the same topic i want to control it with) so i get stuck in a loop.
i only want to send the MQTT message when I adjust the slider on UI, not on every update.
# Example configuration.yaml entry using 'input_number' in an action in an automation
input_number:
target_temp:
name: Target Heater Temperature Slider
min: 1
max: 30
step: 1
unit_of_measurement: step
icon: mdi:target
# This automation script runs when a value is received via MQTT on retained topic: setTemperature
# It sets the value slider on the GUI. This slides also had its own automation when the value is changed.
automation:
- alias: Set temp slider
trigger:
platform: mqtt
topic: 'setTemperature'
action:
service: input_number.set_value
data_template:
entity_id: input_number.target_temp
value: "{{ trigger.payload }}"
# This second automation script runs when the target temperature slider is moved.
# It publishes its value to the same MQTT topic it is also subscribed to.
- alias: Temp slider moved
trigger:
platform: state
entity_id: input_number.target_temp
action:
service: mqtt.publish
data_template:
topic: 'setTemperature'
retain: true
payload: "{{ states('input_number.target_temp') | int }}"