#Hello I m confused in HA between

1 messages · Page 1 of 1 (latest)

wicked thistle
#

I made an automation script:

#
alias: salon - NAD-MPD remote control
description: ""
trigger:
  - platform: event
    event_type: esphome.remote_nad_button
condition: []
action:
  - if:
      - condition: template # key 1
        value_template: |
          {{ trigger.event.data.message == '0xF30C' }}
    then:
      - service: media_player.play_media
        data:
          media_content_type: playlist
          media_content_id: radio_radio_classique
        target:
          entity_id: media_player.mpd_salon
...
#

But as I want to make custom dashboard with buttons to do the same, I tried to write a blueprint with an ir_cmd parameter. The idea is to have the code centralized into the blueprint and trigger the right action using a human understandable key name instead of the NEC IR keyscan code...

#

My blueprint looks like this:

#
blueprint:
  name: MPD IR remote controller
  description: >-
    A script that control mpd daemon through remote IR
  domain: script
  source_url: https://git.ricozome.net
  author: Eric Belhomme
  input:
    ir_cmd:
      name: IR command pressed
      description: The key pressed on IR remote, in human readble string
      selector:
        text:

mode: restart

sequence:
  - alias: NAD key 1 button
    if:
      - condition: template
        value_template: "{{ ir_cmd == '1' }}"
        #          {{ trigger.event.data.message == '0xF30C' }}
    then:
      - service: media_player.play_media
        data:
          media_content_type: playlist
          media_content_id: radio_radio_classique
        target:
          entity_id: media_player.mpd_salon
  - alias: NAD key 2 button
...
#

But now I miss the glue that would allow me to use my blueprint from either an automation script or a dashboard !
I tried to make a script but it requires me to provide a value for my input ir_cmd 😢

Ideally, I would call my blueprint like I do for a service ! How could I do that ?

fleet parcel
#

Automations, scripts, blueprints, and scenes are 4 different things in Home Assistant. There is no such thing as an “automation script”.

#

An automation is basically a script that has a trigger and (optionally) conditions that control when it is executed. A script has to be called in order to be executed.

#

You can pass variables into scripts and use them inside the script

#

script:
  my_example_script_that_calls_another_script:
    alias: "Example Script that calls another one"
    sequence:            
      - service: script.my_other_script
        data:
          my_variable: "some value"
#

You can call scripts from the front end, like a button push on a dashboard, and you can call it with whatever variables you want, just like the example above

#
script:
  my_other_script:
    alias: "Example Script that uses an passed-in variable"
    sequence:
      - service: notify.my_phone
        data:
          message: "{{ my_variable }}"