I’m currently using the BLE adaptor in my RPi for Device Tracker of BLE devices.
I was wonder if it’s possible to somehow write a component that temporarily “borrows” access to that dongle to perform a task and also stop it being borrowed for multiple copies of that task?
e.g. I’m currently using a second Pi to get the battery level of a number of BLE Devices (Smart Watch, Bike Light, HR Sensor) via a convoluted combination of cURL commands and PHP scripts and would like it to be more efficient.
The way I see it happening is
- The Device Tracker says that device A B and C are home
- Three Automations running triggering a (script?) within my custom component which uses gatttool tool to retrieve the battery level, but these commands are somehow queued rather than triggered immediately
- The Device tracker component finishes it’s run
- Allowing my Custom Component to run and gets Device A’s battery level
- The Device Tracker is then allowed to run again
- The Custom Component runs and gets Device B’s battery level
- The Device Tracker is then allowed to run again
- The Custom Component runs and gets Device C’s battery level
- The Device Tracker is then allowed to run again
I’m not sure what I’d look for in the documentation to achieve this type of locking of the BLE device, and allowing only 1 instance of the component script to run at a time (effectively building a FIFO queue). Are there proper mechanisms for this or am I limited to a bodge? If I can’t share access to the BLE Dongle I could add another USB Dongle, but does HASS have a FIFO queue mechanism when multiple commands must not be run at the same time?