Home assistant (Rpi3) and room assistant on 2x PiZero - configuration issues using a cluster

Hi all,

Due to some disadvantages of my Fibaro HC2, I decided to start using HA. I’m no coding expert so quite a challenge;-). One of the many advantages of HA over HC2 is Room Assistant which offers accurate presence detection via BLE.

My setup:
I have two Rpi Zero’s with the idea to have them both running room assistant for good Bluetooth coverage/detection in our house.

I started with only one PiZero that communicates via MQTT with my Rpi3 running Home Assistant. For the setup of room assistant I followed this manual; Raspberry Pi Zero W | room-assistant

I could see Bluetooth presence switching for both the 2 devices/MAC address I put in the local.yaml file of room assistant.

It seems that I need a cluster to have 2x PiZero running room assistant, both communicating to my Rpi3 with HA. I used this manual to setup this cluster;

According to the MQTT log on my HA it seems that I have communication between room assistant and home assistant, however, no state changes for BT presence (screenshot).

This is my local.yaml file on my first room-assistant PiZero.

global:
cluster:
autoDiscovery: false
port: 6425
peerAddresses:
- ‘192.168.188.81:6425’
instanceName: kitchen
integrations:
- homeAssistant
- bluetoothClassic
homeAssistant:
mqttUrl: ‘mqtt://192.168.188.41:1883’
mqttOptions:
username: MyUserName
password: MyPWD
bluetoothClassic:
minRssi: -20
hciDeviceId: 0
addresses:
- ‘F0:A3:5A:1E:82:16’
- ‘94:65:2d:c4:20:91’

  • IP at MQTT URL is my RPI running HA.
  • MQTT user name and pwd are my regular HA credentials. In my standalone setup of room assistant I tried to use my MQTT user & pwd but that failed and for some reason my own user/pwd did work.
  • Do I need the MAC addresses to be in quotes ’ '? Only in one manual, I see quotes used.
  • The peer address is the IP of my 2nd PiZero (I did not set up the 2nd PiZero yet)
  • What is wrong with this config? Indentation maybe, I played with it but no success.
  • what should I put in the room assistant config file of the 2nd PiZero?
    I guess all the same except for;

    the peer address, this should be the first PiZero
    the instance name should be a different room
    I guess I don’t need separate MQTT users for PiZero 1 and PiZero2

  • I did not change my HA configuration after I setup a cluster in Room Assistant.
  • btw I now see presence like this(screenshot), I see people only use BT for presence detection, no idea how to set this up.

Thanks for your advice!

Regards
Jules

Where do you see that room assistant connected to the broker? I only see home assistant connecting to the broker.

It’s “safer” to put it in quotes, I do it always like this. However, I noticed an error in your first mac address, all letters need to be lowercase.

The cluster should be created automatically, if you don’t have a complex network you normally don’t need to specify the IPs and ports of the peers.

We can’t tell from the code you posted, because you didn’t format it correctly. See here (especially number 11) for more details on how to format the code properly.

You only need to change the instance name, the rest stays the same.

You need to bind the device tracker to the person. See here for more details.

I shared a detailed guide here on how I set it up in a cluster of 6 Pi Zero’s, which may help you.

1 Like

Thanks for the very clear information! I played around and ended up with below working config. I now can see BT presence flip between home @pi1, home @pi2 and not-home, nice!

global:
cluster:
autoDiscovery: true
port: 6425
#peerAddresses:
# - ‘192.168.188.81:6425’
instanceName: kitchen
integrations:
- homeAssistant
- bluetoothClassic
homeAssistant:
mqttUrl: ‘mqtt://homeassistant.local:1883’
mqttOptions:
username: XXXX
password: XXXX
bluetoothClassic:
# minRssi: -20
# hciDeviceId: 0
addresses:
# Iphone - Vannessa
- F0:A3:5A:1E:82:16
# ONEPLUS 5 - Jules
- 94:65:2d:c4:20:91

First what I tried was redo of spacing and disabling minRSSI. Now it works! Downside is that with minRSSI enabled device connections switch rapidly between the two PiZero´s running Room Assistant. As optimization I will enable minRSSI back again and play with the setting.

I will also try your tips on using lower case and quotes for MAC address, and I’ll remove IP’s under PeerAddresses.

Next to do is bind device tracker to persons.

1 Like

Hi @Burningstone thank you for this post. I just read your guide on room assistant and I am fairly new to it I have run into problems already.

I have 2 instances of room assistants running, one is in the office and the other in the master bedroom. In my config.yml for both I have put the ble address for my phone and I have also configured the cluster so that they talk to each other.

My problem is: when I am in the master bedroom the sensor for my ble device which is my phone never changes to master bedroom instead its stuck in the office state.

For some reason it’s been doing this and I have no idea on how to resolve it? Can you please help?I

Does the bedroom Pi recognize the phone when you turn off the office Pi?

Nope it doesn’t. Could it be that my configuration is incorrect?

Maybe, can you please show the config for both Pis?

so this is for the one in the master bedroom:

global:
  instanceName: Master Bedroom
  integrations:
    - bluetoothLowEnergy
    - homeAssistant
#    - bluetoothClassic
homeAssistant:
  mqttUrl: 'mqtt://XXXX:1883'
  mqttOptions:
    username: XXXX
    password: XXXX
bluetoothLowEnergy:
  timeout: 60
  maxDistance: 5
  whitelist:
    - b7331af9-d79d-493e-83a4-34f5697f1878
  tagOverrides:
    b7331af9-d79d-493e-83a4-34f5697f1878:
      name: ahmedtest
cluster:
  networkInterface: wlan0
  port: 6425
  peerAddresses:
    - 192.168.68.121:6425

and this is the one in the office:

global:
  cluster:
    networkInterface: wlan0
    port: 6425
    peerAddresses:
      - 192.168.68.142:6425
  instanceName: Office
  integrations:
    - bluetoothLowEnergy
    - homeAssistant
#    - bluetoothClassic
homeAssistant:
  mqttUrl: 'mqtt://XXXX:1883'
  mqttOptions:
    username: XXXX
    password: XXXX
bluetoothLowEnergy:
#  hciDeviceId: 0
  timeout: 60
  maxDistance: 7
  whitelist:
    - b7331af9-d79d-493e-83a4-34f5697f1879
  tagOverrides:
    b7331af9-d79d-493e-83a4-34f5697f1879:
      name: ahmedtest

Try removing the maxDistance and see if you get it to show up.

it doesnt like it.

I think my configuration is not right. Are you using the HA android app? BLE transmitter is now an option and that is what I am using.

I didn’t try the BLE transmitter from the app yet. I use NUT minis currently.

You said that it’s working for the office Pi, so I assume it has something to do with the config.

nope its not working for the office nor for the master bedroom. It used to work for the office with the configuration that I posted above but now it doesnt.

However I have downloaded the beacon scope app on my other android and I can see BLE transmitted through my android that I am currently using with room assistant.

Can you see the BLE transmitter from the phone with the bluetooth tools on the Pi?

yes I can see it

@Burningstone tell me.one thing how quick is your Bluetooth detection from room to room? Do you use it to turn your lights on and off once you move from one room to another?

It’s fairly quick, however I don’t use it for turning lights on, only off. I don’t want the lights turn on when I walk through the hallway and pass the door of the room.

1 Like

Ive recently starting setting Room Assistant up and playing around with it, but im having quite a few issues firstly understanding how it works and secondly getting my system to be reliable. Im trying to track my android phone using the companion app via BLE. Ive got some questions which i cant seem to find the answer to anywhere, so hoping someone here might be able to clarify them.

  1. What is the purpose of the “cluster leader”? My setup involves 3 raspberry pi’s in 3 different rooms. I understand they need to be in a cluster, but what does the actual cluster leader do, and why would each of my instances all show a different cluster leader in the MQTT screen?

  2. What is the maxDistance setting? My understanding is that this is a measurement in metres but im not sure what this distance is? Is it the measurement between your bluetooth device and the cluster leader? Why would it be so inaccurate? I have my device sitting literally on top of my raspberry pi and its saying 8m. Does this need to be calibrated?

Here is my config which to mean seems basic enough and is replicated on each of my raspberry pi’s. What fine tuning is there to do to make it accurate and reliable?

global:
  instanceName: Bedroom
  integrations:
    - homeAssistant
    - bluetoothLowEnergy
cluster:
  port: 6425
homeAssistant:
  mqttUrl: 'mqtt://192.168.1.100:1883'
  mqttOptions:
    username: ****
    password: ****
bluetoothLowEnergy:
  timeout: 60
  allowlist:
    - 55f0ca34c70949e7a3c41cddaf7c6189-100-1

Hi,

My config:
I have multiple (4) RPIs (zero-W) running room assistant in my house and 1x I have RA installed in HA.

In RA config I played around with my minrssi to tune when a connection to one room assistance should be dropped, such that it becomes available for the next /closer room assistant. The minrssi is not the distance but the signal strength (in db?).

During tuning you need to balance between;
too sensitive, when your device physically moves to another room it remains reported in the former room.
Too insensitive, room assistant will ignore your device as the BT signal is too low. So you will get black spots where room assistant will not connect and as result report your device not at home.

Personally I use RA for presence detection and I don’t really care in what room a device is.
For me it is most important to have a reliable home/away detection, so I tried to avoid black spots.

example room assistant config file: text after # is extra info, no part of my config file.

global:
  instanceName: living
  integrations:
    - homeAssistant
    - bluetoothClassic

homeAssistant:# setup of mqtt communication between room assistant (RA) and HomeAssistant(HA)
  mqttUrl: 'mqtt://homeassistant.local:1883'
  mqttOptions:
    username: mqttadmin # I created separate users in HA per RA device
    password: mqttpwd

cluster:
  autoDiscovery: false # just to make sure I'm in control
  port: 6425
  weight: 183 # no idea what the exact function is, I just gave each RA a unique weight.
  timeout: 60 # after how long (seconds) should room assistant report you mobile device not at home
  peerAddresses:
    - 192.168.188.80:6425 # fixed IP addresses of each RA device
    - 192.168.188.81:6425
    - 192.168.188.82:6425
    - 192.168.188.83:6425

bluetoothClassic:
  minRssi: -60  # this is the min signal strength /threshold when room assistant will detect you 
  addresses:
    #- 94:65:xxxxxxxx    # Bluetooth mac addresses of the mobile devices to track
    - f0:a3:5
    - FC:AA:8
    - ac:d6:18:

What the exact role of the cluster leader is, is not clear to me. I guess when a BT device is in reach of multiple RA RPIs, the software will establish connection with that instance of RA that has the best match based on settings for that cluster (min-max rssi, priority etc)

HomeAssistant:
In Home Assistant I can see in the log file of the MQTT add/-n if the communication between RA and HA is successful.
image

I now get a HA per mobile device. If all works fine, each sensor will report in what room the device is in or it will report not-home when away.

I noticed that the RPIs running room-assistant (rpi zero-w ) hang now and then making the full cluster to become unreliable.

In each rpi zero-w, I setup a cron task/job in linux to schedule a daily reboot each at a different moment during the day. Now it works like a charm.

I don’t know if there is a practical difference between Bluetooth classic (what I use) vs BT low energy (what you used).

I use a ping integration in HA to monitor if my RA devices are have simple network communication.

good luck!