Mastering Hyper-Accurate Room Presence with Room Assistant and Home Assistant

Represent Mastering Hyper-Accurate Room Presence with Room Assistant and Home Assistant article
2m read

For truly intelligent smart home automations, accurate presence detection – knowing who is in which room – is key. Traditional methods often lack the granularity. Room Assistant, integrated with Home Assistant, provides this granular awareness via a distributed network of Bluetooth Low Energy (BLE) receivers.

How Room Assistant Enhances Presence

Room Assistant uses multiple BLE-enabled devices (receivers like Raspberry Pis or ESP32s) placed around your home. These scan for BLE beacons (dedicated trackers or smartphones broadcasting) and measure signal strength (RSSI). This data goes to an MQTT broker. Home Assistant subscribes, interpreting combined RSSI data to determine a beacon's (and thus, a person's) precise room location, enabling context-aware automations.

Setting Up Your Room Presence System

1. Prerequisites

  • Home Assistant instance & MQTT Broker.
  • Multiple Raspberry Pi Zero Ws (or ESP32s), one per monitored zone.
  • BLE devices to track (smartphones, iBeacons).

2. Install Room Assistant on Receivers (Raspberry Pi)

For each Raspberry Pi receiver:

  1. Install OS & Node.js: Flash Raspberry Pi OS Lite. SSH in:
    curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
    sudo apt-get install -y nodejs
  2. Install Room Assistant:
    sudo npm install -g room-assistant@latest
  3. Create config.yml: /etc/room-assistant/config.yml (adjust MQTT/device ID):
    # /etc/room-assistant/config.yml
    global:
    instanceName: livingroom_pi
    mqtt:
    url: 'mqtt://YOUR_MQTT_BROKER_IP'
    username: YOUR_MQTT_USERNAME
    password: YOUR_MQTT_PASSWORD
    sensor:
    ble:
    minRssi: -90
    interval: 10
    active: true
    presence:
    timeout: 30
    - id: 'AA:BB:CC:DD:EE:FF'
    name: 'my_phone'
  4. Create & Start Systemd Service: /etc/systemd/system/room-assistant.service:
    [Unit]
    Description=Room Assistant
    After=network.target
    [Service]
    Type=simple
    User=pi
    WorkingDirectory=/etc/room-assistant
    ExecStart=/usr/bin/npm start --prefix /usr/local/lib/node_modules/room-assistant/
    Restart=always
    [Install]
    WantedBy=multi-user.target

    Then:

    sudo systemctl daemon-reload
    sudo systemctl enable room-assistant
    sudo systemctl start room-assistant

    Repeat for each receiver.

3. Configure Home Assistant

Add to your configuration.yaml:

# configuration.yaml
mqtt:
binary_sensor:
- name: "My Phone Living Room"
state_topic: "room_assistant/livingroom_pi/my_phone/present"
payload_on: "true"
payload_off: "false"
device_class: presence
- name: "My Phone Kitchen"
state_topic: "room_assistant/kitchen_pi/my_phone/present"
payload_on: "true"
payload_off: "false"
device_class: presence

device_tracker:
- platform: template
sensors:
my_phone_location:
friendly_name: "My Phone Location"
value_template: >-
{% if is_state('binary_sensor.my_phone_living_room', 'on') %}
living_room
{% elif is_state('binary_sensor.my_phone_kitchen', 'on') %}
kitchen
{% else %}
not_home
{% endif %}

Optimization & Best Practices

  • Beacon Stability: Use dedicated iBeacons or reliable smartphone apps.
  • Receiver Placement: Central in rooms, away from metal; overlap zones.
  • Tune RSSI/Timeout: Adjust minRssi and timeout in config.yml (e.g., -90, 30s).
  • Mitigate Jitter: Use HA's for: conditions (e.g., for: "00:00:15"). For critical use, combine with a Bayesian Binary Sensor.
  • Robust Infrastructure: Stable MQTT, wired Ethernet for receivers, UPS.
  • Regular Updates: Keep Room Assistant and Home Assistant current.
  • Monitor Health: Track MQTT 'last seen' timestamps for receivers.
  • Privacy-Centric: All data is processed locally.
  • Layered Presence: Combine Room Assistant with other methods (network, GPS) for reliability.

Example Automation: Smart Lighting

# automation.yaml
- alias: "Turn on Living Room Lights when I enter"
trigger:
- platform: state
entity_id: device_tracker.my_phone_location
to: "living_room"
for: "00:00:10"
action:
- service: light.turn_on
entity_id: light.living_room_main_light

- alias: "Turn off Living Room Lights when I leave"
trigger:
- platform: state
entity_id: device_tracker.my_phone_location
from: "living_room"
for: "00:00:30"
action:
- service: light.turn_off
entity_id: light.living_room_main_light

Conclusion

Room Assistant empowers Home Assistant with unparalleled room-level awareness, enabling intuitive, anticipatory automations. While initial setup requires some effort, the enhanced user experience and intelligence are truly rewarding.

Avatar picture of NGC 224
Written by:

NGC 224

Author bio: DIY Smart Home Creator

There are no comments yet
loading...