Button to start an automation

Hi

I am using Lovelace banner cards and would like to have a button to start an action (switches an heater on for 1 hour).

Current configuration:

type: custom:banner-card
background: '#ff8a8a'
heading: 🖥 Studio
color: black
entities:
  - entity: sensor.netatmo_casetta_studio_temperature
    name: Temperatura
    map_state:
      unavailable: '-'
  - entity: switch.albero_di_natale
    name: Stufetta
    map_state:
      unavailable: '-'

The automation I would like to start

- id: "1641221878295"
  alias: Stufetta studio 1 ora
  description: "Stufetta studio 1 ora"
  trigger:
    - platform: event
      event_type: ios.action_fired
      event_data:
        actionName: Studio1o
  condition: []
  action:
    - data:
        entity_id: switch.albero_di_natale
      service: switch.turn_on
    - delay: 01:00:00
    - data:
        entity_id: switch.albero_di_natale
      service: switch.turn_off
  mode: single

Any idea?

Many thanks

Matteo

You could do it with a script and an input boolean. The script would be the button. The input boolean would trigger the automation.

Example
input_boolean:
  boost_studio:
    initial: false

script:
  boost_studio:
    alias: "Boost Studio Heat for 1 hour"
    sequence:
      - service: input_boolean.turn_on
        data:
          entity_id: input_boolean.boost_studio
      - delay: "00:00:05"
      - service: input_boolean.turn_off
        data:
          entity_id: input_boolean.boost_studio

## Add trigger to automation
  trigger:
    - platform: event
      event_type: ios.action_fired
      event_data:
        actionName: Studio1o
    - platform: state
      entity_id: input_boolean.boost_studio
      to: 'on'
      from: 'off'

You could simply use a service call:


  action: call-service
  service: automation.trigger

1 Like