Enable / disable automation

What would be the easiest way to make an automation appear as a switch on hadashboard?

I have a single automation I would like to make a button on my dashboard.

Thank you!

I do it with a template switch.

  # For HADashboard to switch automation
  - platform: template
        value_template: "{{ is_state('automation.motion_detection_01', 'on') }}"
          service: automation.turn_on
          entity_id: automation.motion_detection_01
          service: automation.turn_off
          entity_id: automation.motion_detection_01
1 Like

a script widget?
or an input boolean that you turn off at the end of the automation?

i actually just tested this on a dashboard and it works.

   widget_type: switch
   title: Automation Switch
   use_hass_icon: 1
   entity: automation.door_chime__door_open

TIL! That’s easier! :grinning:

very cooll, will use it. Although is not an automation anymore, it should be called manualation :stuck_out_tongue:

What does the value_template exactly do? It reads the state of the automation… and then does what?

that created a template switch(see template switch in docs) to turn an automation on or off.

but nowadays that isnt usefull anymore. the cript widget or switch widget from HADashboard will work as well.

Thanks, I’ve read the docs and saw that they also use value_template.
As I understand it value_template evaluates to True or False during runtime:
value_template: True
What I don’t get is, what does it do when it is True?

it depends where you use it.

in a template switch, the template makes the switch turn on or off
in a template sensor it sets the state from a sensor.

So, in a switch:
If this evaluates to True:
value_template: "{{ is_state('device_tracker.paulus', 'home') }}"
the switch will turn ON.
But if it evaluates to False, the switch will turn OFF.

Is this correct?

First of all, thank you.
And, yes it explains what is_state() does. That’ s a start. :wink:

Furthermore the following covers the value_template in a template switch:

Defines a template to set the state of the switch. If not defined, the switch will optimistically assume all commands are successful.

Almost there. Still, not clear enough to me. :wink:
And in line with the documentation of availability_template which is much clearer on this topic I would have added:
If the template returns true , the device is on . If the template returns any other value, the device will be off .

I’ve got this working on a single automation using the template above and a Button Card to activate it. Is there a way to have the switch or the button disable more than one automation? And is there a way to have the option to disable the automation or only disable it for a period of time?