-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with multiple sensors #89
Comments
I examined this last night and I think the problem is that bleak cannot be used by two python programs at the same time in a non blocking way. Because my configuration looked like this: sensor:
- platform: airthings_wave
scan_interval: 150
elevation: !secret home_elevation
mac: !secret airthings_wave_mini
- platform: airthings_wave
scan_interval: 150
elevation: !secret home_elevation
mac: !secret airthings_wave_plus Home assistant spawned two python processes and one was then blocking the other (if my assumption is correct). It works for multiple devices when I do not provide mac adresses and let the component scan for near BLE devices using a config l ike this: sensor:
- platform: airthings_wave
scan_interval: 150
elevation: !secret home_elevation While playing around I went over the code and made sure disconnect() will be called after every connect()... this was not the case previosuly. I created a PR so someone could review and eventually merge those changes. |
Was having the same issue with explicitly defined |
Agree! For that my theory has to be verified and we have to find a way to use bleak clients from two separate python processes in a non blocking way. I am no expert in asynchronous programming and at the moment my time is very limited... If no one will look a this I might get back learn something new about async programming but this might take a while... |
Hi,
I updated the custom_component because of the breaking change in the latest home assistant release. Previously, I ran an airwave plus and and airwave mini with the custom_component for months without a problem.
After the migration only one of my sensors seem to connect. The other one becomes unavailable. Both sensors work independently but when I try to connect them both, one fails without any log in the debug log. It just says:
While it says it is connecting to Sensor A and B it actually ever connects only to A.
Did anyone try multiple sensors? I suspect some kind of race condition here caused by the switch to asyncio. Bleak has an example on how to connect to two devices at the same time: https://github.com/hbldh/bleak/blob/develop/examples/two_devices.py
Maybe this helps someone. I will try to check the code for this myself but currently I am out of free time.
Thanks for the integration :-)
The text was updated successfully, but these errors were encountered: