I want to create an automation which lowers the volume of a given mediaplayer and in the last step it should be reset the volume to the value before starting the automation.
My try so far:
alias: Pause Audio while listening
description: Schalten Audio stumm, solange Home Assistant Voice aktiv ist
triggers:
- trigger: state
entity_id:
- assist_satellite.ha_voice_office_assist_satellit
to: listening
conditions: []
actions:
- action: input_number.set_value
data:
value: "{{(state_attr('media_player.office','volume_level')|float)}}"
target:
entity_id: input_number.mm_volume
- action: media_player.volume_set
metadata: {}
data:
volume_level: 0.05
target:
device_id: <id>
enabled: true
- wait_for_trigger:
- trigger: state
entity_id:
- assist_satellite.ha_voice_office_assist_satellit
to: idle
- action: media_player.volume_set
metadata: {}
data:
volume_level: "{{states('input_number.mm_volume')|float}}"
target:
device_id: <id>
enabled: true
mode: single
But obviously the former state is either not saved to variable or not applied back.