Button to turn on/off automations

I would like to program a button on my home assistant that turns on and off some automations.

I have a house that from time to time i need to turn off automations when i am away and turn them back on when i am coming back. Is there a way to have a button that says ‘activated’ when i toggle the button and turn on all automations and ‘deactivated’ when i toggle the button to turn them off…

entity_id: automation.lights
entity_id: automation.water
entity_id: automation.heating

I currently have 3 automations that i would like to toggle on and off.

Kind regards

1 Like

You can use an input_boolean as a switch and put a condition in your automations in order that it can only run when input_boolean.lights is ON.

1 Like

You can put directly your automation entities on the UI. That way you will be able to turn them on and off. No need to create an input boolean to do that

5 Likes

You could do it manually with input_boolean, but I suggest looking in to device tracking to automate this instead. For example, if you have an Asus router, there is an HA device tracker component that can register when your phone is connected to wifi or not. So when you arrive home, your phone connects to your router wifi, HA see’s this, and then allows your automations to be active. When you leave, the phone disconnects from wifi, HA then disables automations until it see’s your phone on wifi again.

I believe there may be similar components for other brand routers too, and there are many other non-wifi ways HA can track your presence near your home. There are BT devices, gps based cloud services, etc… that can be used to automate this. One caveat with wifi presence… since iphone’s like to disconnect wifi randomly, they usually require a few minute delay after disconnect for things to work reliably. This means with wifi presence, automations may run a few minutes after you leave, if that matters.

I thought about the device tracker however i sometimes have to turn on the water and heating 24 hours in advance… so my phone won’t be connected.

1 Like

I hadn’t thought of just adding the entities to a card. It of course works. I guess my problem is more of an ‘aesthetic’ one. I guess id like exactly the same as this:

type: entities
entities:
  - entity: automation.main_house_water
  - entity: automation.main_house_heating
title: Turn on house

but as a big shiny button with an icon of a house… :slight_smile:

P.S i am a newbie, i installed HA yesterday so am discovering everything, so sorry if i cant be more helpful!!

2 Likes

I had read something about putting the entities in to a group and using a button that way, but have no idea how to implement that

Gotcha… paste this in your configuration.yaml and restart HA:

input_boolean:
  turn_on_house:
    name: Turn On House

That will give you an entity input_boolean.turn_on_house that you can add as a switch to your GUI using glances or whatever you like. Then, you add this entity in to the logic of your automations, et voila. I do the same thing for my x-mas light automations… but I use nodered so the automation part is different than yaml. After I put the lights up, I turn on the boolean (this kills a front yard plug earlier than normal to save energy). After xmas I take down the lights, and turn off the boolean.

1 Like
type: button
tap_action:
  action: toggle
hold_action:
  action: more-info
icon: mdi:home
show_icon: true
show_name: true
entity: automation.main_house_heating

You can literally do this from the UI, Button card.

If you want them all at once, just make a group.imhome and make that the entity

5 Likes

That button is perfect!

Many thanks for everyone’s help! There are so many ways to do the same thing it seems but its good to learn them all, it comes in handy for other ideas!!

1 Like

I have sucessfully managed to create a group of automation entities as well as a button. However when i push the button, the colour of the home icon does not change. It toggles the automations, so in that respect it works, but the colour of the icon stays the same. Is there any way to define colours for toggle status?

I believe you can only achieve this using custom plugin, like Button-Card. You can read more about HACS. You will get much more flexibility.

Hi Guys !

Keeping this topic…
Is possible with 3 Toogles, and just allow one enable toogle of them on same time, the others two keeps off.

Examples :
Toogle 1 - ON (Manually click)
Toogle 2 - OFF (Auto off)
Toogle 3 - OFF (auto off)
–=-
Toogle 1 - OFF (auto off)
Toogle 2 - ON (Manually click…)
Toogle 3 - OFF (auto off)
—=-
Toogle 1 - OFF (auto off)
Toogle 2 - OFF (auto off)
Toogle 3 - ON (Manually click…)

Hope can transmit the correct message

1 Like