Advice for a newbie on adding a button to intercept an automation

(If I’ve posted this in the wrong category, please advise. Thanks.)

I’m only a few months into my HA journey, but I do know some basics – 20 devices, have created some automations, used a few blueprints, applied a ZHA quirk, and so on.

I have a simple light automation in my front porch using a door sensor for the outside door and a motion sensor for people coming from inside. If either sensor is triggered, and if the porch is under 400 lumens, it turns on an overhead light, waits 2 minutes, and turns it off.

It’s currently that simple. It doesn’t even check if there is still motion during those 2 minutes in order to leave the light on.

What I want to add is a button to that mix, for the following:

*A single button press will turn on the light, regardless of sensors, and just leave it on (no timer). Sometimes I just want the light on in there.

  • A double-press will turn the light off, and leave it that way, regardless of sensors. Sometimes I want to sit in there without the overhead light.
  • A long-press will return either of the above two states back into the default, triggered by sensors and then off after 2 minutes.

I have the button integrated in HA, and can react to single/double-long presses, so I don’t need help there. But what is the smartest way to program/accomplish my plan? Should I be learning how to create a blueprint (so far I’ve only applied others)? A complex automation? Is this a place for templates, which I’m just learning now? Is there a better or simpler way?

Many thanks!

Based on what you described, a double-press must inhibit your existing automation (to perform its actions) and a long-press re-establishes it.

Use an Input Boolean as a “flag” (on for a double-press, off for long-press). Your existing automation can use a State Condition, that checks if the Input Boolean is on or off, to determine if it should or shouldn’t control the lights based on motion detection.

You can create a separate automation to detect the button events and control the Input Boolean’s state or, slightly more advanced, you can incorporate the functionality into your existing automation.


NOTE

Instead of creating an automation to control an Input Boolean, a more advanced way is to create a Trigger-based Template Binary Sensor.

It is a single entity that combines the functionality of an automation and an Input Boolean.

One note of caution here, I have found that when you give individual lights or groups of lights an override (to disable automation) people forget to return the light back to automatic function.

So at some point in the future, someone walks past the IR sensor and says - why is it not working…

An alternative strategy is to use “house modes”, I keep mine really simple (I would suggest you start the same), but you are free to make things as complex as you want.

Anyway, I only have 4 modes:

  • Manual
  • Day
  • Night
  • Away

Most of the time my system is in “Day” mode, Night really means asleep and away means no-one is home.

Having house modes means that:

  • You can add a condition to each automation so that it only runs if the house is in a certain mode (or modes).
  • Doing this means that the automations are less/not annoying for example only a few light come on automatically at night and they are very dim.

The implementation is almost identical to Taras - the main difference is that I use an input.select instead of an input.boolean.

I primarily use scene switches to switch house modes:

  • There is a Last To Leave / First Home button by the door.
  • And I have a button in the bedroom for Going to Sleep
  • I have an automation that puts the system back in Day mode if:
    • The time is before Noon. and
    • The sun is up. and
    • There is movement on specific IR sensors.

Note: I could add additional automations for Sleep and Away, but frankly it’s so minimal effort to hit one button and there are times I go out to collect the mail etc so its just not worth the effort.

Another point is that all my lights have local control:

  • One click on
  • Double click off

However the automations control the same lights, hence they will come on and off automatically most of the time (unless house mode is manual). Hence I can put a light on and it will stay on until motion is detected then it will go off again once motion clears - which is typically what I want.


A simply enhancement that may work for you, may be to have two modes:

  • Inside house mode.
  • Outside house mode.

That may give you a lot of flexibility with respect to how you want the automations to work.