3.1 KiB
Room Presence Setup with Pi Zeros
Prerequisites
- Raspberry Pi Zero W (or Pi Zero 2 W)
- MicroSD card (8GB+)
- Power supply for Pi
- MQTT broker running on Home Assistant
Step 1: Flash Raspberry Pi OS
-
Download Raspberry Pi Imager from https://www.raspberrypi.com/software/
-
Flash Raspberry Pi OS Lite (no desktop, smaller footprint)
-
Enable SSH and WiFi in the imager settings:
- Set hostname:
livingroom-pi(one per room) - Enable SSH with password auth
- Set WiFi credentials
- Set hostname:
-
Insert SD card and boot the Pi
Step 2: Copy Files to Pi
# From your computer, copy the files to the Pi
scp room-assistant-config.yml setup-room-assistant.sh pi@<pi-ip>:~/
# SSH into the Pi
ssh pi@<pi-ip>
# Default password: raspberry
Step 3: Run Setup
# Make the script executable
chmod +x setup-room-assistant.sh
# Run as sudo
sudo ./setup-room-assistant.sh
The script will prompt for:
- Room name (e.g., LivingRoom, Kitchen)
- MQTT username and password
- Phone MAC addresses
Step 4: Find Phone MAC Address
On iPhone: Settings → About → Bluetooth → Copy address (xx:xx:xx:xx:xx:xx)
On Android: Settings → About Phone → Status → Bluetooth address
Step 5: Verify in Home Assistant
Once running, room-assistant will create MQTT discoveries. In HA:
-
Settings → Devices & Services → MQTT
-
Look for new
device_trackerentities:device_tracker.corey_phone_livingroomdevice_tracker.kathy_phone_livingroom
-
These appear in HA's device tracker UI
Step 6: Create Room Zones (Optional)
# In HA, create zones for each room
# Configuration.yaml or in the UI:
homeassistant:
zone:
- name: Living Room
latitude: !secret home_lat
longitude: !secret home_lon
radius: 5 # meters
Files Created
| File | Purpose |
|---|---|
room-assistant-config.yml |
Template config (edit per room) |
setup-room-assistant.sh |
Automated install script |
config/local.yml |
Generated config (lives on Pi) |
Managing Multiple Pis
Create a config file per room:
| Room | Hostname | Instance Name |
|---|---|---|
| Living Room | livingroom-pi | LivingRoom |
| Kitchen | kitchen-pi | Kitchen |
| Bedroom | bedroom-pi | Bedroom |
Troubleshooting
WiFi not connecting?
- Check
/etc/wpa_supplicant/wpa_supplicant.conffor WiFi config - Pi Zero W supports 2.4GHz only
Bluetooth not scanning?
# Check Bluetooth status
hciconfig
# Restart Bluetooth
sudo systemctl restart hciuart
MQTT not connecting?
- Verify MQTT credentials in
/home/pi/.room-assistant/config/local.yml - Check HA MQTT add-on is running
View logs:
journalctl -u room-assistant -f
Customize RSSI Threshold
Lower value = detects devices farther away Higher value = must be closer to be detected
bluetoothClassic:
rssiThreshold: -70 # Default, adjust as needed
Adding New Devices
Edit /home/pi/.room-assistant/config/local.yml and add:
knownDevices:
- name: 'New Device'
address: 'AA:BB:CC:DD:EE:FF'
Then:
sudo systemctl restart room-assistant