Hi
I’m trying to pass a variable from my MQTT automation - but I’m having trouble getting it to work, even when I hardcode the value in the automation.
This is my script:
volume_up_stue:
sequence:
service: media_player.volume_set
entity_id: media_player.stue
data_template:
volume_level: '{{ states.media_player.kkken.attributes.volume_level + my_volume }}'
This is my automation:
automation:
- alias: Sonos Volume Up Stue from MQTT
trigger:
platform: mqtt
topic: sonos/stue/volume_up
payload: "1"
action:
- service_template: script.volume_up_stue
data_template:
variables: >-
my_volume: '0.5'
Now, in time I would like to be able to set “my_volume” from MQTT or from another trigger, but for now I just want the 0.5 value passed to my script and getting that to work…
As I understand the documentation, variables set in a data_template should be available in the script that is called. But I’m still trying to figure out the difference om service_template and data_template, and where to put my variables.