Seeking software / config advice for offloading esphome function to RPi devices

I’ve got a house full of various sbc devices, mostly esp32 and RPi zero 2w/3a/4b. Generally RPis host platforms, like Moode Audio, OctoPi etc. and ESP32 devices serve as multi-sensors and bluetooth_le_tracker. I’ve gotten to thinking that I could streamline some of my device footprint, (especially now that I’m trying to get a bluetooth_le_tracker in every room) by using those relatively more powerful RPi devices to take sensor data and bluetooth_le_tracker as well.

I don’t think there’s really a coherent way to use ESPHome to manage RPi devices (though that would be rather cool).

So is the next best option to try and do a sort of sideloading with sensors running in the background alongside moode etc, e.g. bluetooth_le_tracker via bluez and a custom config, similar sorts of things for BMP280, CCS811, TEMT6000. Is there some beautiful and streamlined way to do this for RPi like ESPHome that I’m just not finding in web searches? Would love to hear how others are doing similar config.

So I’ve got a sense of the options now after many hours watching youtube videos and trying to wrap my head around options. Here are some initial observations. It seems like there are at least two options for RPi systems:

  • But it’s worth first noting that for ESP32 base stations espresence is the way to go AFAICT as it’s quick and easy to deploy with ESPHome, and can work alongside other sensors connected to the station.
  • On RPi base stations, it looks like can sideload the Room Assistant platform or a script-based solution like Andrew Freyer’s monitor bash shell script for RPi. These are both basically fancy wrappers for hcitool (which is part of BlueZ the RPi fave for bluetooth ops) under the hood.

For all of these solutions, it seems like almost any kind of BLE monitoring station sends data via MQTT to HA, so mix-and-match of base stations shouldn’t be an issue.

I’ve checked a few distributions of RPi that I have laying around the house, and confirmed that, at least in principle, an install of Moode Audio, Volumio, or OctoPi should be able to host BLE monitoring tools alongside their regular operations. I’ll report back once I’ve tested a few options.

Also, FYI, for anyone else who is new to this and wants to test the fitness of a given RPi board with pre-loaded software on it, here’s what you do:

  • Confirm BlueZ is loaded and get version number using: btmon -v
  • Try scanning for regular bluetooth devices: sudo bluetoothctl and then scan on
  • Scan for BLE devices (and confirm your RPi has hw and sw that can do so): sudo hcitool -i hci0 lescan

I’ve managed to get this working without a (at least yet?) hitch on a RPi 4 that is running Moode audio. Here is the process I went through to get it installed. Worth noting that I’ve gone with a docker install for the sake of compartmentalisation just to be safe.

Prerequisites:

  • MQTT installed on HA

Start by connecting via SSH into your RPi device, then run the following commands to install docker and docker-compose:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker ${USER}

Exit and relogin using ssh, the do the following to install room assistant:

mkdir room-assistant
cd room-assistant/
nano compose.yml
mkdir -p ~/room-assistant/config
nano ~/room-assistant/config/local.yml

Create a docker compose file following the recommended room-assistant syntax and create a separate config/local.yml with config for this particular local instance. I used the following for compose.yml:

version: '3'
services:
  room-assistant:
    image: mkerix/room-assistant
    restart: always
    network_mode: host
    volumes:
      - /var/run/dbus:/var/run/dbus
      - /home/pi/room-assistant/config:/room-assistant/config

Then install the room-assistant packages:

docker compose pull
docker compose up-d

Your device will begin scanning for BLE devices you’ve included in local.yml and will send information to home assistant via the configured MQTT server.

1 Like

Reporting back one last time in case others are curious about this experiment. Adding use of hcitool for presence detection pretty much wrecks bluetooth functionality (there are stutters and clicks in the audio) on the Moode device. This seems like a pretty reasonable outcome for a bluetooth function that can’t be used by two features at the same time. If you can disable bluetooth for audio playback, and rely on wifi via airplay, squeeze / LMS or UPNP, which are all quite reasonable options, it’s feasible to devote bluetooth exclusively to BLE monitoring and it seems like that’s a viable use case. However, if your people require bluetooth, then best not worth trying this experiment IMHO.

I’ve worked with Room Assistant for a while, and ESPHome, but have finally settled on ESPresence, with separate ESP32-S3 devices alongside my RPi running ESPresence. The killer feature that ESPresence has at least for now is BLE device fingerprinting. Some devices, especially smartphones will rotate random MAC addresses for BLE, so they’re harder to track. ESPresence has built-in fingerprinting support that will get around this, a feature which is yet to be replicated on any of the other platforms. The devs for ESPresence have been good at adding some basic built-in support for different sensors (BME280, BH1750, LD2410B, etc.) so you don’t need to have a separate multisensor running alongside, though ESPHome obviously has a lot more support for sensors, displays, etc. There is some discussion of trying to dovetail the two platforms, but not much movement on that AFAICT, but will be interesting to see where development goes in the next 12 months. For now, audio RPi / Squeezelite is one box and multisensor / BLE presence is another box side by side.