Hass.io Add-on: room-assistant

Tags: #<Tag:0x00007f7802f8c9c0>

Hey all,

version 1.0 of room-assistant is finally out! :tada: And with it comes support for Hassio. I hope you’ll find it useful - if you run into issues either let me know here or create a new ticket on GitHub.

Find all the details on the GitHub page: https://github.com/mKeRix/room-assistant

What is room-assistant?

room-assistant is a simple Node.js server for tracking presence and other things on a per-room basis. You can use it to track Bluetooth beacons moving around your house together with the mqtt_room component, or to get GPIO or shell command output from other hosts into Home Assistant.

It is the ideal little helper for bringing your automations down to a room by room level!

Running room-assistant

You can run room-assistant on every machine that supports NodeJS or Docker - this includes all Raspberry Pis. We provide detailed instruction for running it directly with NodeJS, Docker and Hassio on GitHub.

6 Likes

Can i put this on a raspberry pi w? How does it detect and how fast does it respond?

Yes, you can! In theory anything that can run Node.js can also run room-assistant. Only thing you need to watch out for is making sure to install a current version of Node on the Pi W, there are a few guides online on how to get this done.

Detection can be done in multiple ways… e.g. I use PIR motion sensors via GPIO and bluetooth beacons at my home currently, but am in the process of trying D6T thermal sensors as replacement for carrying beacons. Really depends on what exactly what you want to achieve. Reaction speed depends on what you configure, for Bluetooth you can calculate with about a second for most setups (but can be quicker), PIR and D6T should be under a second.

warning wanring…incoming NOOB alert. :smiley:
okay so I have hassio addon installed. up and running.
I have a sensor setup in my config

  • platform: mqtt_room
    device_id: Living_room
    away_timeout: 30
    name: “Living_Room_Presence”

now the next question… how do I figure out what devices are in the living room. for example I always have my iphone on me or my garmin watch. do I need to do something to them to get them to send data to the room?. will they show up as a sensor in the system?

my addon config is as follows

{
“services”: [
“mqtt”,
“ble”
],
“room”: “living-room”,
“mqtt”: {
“url”: “mqtt://10.0.1.44”,
“username”: “Admin”,
“password”: “XXXXX!”,
“rejectUnauthorized”: true
},
“ble”: {
“channel”: “room_presence”,
“useAddress”: false,
“whitelist”: [],
“maxDistance”: 10,
“updateFrequency”: 0,
“processIBeacon”: true,
“onlyIBeacon”: false,
“majorMask”: “0xFFFF”,
“minorMask”: “0xFFFF”
},
“gpio”: [],
“shell”: [],
“autoDiscovery”: true
}

Hey,

If this could work on an ESP32 it would be ace, plus the esp32 has BT and wifi plus a whole ton of gpio.

Just an idea.

1 Like

agreed. then i could buy a heap of them :slight_smile:

1 Like

I am having a heck of a time getting Room Assistant to send to my hassio MQTT server. My MQTT server is at 192.168.1.100 and has SSL turned on. Many things already connect and send things to it successfully. I’ve installed Room Assistant on a Raspberry Pi Zero W and set it all up, but it’s not sending anything to the MQTT server. Here is my config at ~/room-assistant/config/local.json (I’ve also tried mqtt: instead of mqtts: with the same results. Nothing ever appears to be sent. I thought adding the “console” service would display debugging information to the SSH console, but nothing is seen at all. What am I missing? A status gives this:

[email protected]:~/room-assistant $ systemctl status room-assistant.service
room-assistant.service - Room Assistant service
Loaded: loaded (/etc/systemd/system/room-assistant.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) since Tue 2019-01-22 23:44:49 GMT; 4s ago
Process: 1993 ExecStart=/usr/bin/npm start (code=exited, status=0/SUCCESS)
Main PID: 1993 (code=exited, status=0/SUCCESS)

Here is the config/local.json:

{
  "services": ["console", "mqtt", "ble"],
  "room": "living-room",
  "autoDiscovery": true,
  "mqtt": {
    "url": "mqtts://192.168.1.100",
    "username": {redacted username},
    "password":{redacted password},
    "rejectUnauthorized": false
  },
  "ble": {
    "channel": "room_presence",
    "useAddress": true,
    "whitelist": [],
    "whitelistRegex": false,
    "txPowerOverride": {},
    "maxDistance": 0,
    "updateFrequency": 0,
    "processIBeacon": true,
    "onlyIBeacon": false,
    "majorMask": "0xFFFF",
    "minorMask": "0xFFFF"
  },
  "d6t": [],
  "gpio": [],
  "shell": [],
  "prometheus": []
}

Okay, several questions:

  1. can you get esp32 integration yet through espyaml?

  2. has anyone made their iPhone into a beacon? I saw a video on how but access to the Xcode section on dev requires $99/yr. I’m not sure I would pay that and not have it work.

  3. are more pi’s better for this setup? How does it do with multiple floor detection?

Thanks!

1 Like

MQTT auto discovery doesn’t seem to be working over here :frowning: How do I create the sensors manually in config.yaml please? Thanks!

Hi dedepene,

Add a sensor like this in the configuration file:

 - platform: mqtt_room
    device_id: "beacon_id"
    name: "Godfather"
    state_topic: "room_presence"
    timeout: 15
    away_timeout: 600

Your device_id (UUID) can be found by checking the room assistant log or in the Beacon app you are using. Its also possible to use a MQTT sniffing tool to see the messages that are send by room assistant.

Then you can make a boolean sensor template for your room presence like this:

  - platform: template
    sensors:
      presence_huiskamer:
        value_template: >-
          {{ (is_state('sensor.tim_ibeacon', 'Huiskamer') or
             (is_state('sensor.natascha_ibeacon', 'Huiskamer')) }}`
1 Like

I use this on a pi zero. It is responding fast enough. I have it set to a 5 second interval.

Been using it for a few days, only the HA and BluetoothClassis integrations… I’m tracking 4 devices and it works fine. But when the devices have been away for some time and returns, the tracking doesn’t update anymore. Running on RP3, LAN cable. Anyone else having this issue?

Could you post some logs from when that happens (ideally from room-assistant -v if not running via Hass.io)? Either here or as a GitHub issue.

Been trying to get this addon to work and really struggling, was hoping for some help. For reference all I am trying to do is get room assistant running as an addon on the same pi I have HA on and able to detect and report presence for my phone and my wife’s apple watch. I eventually would like to do actual room presence but I’m not buying pi zeros to set up a cluster until I can get it working on this one device.

So far I have not had any success tracking the apple watch at all. For my android phone it seemed like nothing was working at all but after I figured out a way to turn on verbose logging via the Portainer add-on I was able to make some small progress. My log is almost entirely filled with messages like this:

5/2/2020, 4:12:10 PM - debug - BluetoothClassicService: Querying for RSSI of <Phone BT MAC> using hcitool
5/2/2020, 4:12:11 PM - debug - BluetoothClassicService: Command failed: hcitool -i hci0 cc "<Phone BT MAC>" && hcitool -i hci0 rssi "<Phone BT MAC>"
Can't create connection: Operation timed out
Read RSSI failed: I/O error

But once in a while I see something like this:

5/2/2020, 4:08:34 PM - debug - BluetoothClassicService: Querying for RSSI of <Phone BT MAC> using hcitool
5/2/2020, 4:08:34 PM - debug - BluetoothClassicService: Received RSSI of 0 for <Phone BT MAC> from 6e66619d-room-assistant
5/2/2020, 4:08:34 PM - debug - EntitiesService: Adding new entity bluetooth-classic-<Phone BT MAC>
5/2/2020, 4:08:34 PM - debug - HomeAssistantService: Registering entity room-assistant-bluetooth-classic-<Phone BT MAC> under homeassistant/sensor/room-assistant/bluetooth-classic-<Phone BT MAC>/config
5/2/2020, 4:08:34 PM - debug - HomeAssistantService: Sending new state 6e66619d-room-assistant for room-assistant-bluetooth-classic-<Phone BT MAC>
5/2/2020, 4:08:34 PM - debug - HomeAssistantService: Sending new attributes {"distance":0,"lastUpdatedAt":"2020-05-02T20:08:34.391Z"} for room-assistant-bluetooth-classic-<Phone BT MAC>

Also to clarify, when I say once in a while I mean like I’ve seen this message a couple of times total in a few hours of trying this. And only when I’ve had the bluetooth pair devices screen open on my phone, if my phone is just sitting there it always says I/O timeout. And even if I leave it on the pair devices screen I only get this success message once, then its back to I/O timeouts.

And while its nice to see something that looks positive in the log, this is all I get. There is no entity created in Home Assistant and all during this I’ve been listening to # on my MQTT broker, I don’t see any message actually come through from room-assistant. This would suggest there’s an issue talking to my MQTT broker but I’m using the exact same configuration that works with Zigbee2MQTT. And right at the beginning of my room-assistant log after start-up I see this:

5/2/2020, 4:05:18 PM - info - HomeAssistantService: Successfully connected to MQTT broker at mqtt://<HA IP>:1883

I also don’t see any messages about issues sending MQTT messages despite having verbose logging turned on.

I’m pretty much at a loss at this point. Nothing seems to be working and I’m out of potential troubleshooting steps. Would love some advice from anyone who has gotten this working.

If it’s connected successfully I think there are just no updates happening unfortunately. With the newest version some entities are created to report the room-assistant status on startup, so if you don’t see those either we need to investigate that part further.

For monitoring the phone: this is unfortunately down to the specific model that you use and a bunch of other factors that are hard to generalize. I’ve heard that some models require you to have something paired (some even allow unpairing afterwards) before they respond to Bluetooth queries. The Apple Watch is such a case - users that had problem with this one could fix it by just pairing some BT headset to it once and then removing it again.

Right so it looks like I have a problem then for sure. I found this issue in the release notes of 2.5.0 with the status entities you’re talking about but I don’t see anything in my entities list with an ID that contains room_assistant. I also tried listening on my mqtt broker for room-assistant and I’m not seeing anything.

Any ideas what I might be doing wrong here? It seems like something is just not getting through from room assistant to HA. I have discovery turned on for MQTT so I think it should be working. I’m also using the same user as I use for Zibgee2MQTT which has full read-write permissions across # so it shouldn’t be a permission issue. Do I have to create a separate MQTT user for room assistant that isn’t used anywhere else?

Alternatively I could try and set up these entities manually. I’ve never done that before, I always use discovery but I assume there’s a way to do that. Is there instructions somewhere I could follow to try manual setup of one of these status entities?

Here’s my full config for the add-on btw if it helps:

global:
  integrations:
    - homeAssistant
    - bluetoothClassic
homeAssistant:
  mqttUrl: 'mqtt://<HA IP>:1883'
  username: <MQTT USERNAME>
  password: <MQTT PASSWORD>
bluetoothClassic:
  minRssi: -1
  addresses:
    - '<BT MAC 1>'
    ...

I didn’t change the defaults for the network area, HTTP API port is set to null and internal communication uses port 6425.

I facing the following error

[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.
[16:41:16] INFO: Setting up Home Assistant configuration
[16:41:16] 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 <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>
5/8/2020, 4:41:16 PM - info - IntegrationsModule: Loading integrations: home-assistant, bluetooth-classic
5/8/2020, 4:41:16 PM - info - NestFactory: Starting Nest application...
5/8/2020, 4:41:16 PM - info - InstanceLoader: AppModule dependencies initialized
5/8/2020, 4:41:16 PM - info - InstanceLoader: ConfigModule dependencies initialized
5/8/2020, 4:41:16 PM - info - InstanceLoader: NestEmitterModule dependencies initialized
5/8/2020, 4:41:16 PM - info - InstanceLoader: IntegrationsModule dependencies initialized
5/8/2020, 4:41:16 PM - info - InstanceLoader: DiscoveryModule dependencies initialized
5/8/2020, 4:41:16 PM - info - InstanceLoader: HomeAssistantModule dependencies initialized
5/8/2020, 4:41:16 PM - info - InstanceLoader: ClusterModule dependencies initialized
5/8/2020, 4:41:16 PM - info - InstanceLoader: ScheduleModule dependencies initialized
5/8/2020, 4:41:16 PM - info - InstanceLoader: BluetoothClassicModule dependencies initialized
5/8/2020, 4:41:16 PM - info - InstanceLoader: EntitiesModule dependencies initialized
5/8/2020, 4:41:16 PM - info - InstanceLoader: StatusModule dependencies initialized
5/8/2020, 4:41:16 PM - info - RoutesResolver: EntitiesController {/entities}:
5/8/2020, 4:41:16 PM - info - RouterExplorer: Mapped {/, GET} route
5/8/2020, 4:41:16 PM - info - RoutesResolver: StatusController {/status}:
5/8/2020, 4:41:16 PM - info - RouterExplorer: Mapped {/, GET} route
5/8/2020, 4:41:17 PM - info - HomeAssistantService: Successfully connected to MQTT broker at mqtt://192.xxx.x.xxx:1883
5/8/2020, 4:41:17 PM - info - ConfigService: Loading configuration from /usr/lib/node_modules/room-assistant/dist/config/definitions/default.js, config/default.json, config/local.json
5/8/2020, 4:41:17 PM - info - ClusterService: Starting mDNS advertisements and discovery
5/8/2020, 4:41:17 PM - info - NestApplication: Nest application successfully started
5/8/2020, 4:41:18 PM - info - EntitiesService: Refreshing entity states
5/8/2020, 4:41:33 PM - error - ClusterService: Command failed: dig +short @224.0.0.251 -p 5353 -4 localhost.

I believe that you need to move your username and password under mqttOptions:

global:
  integrations:
    - homeAssistant
    - bluetoothClassic
homeAssistant:
  mqttUrl: 'mqtt://<HA IP>:1883'
  mqttOptions:
    username: <MQTT USERNAME>
    password: <MQTT PASSWORD>
bluetoothClassic:
  minRssi: -1
  addresses:
    - '<BT MAC 1>'

If you’re running this on HassOS with the Mosquitto add-on you don’t need to setup the mqttUrl or mqttOptions at all btw, those will be auto-discovered (only on the add-on instance though, if you run others you need to configure it there). Generally using the same user multiple times should be fine, although I guess it doesn’t hurt to try if this still doesn’t pan out. room-assistant will write to homeassistant/+/room-assistant/+/config and room-assistant/+/+/+.

1 Like

I’m not sure what error you are referring to? If it’s about the localhost line right at the end, that can be ignored and shouldn’t have an impact on the application. It’s just a weirdness with MDNS and I need to enhance the filter to ignore localhost in order to not print that error anymore.

Well I feel incredibly dumb, that did the trick. I clearly did not look at the docs close enough, sorry about that.

I did see in the docs that it says if you use the mosquitto add-on you don’t need to set up the mqttUrl or mqttOptions. But one thing I don’t understand is how does it get the username to use? I have a specific user I give read/write access to and the mosquitto config doesn’t specify that. Does it look at the accesscontrollist file to try and figure it out or does it assume a specific username?