Run automation from input_button

Hi all.
I’m developing a dashboard for irrigation.
Most of the settings are automatic, I set the days, time and duration and the automations do all the work.

However, I need a button for manual activation of irrigation for a variable duration.
I have created a input_button and input_number

This is the dashboard code:

         - type: custom:button-card
            entity: input_button.irrigazione_manuale
            name: "START Irrigazione Manuale"
             tap_action:
              action: call_service
              service: automation.trigger
              service_data:
                entity_id: automation.irrigazione_manuale_zona_1

And this is the automation:

alias: Irrigazione Manuale Zona 1
description: ""
trigger: []
condition: []
action:
  - type: turn_on
    device_id: 59942181bceb160e186d58a5da290189
    entity_id: switch.irrigazione_orto
    domain: switch
  - delay:
      hours: 0
      minutes: "{{ states('input_number.zone1_manual_duration') | int }}"
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: 59942181bceb160e186d58a5da290189
    entity_id: switch.irrigazione_orto
    domain: switch
mode: single

but it does not work, the automation not start.

Where am i wrong?

Regards,
Marco

Your indentation is wrong on the button card, and it’s data not service_data. Should be thus:

         - type: custom:button-card
           entity: input_button.irrigazione_manuale
           name: "START Irrigazione Manuale"
           tap_action:
             action: call_service
             service: automation.trigger
             data:
               entity_id: automation.irrigazione_manuale_zona_1

An automation without a trigger is a script — perhaps write it as a script and call it like that?

Besides, if your “automation” does not actually have a trigger, you should make it a script.
If it’s just an example, you might want to use an actual button helper:

Thank.
Yes, you have right

I’m trying via script too, but the result is the same. I tried changing indentation and service_data to data but it doesn’t work.

            tap_action:
              action: call_service
              service: script.turn_on
              data:
                entity_id: script.irrigazione_manuale_zona_1

You have to create a script — you can’t just call the automation as a script.

Does your existing automation work if you trigger it manually?

Yes, with “Button” it works fine, but I have created a heavily customized dashboard and would like to continue using the custom button

Yes, I have created the script and worked fine if called from “button”

alias: Irrigazione Manuale Zona 1
sequence:
  - type: turn_on
    device_id: 59942181bceb160e186d58a5da290189
    entity_id: switch.irrigazione_orto
    domain: switch
  - delay:
      hours: 0
      minutes: "{{ states('input_number.zone1_manual_duration') | int }}"
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: 59942181bceb160e186d58a5da290189
    entity_id: switch.irrigazione_orto
    domain: switch
mode: single

And yes, the automation work if manually run

1 Like

It doesn’t matter how you display it.
You can use its button.press service.

But yeah, if you actually go to a script, this is irrelevant

I am an idiot!!!

Is not: action: call_service
but: action: call-service

Sorry for wasting your time!

Marco

1 Like

Well spotted. I’m annoyed I didn’t see that. Glad it works now!

hi! in triying to create and automation coming from an input with luck… any idea?

alias: piscina
description: “”
trigger:

  • platform: numeric_state
    entity_id:
    • sensor.living_clima_temperature
      above: input_number.termostato_piscina
      id: apagar piscina
      for:
      hours: 0
      minutes: 0
      seconds: 0
  • platform: numeric_state
    entity_id:
    • sensor.living_clima_temperature
      id: prender piscina
      below: input_number.termostato_piscina
      for:
      hours: 0
      minutes: 0
      seconds: 0
      condition:
      action:
  • choose:
    • conditions:
      • condition: trigger
        id:
        • apagar piscina
          sequence:
      • service: input_boolean.turn_off
        target:
        entity_id: input_boolean.termostato_on_off_piscina
        data: {}
    • conditions:
      • condition: trigger
        id:
        • prender piscina
          sequence:
      • service: input_boolean.turn_on
        target:
        entity_id: input_boolean.termostato_on_off_piscina
        data: {}
        mode: single

@kilopter This is unrelated to this thread, open a new one.
And format your code. At first sight you invented that trigger has a choose