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!
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.
switch:
# For HADashboard to switch automation
- platform: template
switches:
sw_motion_01:
value_template: "{{ is_state('automation.motion_detection_01', 'on') }}"
turn_on:
service: automation.turn_on
entity_id: automation.motion_detection_01
turn_off:
service: automation.turn_off
entity_id: automation.motion_detection_01
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.
door_chime:
widget_type: switch
title: Automation Switch
use_hass_icon: 1
entity: automation.door_chime__door_open
TIL! That’s easier!
very cooll, will use it. Although is not an automation anymore, it should be called manualation
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.
etc.
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.
Furthermore the following covers the value_template
in a template switch:
value_template
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.
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?
Thanks,
Robert
@rob0225 Hi Robert. Did you find a way to do this? I am in the same place, I would like to have a virtual switch to chose between 2 active automations, one for when the house is on vacation mode and one for when it’s in normal mode. I now use an entity card to just chose to turn on/off those two automations, but it would be so much better having a virtual switch just say “Work” and “Vacation” and then enable/disable those two automations automatically. Any help would be greatly appreciated.