Where We Are Going We Don’t Need Modes
Ok, so that is a lie.
Turns out there is a case to be made for modes within Home Assistant. For example, my wife complained when my collection of presence trackers decided to freak out and start spamming notifications to her phone. I mean, who wouldn’t right. We hit our daily spam quota just opening our email client each day we shouldn’t have to deal with app spam too. So, I added the ability for her to control her notifications via the Home Assistant UI.
I started out looking for how other people implemented say a Vacation Mode in Home Assistant. What I found was that every one I looked at (ok, I didn’t look at them all) solved it with an input boolean. An input_boolean is simple way to mark something as on or off within Home Assistant.
And at first glance that seems the obvious answer. It will keep the state between restarts, as long as you don’t set the initial value, but what if you wanted to a third-party process control the switch and you just happen to have an MQTT broker lying around?
So instead of input_booleans I created some MQTT switches. In the case of giving my wife the ability to suppress her notifications, I set up the following switch:
- platform: mqtt
name: Text Notify Kat
Then I just added the switch to my groups to display on my UI. After that, all that was left to do was add the condition to my notification automations:
Then if my wife wanted to kill the text notifications all she had to do was flip the switch and the notifications would stop. For notifications I consider to be security or safety, I just left the condition out of the automation or script.
From there I added a vacation mode, a guest mode, secure mode, and might have a few others. Each one gives me an easy way to control the context of various automations via the UI.
Like I said before you could accomplish all of this via an input_boolean, and if you did it that way you would certainly get the job done. But if you are already using MQTT and this is simply another way of getting the job done.