Pass parameters to scripts and react to it

I am getting mad :slight_smile: Why doesn’t that work?

I want to create a script, that accepts 4 different commands (on, off, lock, unlock) to create a “black box” with special features. BUT i can’t pass any data from the sender script to the receiver script, better say i can’t get the receiver to react to it.

Does anybody see the bad?

Thank you!

alias: sender
sequence:
    - service: script.receiver
    data:
      command: "on"
mode: single



alias: receiver
sequence:
  - choose:
      - conditions:
          - condition: template
            value_template: "{{command}} == \"on\""
        sequence:
          - service: light.turn_on
            data: {}
            target:
              entity_id: light.kuche
mode: single



Indentation. data should align with service.

Sorry, maybe i misdirected you. The Problem is Not, that the Data doesnt Reach the Receiver Script. The Problem is, that the condition Template doesnt seem to be interpreted right.

this:
  entity_id: script.receiver
  state: 'off'
  attributes:
    last_triggered: '2023-04-05T20:29:43.415733+00:00'
    mode: single
    current: 0
    friendly_name: receiver
  last_changed: '2023-04-05T20:32:28.257195+00:00'
  last_updated: '2023-04-05T20:32:28.257195+00:00'
  context:
    id: 01GX9HXV31X9Z8J9FH8Q9KYC4S
    parent_id: null
    user_id: null
**command: 'on'**
value_template: "{{ command == 'on' }}"

Thanks mate, this one does the magic!

1 Like

But why doesn’t this thing work as a button on love lace? It says “extra keys not allowed”.

show_name: true
show_icon: true
type: button
name: aus
tap_action:
  action: call-service
  service: automation.trigger
  data:
    entity_id: automation.receiver2
    command: 'on'
entity: automation.receiver2

Scripts are not automations.

I don’t get that. I want to do an automation, which i can trigger from a script, or a love lace button and send 4 parameters as a command, on, off, lock and unlock. Depending on this command, i want the automation to do things. But i have to do it by an automation, because the same automation has to be triggered by a timer. If this wasn’t, i could do it by a script.

It should be a “blackbox” for light. on - light on, off - start timer, off after timer finishes, lock - light on and stay on, whatever happens, unlock - switch off light an go back to “automatic mode”, so to say switch of by timer.

Thats why i need an automation, which takes a variable command.

That’s the first time you’ve told us that. Automations do not take parameters, which is why you’re getting the error message. You could use an input_text helper and set that from your button, then have a change of that helper as one of the triggers for your automation; and the last step of the automation clears the helper.

Not sure how much help you’re looking for here: have you written the automation?

No, but knowing that, helps me a lot and i may start writing the automation. Thank you!