Off/Home/Away switch [solved]

Hello list,

Newbie to HA, in my first install, I found a small piece of code somewhere to add to configuration.yaml (AFAIK) that gave me a three-state home/off/away option. When pressing “away” there was an offset option (it waited X seconds before entering into the “away” state. I cannot find it anymore. It was just a manual state setting with two or three buttons (green, yellow and red IIRC).

Anyone a hint?

Richard.

What this switch do? And what are you using this for?

Just switch the state: off, home or away…

State of what? Person, device, i don’t know.

State of HA…

:grinning:
Why do you have state of ha away? Where does it goes? Out for a beer with guys :grinning:

1 Like

Off: what most people call “home”
Home: when you’re home (at night)
Away: drinking beer at the pub :slight_smile:

If you just want something you can change manually - select helper.

If you want something that you can change manually and can automatically change at times (like automatically switching to away when everyone leaves to go to the pub) - trigger template select. That’s what I do personally, is a bit complicated though.

Well, I know, I came across these options, but what I’m looking for is a small piece of configuration.yaml code with these two or three button options.

The first install, in which I had found that code, was a HAOS install, now I run a core install on a RPi. Could that be the reason I cannot find it?

R.

No, that doesn’t matter. If you click this below:
Open your Home Assistant instance and start setting up a new integration.

It will take you straight to the screen to make a drop-down helper (input select) in the UI with as many options as you need. If you really want to you can also make input selects in yaml, see here for how.

Not really sure what you mean by the buttons. That sounds like a UI presentation option which goes in a dashboard not in configuration.yaml.

Regardless both an HAOS and a container install run the same HA container. The only difference is in an HAOS install supervisor starts the HA container correctly for you, in a docker install the admin must correctly run the container on their own.

EDIT: oh core install. Well still all 4 install methods use the same pip libraries and code. The install methods that use the container handle the dependencies for you, in a core install you do that yourself. But still the same HA either way.

Thanks for your reply. I know that I can build one myself (and I will take your example if I cannot find the code) but I was just curious if anyone knew that piece of code I was talking about. I really can’t remember what I did at that time, I was completely new to HAOS. I removed HAOS and opted for the core install as I want to understand exactly how it works. And HAOS does not allow to change e.g. the chown of /dev/i2c*, because I want to use PCF8574’s.

The piece of code I found was not big IIRC. It gave me a three state option: home/away/off. I saw two buttons on the dashboard IIRC:

off: home and away
home: off and away
away: off and home

When pressing “away” there was also an option in seconds as an offset: a timeout before the “away” becomes active.

The three-state is how old alarm systems generally work. I’d rather have some buttons instead of an automagic home/away system.

R.

As mentioned above, use drop down helper. There you can define statuses. And the rest is just using automation to set status for entity you want to configure. You don’t actually need to write code as all of this can be done in gui.

Ok, thnx! I’m not a GUI guy. I think I’ll have just two buttons which change their function. If the state is “X” it does not make sense to have a button to activate “X”. I hope this can be done using the GUI.

Crazy that I’m not able to find that piece of code, the first time I used it, it was the first piece of code I stumbled upon :slight_smile:

I found it, it’s not far away: https://www.home-assistant.io/integrations/manual/

It gives me the options I need.

R.