Hey there. I want to save the volume states of my Alexa devices before I start the script. The devices always differ and that is why I want to use the list of targets to iterate over and use the target name as a variable name to automatically save the volume value of the device and not manually change it for every automation and every device.
What I tried:
repeat:
sequence:
- variables:
{{target}}: >-
{{ state_attr('{{target}}', 'volume_level') | default(0.5, true) |
float }}
for_each: "{{target}}"
The automation that delivers the values looks like this for example:
service: script.nachricht_uber_alexa
data:
message: >-
KĂĽhlschrank und oder SpĂĽlmaschine haben keinen Strom. Bitte prĂĽfe das
sofort.
target:
- media_player.saschas_echo_dot_kuche
- media_player.saschas_echo_dot_wohnzimmer
- media_player.saschas_fire
Anyway, the above code will end up in the following and not work:
repeat:
sequence:
- variables:
"[object Object]": >-
{{ state_attr('{{target}}', 'volume_level') | default(0.5, true) |
float }}
for_each: "{{target}}"
How is it possible to save the volume values for all devices in the target list (variable)?