Media Player volume in script

I have IFTTT setup with this:

Google Assistant Say - “set tv volume to #”

Maker Webhook URL - http://IP/api/services/script/tv{{NumberField}}?api_password=MYPASSWORD

Body - { “script”: “tv{{NumberField}}” }

I am stuck with the script part.
I dont know how I would actually change the volume level.
For example tv1 should set volume_level on the tv to 0.1
Where would I put that line telling it to set the level to 0.1?

script:
tv1:
sequence:
- service: media_player.volume_set
data_template:
entity_id: media_player.tv

It would be something like

action:
- service: media_player.volume_set
  data_template:
    entity_id: media_player.tv
    volume_level: 0.1
1 Like

So like this? and just have the the tv1 and 0.1 change with the volume level?
tv1:
action:

  • service: media_player.volume_set
    data_template:
    entity_id: media_player.tv
    volume_level: 0.1

Please check how to format your code correctly. Makes it easier to read.

Try something like this:

tv1:
  sequence:
    - service: media_player.volume_set
      entity_id: media_player.tv
      volume_level: 0.1

Failed config
General Errors:
- Component not found: tv1
- Setup failed for tv1: Component not found.

I have removed the errors and have the code below, but nothing happens when i trigger IFTTT:

# Volume Script
script:
  tv1:
    sequence:
      - service: media_player.volume_set
        data:
          entity_id: media_player.tv
          volume_level: 0.01

I don’t know anything about IFTTT integration but did you try the script itself inside HASS?

How do I do that ?

In GUI there should be a representation of your script. You simply press ACTIVATE.

Example:

I did something similar to this last night.
I created a template light (which I can then import to Alexa and google assistant)
In the script I had to convert the light’s base 255 value to the audio component’s 0-1.
It was really simple after that.
“Alexa, TV 50%” sets the volume to 35 (max volume is 70. who uses max 70?!)

I would like to control volume on my set top box with Google Home (I setup via Nabu Casa).

How do I expose volume control to Google Home?