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

Call a rest_command based on trigger name and value

$
0
0

@Samuele_Sommariva wrote:

Hello, the general goal is in the title.

I want to turn on and off certain services (squeezebox, airplay, spotify) on each of my 3 music player.
I want it to be user friendly so that also my wife knows how to do it.

To do that, I have defined as many input_boolean as needed

and I created as many rest_command as needed, two for each variable

input_boolean:
  hfb_sala_spotify:
  hfb_cucina_spotify:
  hfb_bimbi_spotify:

  hfb_sala_airplay:

and many more

I need to write a single automation that calls the appropriate method based on the trigger.

If the trigger is hfb_sala_spotify, and it was turned on, I want to call rest_command.hfb_sala_airplay_on

This is not working

  trigger:
  - entity_id: input_boolean.hfb_sala_airplay
    platform: state
  - entity_id: input_boolean.hfb_sala_spotify
    platform: state
  - entity_id: input_boolean.hfb_cucina_spotify
    platform: state
  condition: []
    action:
  - service_template: >
      rest_command.{{trigger.entity_id.split(".") [1]}}_{{trigger.to_state.state}}
   

but if i can get the right notification if I change the action

action:
  - service: notify.mobile_app_sm_n960f
    data_template:
      message: >
        rest_command.{{trigger.entity_id.split(".") [1]}}_{{trigger.to_state.state}}

Any clue is welcome

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 102460

Trending Articles



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