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:…
Commit
19e4a02
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 to an ESP32 running ESPHome. It's cheap and unlike a PIR it sees me when I'm not moving. Here is a minimal config:
The radar exposes a lot more (distances, energy per gate...). I keep all of it
It's a plain OR, any sensor seeing me is enough.
yaml
uart: tx_pin: GPIO18 rx_pin: GPIO33 baud_rate: 256000 ld2410: binary_sensor: - platform: ld2410 has_target: name: Presence
internal: true. Handy for tuning, noisy in HA.
One sensor was not enough though, so I merge two of them in a template binary_sensor:
yaml
- binary_sensor: - name: "Office presence" device_class: occupancy state: > {{ is_state('binary_sensor.office_radar_1', 'on') or is_state('binary_sensor.office_radar_2', 'on') }} delay_on: { seconds: 2 } delay_off: { seconds: 15 }
delay_on drops pulses too short to be real (costs me 2s when I walk in, that's fine). delay_off gives some margin before calling the room empty for when I walk out and back in quickly (you know, when I play with the cats)
Now the bug that taught me something. At first I also had the radars' still_target in that OR. Looked like a good idea, more inputs = more reliable, right?
Except on the LD2410, has_target is already "moving OR still". So still_target added nothing: out of all the times it went on, presence was already on 99% of the time. What it did add was chatter. On some evenings 98% of its "on" pulses lasted less than 5 seconds. Each one re-armed the delay_off, so the combined sensor never went back to off, and my "leaving the office" automation just stopped firing. Lights on all evening in an empty room.
Removed still_target, problem gone.
So before ORing every sensor you own together, check what each one really brings. Sometimes it's only noise.commit 19e4a02
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,…