quentinms / homebridge-aranet4

An Homebridge plugin to get data from an Aranet4
Apache License 2.0
36 stars 1 forks source link

Raspberry Pi not finding sensor #27

Open ohmantics opened 1 year ago

ohmantics commented 1 year ago

I'm running Homebridge on a Raspberry Pi on Raspbian Bullseye (32-bit). The plugin always fails with "did not find any devices." I've increased the discovery timeout to 60s with no success.

Home Assistant running on the same device sees the sensor with no problems. The bluetoothDebug.js script does see the MAC of the sensor. bluetoothctl indicates that the device is paired.

alcayaga commented 1 year ago

I have the same issue on Raspbian Buster when I updated the firmware of the Aranet to v1.2.0 and the plugin to 0.0.3

[2/21/2023, 9:48:51 AM] [Aranet4 Platform] Initializing Aranet4 platform...
[2/21/2023, 9:48:51 AM] [Aranet4 Platform] Finished initializing platform: Aranet4 Platform
[2/21/2023, 9:48:51 AM] [Aranet4 Platform] Configs: {"name":"Aranet4 Platform","co2AlertThreshold":1400,"batteryAlertThreshold":10,"sensorDataRefreshInterval":300,"bluetoothReadyTimeout":60,"bluetoothDeviceSearchTimeout":60,"platform":"Aranet4"}
[2/21/2023, 9:48:52 AM] [Aranet4 Platform] Executed didFinishLaunching callback
[2/21/2023, 9:48:52 AM] [Aranet4 Platform] poweredOn
[2/21/2023, 9:48:52 AM] [Aranet4 Platform] Starting to scan...
[2/21/2023, 9:49:52 AM] [Aranet4 Platform] errored while getting devices:Error: Did not find any devices
ParaAdBellum commented 1 year ago

can you see if the following diff resolves your problem? it does for me:

in /var/lib/homebridge

--- ./node_modules/homebridge-aranet4/dist/aranet.js- 2022-11-05 10:52:28.866609648 -0700 +++ ./node_modules/homebridge-aranet4/dist/aranet.js 2023-05-20 10:36:14.530192577 -0700 @@ -18,7 +18,8 @@ exports.Aranet4Device = void 0; const noble_1 = __importDefault(require("@abandonware/noble")); const util_1 = require("util"); -const ARANET4_SERVICE = '0000fce0-0000-1000-8000-00805f9b34fb'; +const ARANET4_SERVICE = 'fce0'; +//const ARANET4_SERVICE = '0000fce0-0000-1000-8000-00805f9b34fb'; const ARANET4_CHARACTERISTICS = 'f0cd300195da4f4b9ac8aa55d312af0c'; const MANUFACTURER_NAME = { name: 'org.bluetooth.characteristic.manufacturer_name_string', id: '2a29' }; const MODEL_NUMBER = { name: 'org.bluetooth.characteristic.model_number_string', id: '2a24' };

ohmantics commented 1 year ago

@ParaAdBellum Same error as before, although I'm now running Ubuntu Lunar Lobster.

ParaAdBellum commented 1 year ago

weird, does aranetctl @ https://github.com/Anrijs/Aranet4-Python work for you?

aranetctl --scan

ParaAdBellum commented 1 year ago

also, which raspberry pi are you using? I've had issues with raspberry pi 3 in the past

ohmantics commented 11 months ago

I've migrated to an 'Raspberry Pi Compute Module 4 Rev 1.1' and still have this problem. aranetctl --scan finds nothing, but my Home Assistant Yellow box (also CM4-based) is happily talking to the sensor.

max-christian commented 11 months ago

The patch above solved the "did not find any devices" error for me. N.B. You get zero readings for the first few minutes.

max-christian commented 10 months ago

I found scanning for the device eventually failed on Linux and Mac even after applying this patch. Took a week for it to fail on Mac, no idea why. Connecting to the device using the previously-scanned peripheral UUID still worked fine, as did scanning all devices and looking for 'Aranet4' but neither this plugin nor aranetctl could find it since they both search by service. So I rewrote the scanning code to grab all devices and look for the device by name instead of service. This seems to be working well so far.

alcayaga commented 4 months ago

I found scanning for the device eventually failed on Linux and Mac even after applying this patch. Took a week for it to fail on Mac, no idea why. Connecting to the device using the previously-scanned peripheral UUID still worked fine, as did scanning all devices and looking for 'Aranet4' but neither this plugin nor aranetctl could find it since they both search by service. So I rewrote the scanning code to grab all devices and look for the device by name instead of service. This seems to be working well so far.

Can you publish the changes in your repository? I am interested in testing this. Thanks!

max-christian commented 3 months ago

Can you publish the changes in your repository? I am interested in testing this. Thanks!

@alcayaga sorry for the delay, my experimental version is now available here: https://github.com/max-christian/homebridge-aranet4

This has the following changes:

I'm not sure if Homebridge will share the accessory cache between different repositories of the same plugin, but if it does you must remove any cached Aranet accessories before installation. Homebridge Settings -> Remove Single Cached Accessory.