Commit

88c0633

I've been automating my home office with Home Assistant for a while now, and I'm going to share how it works in a short series of posts. From the very basic stuff to the part where an LLM runs parts of my house and I can talk with it from my phone. Quick look at the setup first:…
Starting with the boring but essential part: knowing if I'm actually in the room. Everything else depends on it in my office: if presence is wrong, the lights go off while I'm sitting there, or the room stays lit for the cats 🐈. The main sensor is an LD2410 mmWave radar wired…
Last commit was about presence detection, now the first thing it drives: the lights. Two automations for that: presence goes on, lights on. Presence off for 5 seconds, lights off. Here's the "on" one, simplified:…
A short one this time: physical buttons for the music. There's a smart speaker in my office. Reaching for the phone just to lower the volume gets is a no no, so I have cheap Zigbee devices on the desks: a small dimmer-style remote and a rotary knob. Both go through Zigbee2MQTT…
Sorry, this one took a bit longer than planned 😅 I mentioned house modes a couple of times already, so let's fix that debt. It's not really about the office, but almost every office automation depends on it. I have one input_select with four options: active, away, night, vacation. Lots of automations check it in their conditions instead of each reinventing "is anyone home / is it night". Office lights only turn on in active, for example. Switching between modes is handled by a few small automations: - away: nobody has been home for 3 minutes (and we're not in vacation). The cats 🐈 and the dog 🐕 don't have a phone, so they don't count - back to active: someone gets home while the mode is away - night: every day at 22:00 - active: 6:00 on weekdays, 7:00 on weekends - vacation: no automation, I set it by hand before leaving. And the night/active schedule ignores it so it doesn't get overwritten The "everyone left" one:
yaml
triggers:
  - trigger: state
    entity_id: person.me
    for: { minutes: 3 }
  - trigger: state
    entity_id: person.partner
    for: { minutes: 3 }
conditions:
  - condition: not
    conditions:
      - condition: state
        entity_id: person.me
        state: home
  - condition: not
    conditions:
      - condition: state
        entity_id: person.partner
        state: home
  - condition: not
    conditions:
      - condition: state
        entity_id: input_select.house_mode
        state: vacation
actions:
  - action: input_select.select_option
    target: { entity_id: input_select.house_mode }
    data: { option: away }
Nothing clever, but having one single place that says "what state is the house in" made everything else simpler. If you're not used to HA, this one can look weird at first read. The triggers watch me and my partner, then the conditions check me and my partner again. Why say it twice? Because they don't answer the same question. Triggers answer "when should I look?". They're OR'ed: any one of them firing starts the automation. Here, it's "one of us changed state and stayed like that for 3 minutes". The for is there so a quick GPS hiccup doesn't send the whole house to away. Conditions answer "should I act right now?". They're AND'ed: all of them must pass. When my state changes, that tells nothing about my partner. So the conditions check the whole picture: me not home, partner not home, not on vacation. Two details that make it work: - no to: not_home on the triggers. When I leave I might end up in not_home, but also in work or any other zone I defined. Same for the conditions: I check "not home" rather than "is not_home" - a state trigger with no to/from also fires when only attributes change, like GPS coordinates. It fires way more often than you'd think, and that's fine: the conditions do the real check The rule of thumb I use: triggers are events, conditions are state. Put the "when" in triggers, the "is it true right now" in conditions, and don't expect one to do the other's job.

commit 88c0633