Hass.io Add-on: room-assistant

For the most part room-assistant will only send messages to MQTT when something changes, it also sends the current state of all entities to MQTT whenever the leader changes though (to make sure the state is up-to-date). I believe that this is what you might be seeing here. I thought that Home Assistant also filters these state updates, but I guess I misunderstood that part. For Node-RED I usually check the “output only on state change” box of the events: state node, which may be why I never noticed this before.

Maybe check your leader sensors In Home Assistant to see if there are a lot of changes happening. If that’s the case you could play around with some of the cluster options to stabilize that a bit more.

Hi!

This looks really promising! I set it up for my Raspberry Pi 4, already running Home Assistant. Tracking my Mi Band 4, it looks like this. Has anyone made any progress on having it not switching this often between home/away?

These are my setup configurations:

global:
  instanceName: apartment
  integrations:
    - bluetoothLowEnergy
    - homeAssistant
bluetoothLowEnergy:
  whitelist:
    - [MAC ADDRESS]
device_tracker:
- platform: mqtt
  devices:
    molles_mi_band: 'room-assistant/device_tracker/ble-[MAC ADDRESS]-tracker/state'
  payload_home: 'true'
  payload_not_home: 'false'
  source_type: bluetooth_le

Two suggestions that might help you filter out the false negatives:

  • increase the timeout in your room-assistant bluetoothLowEnergy settings
  • if that doesn’t help enough you can also take a look at entity behaviors, which allow you to debounce entities or pull states from a rolling window average

Nice work, @mKeRix!! I got this successfully working in two raspberries Pi 3b, an OrangePi Zero with armbian, and a Bluetooth USB adapter, impressive work.
I’m unable, though, to get the raspberry pi 3b on which Homeassistant is running to produce any readings whatsoever. I suspect that this may be due to the fact that the hci adapter is somehow clogged up, but I don’t want to reset the board, as there is no access to hciconfig via HomeassistantOS.

What does troubles me is that all the five devices at home, I can only connect to two of them: A ZTE mobile phone and my Huawei P20 Pro. For the Fitbit Versa, TicWatch Pro and Motorola Fusion One there is no way I can get any readings at all, once the connection request. Any ideas would be very welcome, and thanks again!

For the Home Assistant OS problem there is a thread here that may contain some helpful information: https://github.com/mKeRix/room-assistant/issues/314. In the SSH add-on you have access to bluetoothctl, which you can use to show the adapter state and reset it if needed.

As for tracking your other devices: every device behaves differently, so it’s a bit hard to give general advice. Some things you can try to get BT Classic working:

  • try to pair your device to some BT peripheral like headphones once if possible and not already done before (for e.g. the Apple Watch this makes it allow incoming connections)
  • verify that you are using the Bluetooth MAC and not the WiFi MAC - these are different, but sometimes very close together
  • check if you can detect the device while the Bluetooth menu is open in the settings of the device
  • some smart watches are only detectable when not currently connected to a phone

For the Motorola Fusion One you could also try the bluetoothLowEnergy integration as an alternative. For Android phones there are apps available that broadcast iBeacon data in the background, which can be detected by that. These apps unfortunately do not work on WearOS yet. You can run both Bluetooth integrations in parallel with the latest room-assistant versions.

Thanks for the reply. The ssh command worked. Unfortunately, when enabling the BLE plugin it seems that it ceased to detect the classic Bluetooth phones that it used to detect before, and the situation hasn’t changed for the devices I was trying to detect in the first place, both the Motorola and the smartwatches. It seems that this won’t be the solution for my use case.
Thanks a lot again!

Using this together with Bluetooth Classicon the same adapter works, but will slightly degrade the performance. If you encounter issues you can try to run to run the integrations from different HCI devices.

So it’s best to stick with either Classic or BLE or use an extra RPIW.

Is it possible to run Room Assistant over TLS? Specifically I want to run it on port 8883. I keep on getting “error - HomeAssistantService: read ECONNRESET” when I start room assistant.

I assume you mean MQTT over TLS? If you use a self-signed certificate you can set rejectUnauthorized to false to disable certificate checking. Alternatively you could try to install your certificate into the stores of the Pis that you run room-assistant on in a way that NodeJS can read it.

Hi,

I’m just trying this addon for the first time but I’m having some issues getting up and running…

I’m running the hassio addon under a supervised installed with the mqtt addon, and the room-assistant addon config is as follows:

global:
  instanceName: homeassistant
  integrations:
    - homeAssistant

I then currently have one node setup although I’m going to have many so I am trying to get it working with the clustered approach. This is my config:

global:
  cluster:
    networkInterface: eth0
    port: 6425
    autoDiscovery: true
  instanceName: kitchen
  integrations:
    - homeAssistant
    - bluetoothClassic
homeAssistant:
  mqttUrl: 'mqtt://homeassistant-ip:1883'
  mqttOptions:
    username: username
    password: password
bluetoothClassic:
  addresses:
    - 'my mac addresses'

In home assistant I get the following logs:

12/23/2020, 10:47:59 PM - info - ClusterService: Added 192.168.1.52:6425 to the cluster with id kitchen
12/23/2020, 10:50:42 PM - info - ClusterService: kitchen has been elected as leader
12/23/2020, 10:51:47 PM - info - ClusterService: Removed 192.168.1.52:6425 from the cluster with id kitchen
12/23/2020, 10:51:47 PM - info - ClusterService: homeassistant has been elected as leader
12/23/2020, 10:51:47 PM - info - EntitiesService: Refreshing entity states
12/23/2020, 11:00:04 PM - info - ClusterService: Added 192.168.1.52:6425 to the cluster with id kitchen

However on the kitchen entity in the logs I see it join the cluster but then I get

error - ClusterService: dns service error: unknown

I’ve checked I can ping my pi from my home assistant server by it’s name, but I have no idea why it complains of a dns error?

Hi mReRix,

First, thank you for all the amazing work on room-assistant. I love it, and your documentation makes it so easy to follow. Just fantastic!

If you are open to it, I was wondering if I could run an idea by you and get your thoughts. I find with my setup, I’m getting a ton of switching back and forth between sensors . I live in an apartment and I have 3 raspberry pis (2 Zero W that I only run Room Assistant on and 1 Raspberry Pi 4 that is also runs my Home Assistant). My devices are an apple watch 3 and an iphone 11, and I’m using Bluetooth Classic.

I was wondering, if instead of trying to modify the minRssi and bounce settings manually, if there was a way to use machine learning for Room Assistant to automatically guess a location. I wrote a small python program (and I’m not really a programmer at all so I’m sure it is horrible) on the Pis to grab readings and send then to a server via MQTT to save them in a database (inspired by you obviously!). I walked around my apartment and, using Home Assistant UI and a MQTT message to the server to identify which room I am in, took readings. As you can see in the graphs below it does look like there is a reasonable pattern (note: -31 is actually a FAILED reading). I thought providing the last three readings per sensor for a device to a machine learning program would create an accurate location estimate with less setup (other than the training) and would enable you to create “virtual rooms” as opposed to just allocation to a sensor. Initial readings seem to be pretty positive (in the low 90s), but still a guess.

Graph 1
graph 2
graph 3

I was also imaging you could use multiple type of sensors and integrate it into the ML. For example, for phones include wifi RSSI by using a router as a sensor.

The issue I’m having and was wondering if you ran into is that I can’t get reliable semi-real time readings from the Pi Zeros. I have no issue the Raspberry Pi 4. I’m guessing this is due to the fact that on the Zeros they have a shared chipset for wireless and bluetooth (as I found out from your docs). I’ve also set the MQTT publish QOS to 1. The graph below shows over time (x-axis), the time between when a reading was captured on a sensor to the time it was saved to the database on the server (y-axis). Since the database is and server are on the same machine, I’m guessing the lag is due to time when the HCI command is completed and then the MQTT server sends the message to the subscriber.

time

Would love your thoughts on:

  1. Do you think there is value in this idea of training to create “virtual rooms” rather than using a sensor as a location? You’ve thought about this a lot longer than I
  2. I believe there is a lot of noise in the RSSI signals. Do you think ML would be helpful and accurate enough?
  3. Have you seen this lag issue in the Pi Zeros before (my biggest issue with my proof of concept) and what have you done to resolve this?

I’m happy to share any of my code or learnings if they are of any interest to you. I do have to warn you, I’m not a programmer so I think you’d be disgusted with my code.

Happy New Year!

PS - Some people have done similar work - https://www.preprints.org/manuscript/202009.0508/v1,

1 Like

I’ve clean installed room-assistant at least 4 times on a RPi 3b+. From what I can tell, everything is working properly and communicating but I don’t see any instances in HA except for the RPi itself.

global:
  cluster:
    autoDiscovery: true
    port: 6425
    peerAddresses:
      - 10.10.*.*6425
  instanceName: masterbedroom
  integrations:
    - homeAssistant
    - bluetoothClassic
homeAssistant:
  mqttUrl: 'mqtt://10.1.*.*:1883'
  mqttOptions:
    username: omitted 
    password: omitted
bluetoothClassic:
  minRssi: -20
  hciDeviceId: 0 
  addresses:
    - ‘my phone mac’
    - ’my watch mac’
    - ‘wife's phone mac’
    - ‘wife's watch mac’
    - ’son's tablet'

I have doubled checked multiple times the MAC addresses are the Bluetooth MAC addresses.

When I run the service, I see this:

*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
1/10/2021, 20:36:27 - info - IntegrationsModule: Loading integrations: home-assistant, bluetooth-classic
1/10/2021, 20:36:29 - info - NestFactory: Starting Nest application...
1/10/2021, 20:36:30 - info - InstanceLoader: AppModule dependencies initialized
1/10/2021, 20:36:30 - info - InstanceLoader: ConfigModule dependencies initialized
1/10/2021, 20:36:30 - info - InstanceLoader: NestEmitterModule dependencies initialized
1/10/2021, 20:36:30 - info - InstanceLoader: IntegrationsModule dependencies initialized
1/10/2021, 20:36:30 - info - InstanceLoader: HttpModule dependencies initialized
1/10/2021, 20:36:30 - info - InstanceLoader: DiscoveryModule dependencies initialized
1/10/2021, 20:36:30 - info - InstanceLoader: ClusterModule dependencies initialized
1/10/2021, 20:36:30 - info - InstanceLoader: TerminusModule dependencies initialized
1/10/2021, 20:36:30 - info - InstanceLoader: BluetoothModule dependencies initialized
1/10/2021, 20:36:30 - info - InstanceLoader: ScheduleModule dependencies initialized
1/10/2021, 20:36:30 - info - InstanceLoader: EntitiesModule dependencies initialized
1/10/2021, 20:36:30 - info - InstanceLoader: HomeAssistantModule dependencies initialized
1/10/2021, 20:36:30 - info - InstanceLoader: BluetoothClassicModule dependencies initialized
1/10/2021, 20:36:30 - info - InstanceLoader: StatusModule dependencies initialized
1/10/2021, 20:36:31 - info - RoutesResolver: EntitiesController {/entities}:
1/10/2021, 20:36:31 - info - RouterExplorer: Mapped {/entities, GET} route
1/10/2021, 20:36:31 - info - RoutesResolver: StatusController {/status}:
1/10/2021, 20:36:31 - info - RouterExplorer: Mapped {/status, GET} route
1/10/2021, 20:36:32 - info - HomeAssistantService: Successfully connected to MQTT broker at mqtt://10.1.1.10:1883
1/10/2021, 20:36:32 - info - ConfigService: Loading configuration from /usr/lib/node_modules/room-assistant/dist/config/definitions/default.js, config/local.yml
1/10/2021, 20:36:32 - info - ClusterService: Starting mDNS advertisements and discovery
1/10/2021, 20:36:32 - info - NestApplication: Nest application successfully started
1/10/2021, 20:36:32 - info - ClusterService: master-bedroom has been elected as leader
1/10/2021, 20:36:32 - info - EntitiesService: Refreshing entity states

The only thing in HA is:
switch.master_bedroom_bluetooth_inquiries
sensor.master_bedroom_cluster_leader
sensor.master_bedroom_cluster_size

So I posted my issue as a stand alone topic but I guess it may be better to ask it as part of this one. Hopefully mReRix will take a look and tell me what I’m doing wrong!

So I have my HA instance running on a Pi-4 under Home Assistant OS (I’m kind of confused by all the name changes that have gone on around the different versions but basically I have Core 2021.1.5 and Supervisor 5.10).

I have a MQTT broker running on a separate Pi-zero W (this is used by Sonoff switches on which I have Tasmota installed so I know it is working correctly).

I installed the room-assistant add-on on my HA instance so that I could track the presence of my Iphone and Apple Watch. Had a few issues with the configuration but I now have one that seems to work and the room-assistant add-on starts. My configuration is as shown below:

Copy to clipboard

> global:
>   instanceName: familyRoom
>   integrations:
>     - homeAssistant
>     - bluetoothClassic
> homeAssistant:
>   mqttUrl: 'mqtt://192.168.xx.xxx:1883'
> bluetoothclassic:
>   minRssi: -20
>   hciDeviceId: 0
>   addresses:
>     - 'xx:8c:43:47:xx:xx'
>     - 'xx:e4:ab:b1:xx:xx'

The mqtt URL is the internal network address for the Pi that is running the mqtt broker while the ‘addresses’ are the bluetooth IP’s given for my phone and watch.

When room-assistant starts I see three new items appear in Home Assistant:

  • switch.familyroom_bluetooth_inquiries
  • sensor.familyroom_cluster_leader
  • sensor.familyroom_cluster_size

It isn’t clear to me from the documentation what these are or how I’m meant to use them. I was expecting to see a sensor appear for both my phone and watch but they don’t appear to be there. The room-assistant log shows the following:

[s6-init] making user provided files available at /var/run/s6/etc…exited 0.
[s6-init] ensuring user provided files have correct perms…exited 0.
[fix-attrs.d] applying ownership & permissions fixes…
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts…
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[12:06:36] ERROR: Got unexpected response from the API: Service not enabled
[12:06:36] INFO: Starting room-assistant
*** WARNING *** The program ‘node’ uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see Avahi Gains Compatibility Layers for Apple Bonjour and HOWL
*** WARNING *** The program ‘node’ called ‘DNSServiceRegister()’ which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see Avahi Gains Compatibility Layers for Apple Bonjour and HOWL
2/10/2021, 12:06:40 PM - info - IntegrationsModule: Loading integrations: none
2/10/2021, 12:06:41 PM - info - NestFactory: Starting Nest application…
2/10/2021, 12:06:41 PM - info - InstanceLoader: AppModule dependencies initialized
2/10/2021, 12:06:41 PM - info - InstanceLoader: ConfigModule dependencies initialized
2/10/2021, 12:06:41 PM - info - InstanceLoader: NestEmitterModule dependencies initialized
2/10/2021, 12:06:41 PM - info - InstanceLoader: IntegrationsModule dependencies initialized
2/10/2021, 12:06:41 PM - info - InstanceLoader: HttpModule dependencies initialized
2/10/2021, 12:06:41 PM - info - InstanceLoader: DiscoveryModule dependencies initialized
2/10/2021, 12:06:41 PM - info - InstanceLoader: PrometheusModule dependencies initialized
2/10/2021, 12:06:41 PM - info - InstanceLoader: ClusterModule dependencies initialized
2/10/2021, 12:06:41 PM - info - InstanceLoader: TerminusModule dependencies initialized
2/10/2021, 12:06:41 PM - info - InstanceLoader: ScheduleModule dependencies initialized
2/10/2021, 12:06:41 PM - info - InstanceLoader: EntitiesModule dependencies initialized
2/10/2021, 12:06:41 PM - info - InstanceLoader: StatusModule dependencies initialized
2/10/2021, 12:06:41 PM - info - RoutesResolver: EntitiesController {/entities}:
2/10/2021, 12:06:41 PM - info - RouterExplorer: Mapped {/entities, GET} route
2/10/2021, 12:06:41 PM - info - RoutesResolver: StatusController {/status}:
2/10/2021, 12:06:41 PM - info - RouterExplorer: Mapped {/status, GET} route
2/10/2021, 12:06:41 PM - info - RoutesResolver: PrometheusController {/metrics}:
2/10/2021, 12:06:41 PM - info - RouterExplorer: Mapped {/metrics, GET} route
2/10/2021, 12:06:41 PM - info - ConfigService: Loading configuration from /usr/lib/node_modules/room-assistant/dist/config/definitions/default.js, config/local.json
2/10/2021, 12:06:41 PM - error - ClusterService: Failed to start mdns discovery (dns service error: unknown)
2/10/2021, 12:06:41 PM - info - NestApplication: Nest application successfully started
2/10/2021, 12:06:43 PM - info - ClusterService: 6e66619d-room-assistant has been elected as leader
2/10/2021, 12:06:43 PM - info - EntitiesService: Refreshing entity states

As you can see there are a few ‘error’ entries in the file but it’s not clear whether these are fatal or not. For example, does the error:

ClusterService: Failed to start mdns discovery (dns service error: unknown)

indicate that there is some failure or shortcoming on the Pi-4 that is preventing Room-Assistant from broadcasting the messages that it uses to detect the devices? I’ve seen other log files which contain a message to the the effect that “mDNS services are starting”).

Can anyone shed light on what I need to do to my system in order to get room-assistant working properly.

2 Likes

Okay, after a day or so of reading, I got it mostly figured out. I can see it discovering BLE devices in the add-on logs. However, I’ve enabled BLE in the native HA app on my android phone, and my phone won’t show up in the logs, even with power set to HIGH and the device right next to the Bluetooth dongle.

What am I doing wrong?

If it matters, here are super simple settings:

global:
  instanceName: laundryroom
  integrations:
    - homeAssistant
    - bluetoothLowEnergy
bluetoothLowEnergy:
  timeout: 60

Does yours stop working at random times or is it pretty stable (no not-homes when I’m a foot away)

So I went ahead and purchased a Grid-eye from sparkfun and connected it to the Raspberry Pi 3.

I’ve followed the instructions on installing the system, but I’m uncertain where to go from here. Is there a way to test it?

Anyone have problems running room-assistant w/ the native HASS Bluetooth integration? They seem to conflict with each other. For example, if both are running then

  • Bluetooth integration is happy
  • room-assistant device trackers drops out intermittently

If I disable bluetooth integration, then room-assistant is stable and flawless

I am running Debian on a NUC with Supervised install

nevermind, looks like dual usage of one bluetooth adapter is not supported.

Looks like the short term solution is to get two adapters if I want to use two bluetooth integrations