I try to pass a variable to a script. I want my Google Home lower it’s volume when my son is sleeping, based on a input_select. Unfortunately I get an error and I am not that experienced with variables. I think I messed up some examples I found on the forum.
I got this automation and script:
alias: change volume when son is sleeping
trigger:
platform: state
entity_id:
- input_select.niek_status
action:
service_template: >-
{%
if (
is_state('input_select.niek_status', 'sleeping')
)
%}
service: script.set_volume_googlehome
data_template:
variables:
volume: '{{ 30 }}'
{%
elif (
is_state('input_select.niek_status', 'awake')
)
%}
service: script.set_volume_googlehome
data_template:
variables:
volume: '{{ 70 }}'
{%- endif %}
set_volume_googlehome:
alias: 'Set volume Google Home'
sequence:
- service: media_player.volume_set
data_template:
entity_id: media_player.home
volume_level: '{{ volume }}'
The error I get:
2020-03-06 15:32:44 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.change_volume_when_son_is_sleeping. Invalid data for call_service at pos 1: Service service: script.set_volume_googlehome
data_template:
variables:
volume: 70 does not match format <domain>.<name>