Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Needing help with script (noob guy)

$
0
0

@jsantos wrote:

So I’m doing my first steps with HA and I want to create a way to choose a radio station to play on my soundbar using TuneIn. I’ve got a rest service configured like this (using the station parameter):

rest_command:
  change_station:
    url: http://xx.xx.xx.xx:55001/CPM?cmd=giantCommand...{{ station }}restOfGiantCommand
    method: GET

If I execute this service with developer tools it works great.
Using some information I got from these forum I added this to configuration

input_select:
  radio_station:
    name: 'Select Radio Station:'
    options:
      - Option1
      - Option2

And this script

radio_script:
    alias: Play Radio on Soundbar
    sequence:
      -  service: rest_command.change_station
         data:
           station: >
            {% if is_state("input_select.radio_station", "Option1") %} 3
            {% elif is_state("input_select.radio_station", "Option2") %} 4
            {% endif %}

And this lovelace entity

entities:
  - entity: input_select.radio_station
  - entity: script.radio_script
show_header_toggle: false
title: Teste
type: entities

This doesn’t work. If i change the script to have a fixed value like bellow it will work but I can’t control the station

radio_script:
    alias: Play Radio on Soundbar
    sequence:
      -  service: rest_command.change_station
         data:
           station: 3

I’ve searched online but can’t find out what i’m doing wrong. Thanks

Posts: 6

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>