mKeRix / room-assistant

Presence tracking and more for automation on the room-level
https://www.room-assistant.io
MIT License
1.27k stars 122 forks source link

Avoid keeping bluetooth busy #77

Closed martinrosenauer closed 4 years ago

martinrosenauer commented 5 years ago

Hi,

@mKeRix: first of all thanks for doing this project.

I am in the situation where I'm also using the same Raspberry Pi Zero W to read a Xioami BLE temperature/humidity sensor. When Room-Assistant is running, it fails reading, but when stopping it, it works. Is there any way to have these running in parallel ?

It's easy to simulate by running 'sudo hcitool lescan' while Room-Assistant is running.

mKeRix commented 5 years ago

Unfortunately I believe that we have to keep the lock on the Bluetooth adapter to keep receiving the scan messages. Currently I see two ways of fixing this:

  1. Get a USB bluetooth adapter, plug it in and use that one for room-assistant as described here. (cheap & quick fix)
  2. Integrate Xiaomi sensors into room-assistant, so that it may parse these sensors by itself. Unfortunately I don't have one of these things to play around with atm. Could you maybe link the model you are using? Possibly I can get my hands on one sometime. (more sustainable fix, just takes some work)
martinrosenauer commented 5 years ago

I agree 1) is worth a try - waiting for one in the mail and will give it a shot.

For 2) - It would be greatly appreciated - this is the device:

https://www.banggood.com/Xiaomi-Mijia-Bluetooth-Thermometer-Hygrometer-with-LCD-Screen-Magnetic-Suction-Wall-Stickers-p-1232396.html?cur_warehouse=CN

and the stuff I'm using to read it and send mqtt message:

https://github.com/algirdasc/xiaomi-ble-mqtt

asknoone commented 5 years ago

Hi mKeRix,

I tried using a second BLE adaptor. I used hci0 for Room Assistant and hci1 for the Mi Flora platform. However, Room Assistant only ran for a couple of minutes then stopped sending data, perhaps due to the other platform getting plant data; logs don't really show anything.

Can I ask, have you proven 2 bluetooth adaptors working okay together and if so, with which other platform did you use at the same time? I don't know whether it's Mi Flora causing the issue or Noble/Room Assistant.

I would try Room Assistant on hci1, however I am running HassIO so I'm guessing this is tricker to do because I don't get easy access to the Docker container to run the sudo command.

I have been using your add-on for about 9 months on 3 Pi Zeros for presence detection and depend on it 100% so thanks for your hard work. (The Wife Approval Factor has been a lot higher with the presence detection than some of my other simpler automations!)

Many Thanks.

BlueBlueBlob commented 5 years ago

Try to don't synchronize them in same time. MiFlora : 20 minutes refresh Room : 3

rGnng commented 4 years ago

Hi guys,

I ran into this issue too, so I plug another bluetooth adapter into my raspberry pi, according to :

  1. Get a USB bluetooth adapter, plug it in and use that one for room-assistant as described here. (cheap & quick fix)

change your home assistant BLE accessories to use HCI1, and add Environment=NOBLE_HCI_DEVICE_ID=0 to your room-assistant systemd service file then restart room-assistant service, works for me.

my room-assistant systemd service file:

[Unit]
Description=Room Assistant service

[Service]
Environment=NODE_VERSION=8.16.2
Environment=NOBLE_HCI_DEVICE_ID=0
ExecStart=/home/pi/.nvm/nvm-exec npm start
WorkingDirectory=/home/pi/room-assistant
Restart=always
RestartSec=10
User=pi

[Install]
WantedBy=multi-user.target