mjmccans / hassio-addon-airthings

Home Assistant Add-on for Airthings devices that uses mqtt to integrate with Home Assistant via mqtt discovery.
MIT License
20 stars 3 forks source link

HA 2022.8 Bluetooth not detected #16

Closed akagalford closed 2 years ago

akagalford commented 2 years ago

Hello, I was wondering a few things - (forgive me, just getting started with HA and learning lots right now)

I have an Airthings Wave (non plus) that I am attempting to monitor and am wondering if anyone has successfully connected to one?

Also, in HA 2022.8 they have now released a bluetooth manager and wondering if this could be used to find my bluetooth device? It appears from my logs that it is currently unable to locate my usb bluetooth adapter. Any guidance where to start would be greatly appreciated.

[22:31:36] INFO: Starting python script with external MQTT broker... [2022-08-03 22:31:36] WARNING: Invalid mac address provided: [2022-08-03 22:31:36] INFO: Setting up Airthings sensors... [2022-08-03 22:31:36] INFO: No devices provided, so searching for Airthings sensors... [2022-08-03 22:31:36] INFO: Starting search for Airthings sensors... [2022-08-03 22:31:36] ERROR: Failed while searching for devices. Is a bluetooth adapter available? If the watchdog option is enabled, this addon will restart and try again. Traceback (most recent call last): File "/src/./airthings-mqtt.ha.py", line 89, in find_devices num_devices_found = self.airthingsdetect.find_devices() File "/src/airthings.py", line 236, in find_devices advertisements = scanner.scan(timeout) File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 852, in scan self.start(passive=passive) File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 800, in start self._mgmtCmd(self._cmd()) File "/usr/local/lib/python3.9/dist-packages/bluepy/btle.py", line 312, in _mgmtCmd raise BTLEManagementError("Failed to execute management command '%s'" % (cmd), rsp) bluepy.btle.BTLEManagementError: Failed to execute management command 'scan'

autumnwalker commented 2 years ago

Holding off on upgrading to 2022.08 until we understand impact of the new bluetooth integration on this addon. A friend of mine updated and this addon no longer works.

Speculation, but it could be the reason you're not able to connect to your Airthings device. Can you try 2022.07?

mjmccans commented 2 years ago

Thank you for letting me know about this issue, which I had not noticed because I was running my dev branch. I have just released version 1.2.0 of the add-on, which at least for me runs properly on 2022.08. This version changes the backend library that is used to communicate with the bluetooth adapter to the new one that Home Assistant uses, and has additional benefits such as the add-on needing less permissions. However, swapping out the underlying library was not a trivial task so please let me know if you encounter any errors. I have been running it without issue for the last few weeks, but that is only a sample size of one and your mileage may vary.

akagalford commented 2 years ago

Great! I'll update and give it a try this weekend and report back.

autumnwalker commented 2 years ago

Updated to 1.3.0 on 2202.07.06 without issue.

Updated from 2022.07.06 to 2022.08.01, no issues.

Configured the 2022.08 Bluetooth integration, no issues.

Thanks @mjmccans!

mjmccans commented 2 years ago

Great to hear and thank you for reporting back. Hopefully others have the same experience and everything works.

akagalford commented 2 years ago

Almost there. I Updated to the latest version, found my Bluetooth device right away and it now finds the Airthings Wave in the log file but now I have a slight different issue. I am unable to save my device settings on the configuration tab. I have copied and pasted the suggested output from the log file that detected the device but receive the following error when attempting to save my config:

Failed to save add-on configuration, Invalid list for option 'devices' in Airthings (ac75c65b_airthings). Got {'devices': {'devices': [{'mac': 'A0:E6:F8:XX:XX:XX', 'name': 'Basement Airthings Wave'}], 'refresh_interval': 150, 'retry_count': 10, 'retry_wait': 3, 'log_level': 'INFO', 'mqtt_discovery': 'true'}, 'refresh_interval': 150, 'retry_count': 10, 'retry_wait': 3, 'log_level': 'INFO', 'mqtt_discovery': True, 'retain': False}

I have modified the MAC address on purpose. This is what was placed into the devices section of the config: devices:

Full log output: -------------------------------------------------

[22:31:34] INFO: Internal MQTT service found, fetching configuration ... [22:31:34] INFO: Starting python script... [2022-08-05 22:31:34] WARNING: Invalid mac address provided: [2022-08-05 22:31:34] INFO: Setting up Airthings sensors... [2022-08-05 22:31:34] INFO: No devices provided, so searching for Airthings sensors... [2022-08-05 22:31:34] INFO: Starting search for Airthings sensors... [2022-08-05 22:31:44] INFO: Found 1 airthings device(s).

Your suggested add-on yaml configuration is below:

devices:


[22:31:44] INFO: Done.

I have uninstalled and reinstalled the plugin with same error upon save also. Seems a file permission issue? Where should this configuration settings reside?

The hardware I am running on is a Dell Optiplex 3050 Micro system.

akagalford commented 2 years ago

Update - Its working! Forgive me, as I stated just getting started with Home Assistant. I took the instruction from the log output a little to literal and copied and pasted the entire config section causing duplication of settings due to the field formatting provided in the configuration tab. I updated the section under devices with just the mac and name from the provided output and it was able to save and launched perfectly. I am now successfully collecting data from my device. Thank you!

mjmccans commented 2 years ago

@akagalford Good to hear it is working. You make a good point about the configuration not being clear now that there is a more graphical configuration of the add-on. I will look into that.