Skip to content
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

Unavailable with HA 2022.7 #86

Closed
kongjudas opened this issue Jul 6, 2022 · 25 comments
Closed

Unavailable with HA 2022.7 #86

kongjudas opened this issue Jul 6, 2022 · 25 comments

Comments

@kongjudas
Copy link

kongjudas commented Jul 6, 2022

This is a warned issue, but I'll post it anyway. Integration is no longer working after the Home Assistant 2022.7 release, due to lack of support with bluepy.

Platform error sensor.airthings_wave - Integration 'airthings_wave' not found. Platform error sensor.airthings_wave - Requirements for airthings_wave not found: ['bluepy==1.3.0'].

@ismarslomic
Copy link

Same issue here after upgrading HA to v2022.7. Please refer to the changelog which recommends replacing bluepy with bleak

@lone-cloud
Copy link

lone-cloud commented Jul 6, 2022

The full error doesn't really add any additional clarity but here it is:

Logger: homeassistant.util.package
Source: util/package.py:99
First occurred: 9:41:56 PM (6 occurrences)
Last logged: 9:47:57 PM

Unable to install package bluepy==1.3.0: error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [8 lines of output] /usr/local/lib/python3.10/site-packages/setuptools/dist.py:772: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead warnings.warn( running bdist_wheel running build running build_py Working dir is /tmp/pip-install-fllp_yrs/bluepy_86bc7bea88ae4aabb87b2c08aa664182 execute make -C ./bluepy clean error: [Errno 2] No such file or directory: 'make' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for bluepy error: subprocess-exited-with-error × Running setup.py install for bluepy did not run successfully. │ exit code: 1 ╰─> [10 lines of output] /usr/local/lib/python3.10/site-packages/setuptools/dist.py:772: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead warnings.warn( running install /usr/local/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running build_py Working dir is /tmp/pip-install-fllp_yrs/bluepy_86bc7bea88ae4aabb87b2c08aa664182 execute make -C ./bluepy clean error: [Errno 2] No such file or directory: 'make' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure × Encountered error while trying to install package. ╰─> bluepy note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.

Seems like it was a poor idea to depend on "bluepy==1.3.0" as that release is 4 years old and no new versions of bluepy have come out since. I do see that bluepy has continued to get updates in master without new releases, so maybe it could work with python 3.10???
As stated previously, I think the ideal solution is to switch over to use bleak.

@sverrham
Copy link
Collaborator

sverrham commented Jul 6, 2022

I will probably get to this but I just moved and do not have time to work on this right now, sorry for the issue.

@mjmccans
Copy link

mjmccans commented Jul 7, 2022

I rely on the airthings.py code for my Airthings mqtt script and addon (which can be found here and here). While my projects are not affected by the removal of bluepy in Home Assistant, it strikes me as a good idea to move over to bleak and I started on that work last night. I already have a decent amount of it working, but it is a bit quick and dirty at the moment and I only have a single Airthings Plus device to test on. Either way, I will share my changes if I get it working so everyone can benefit.

@Madelinot
Copy link

Same issue here after the 2022.07 update. :-(

@mjmccans
Copy link

mjmccans commented Jul 8, 2022

While it is a bit messy, if you are interested you can see my first attempt at converting over to bleak here. It is working for me and my scripts except that I have not yet tried to figure out commands, so the battery level is not included. This is my first time using asyncio so I am probably doing some of it (or all of it) wrong, and you may have to adjust the other parts of the custom component call in due to that, but hopefully this helps get things started. I welcome any suggestions and constructive criticism and I will continue to update my repository as I get more things figured out.

@mjmccans
Copy link

mjmccans commented Jul 9, 2022

I think I have figured out commands, so the newest version here should also work for battery and illuminance. As cautioned before, there may be a more elegant / correct way to convert to bleak but the changes I have made appear to work for my script and addon. As always, suggestions and constructive criticism are welcome, and it would be get if someone could try this out to see if it works for them.

@sondercoder
Copy link

sondercoder commented Jul 9, 2022

I am going to test this, and if it works well, will be a welcome update. Thank you for your efforts mjmccans.

It appears I just need to overwrite the original airthings.py with your version. Wish me luck 👍

*edit Clearly more changes need to be made for it to work with this integration. I believe the manifest as well to include bleak.

@mjmccans
Copy link

You are probably right that the manifest would need to be updated and likely the sensors.py file would need to be updated in a few places to be compatible with asyncio (which is the underlying framework bleak is based on). If I have a moment I will take a look, but I may not have time for a few days. The good news is that I have been running the updated version of my addon that uses bleak for over 2 days now and it has been rock solid. While probably not interesting if you use this custom component, I also like the fact that my addon no longer needs host networking or other elevated permissions because bleak communicates with the hosts dbus instance. Sorry I cannot provide more assistant right now, but hopefully the little bit that I did do gets things moving in the right direction.

@B1ob
Copy link
Contributor

B1ob commented Jul 11, 2022

I created a pull request based on the work from mjmccans. I only have a little experience in Python, so if you have any change requests, I am open for them. For me it is working fine. #87

Edit: Mhm, seems as the data is not updated correctly and always stays the same.

@MartyTremblay
Copy link
Member

MartyTremblay commented Jul 11, 2022

Hi @mjmccans and @B1ob ,

Firstly, amazing work and very glad that someone from the community feels that this component is important enough to dedicate his or her time to make it work.

Much like @sverrham , I have limited free time for the foreseeable future so any help from you guys goes a long way.

I'll be glad to test and approve PRs once you feel your changes are ready. Thanks again!!!

@B1ob
Copy link
Contributor

B1ob commented Jul 11, 2022

I think i fixed my branch... I will continue testing and hopefully create a new pull request tomorrow. In the mean time testing and comments are welcome. https://github.com/B1ob/sensor.airthings_wave/tree/convert_to_bleak

@mjmccans
Copy link

@B1ob, I have made a small change to the code for identifying Airthings devices while scanning because I don't think I was doing it properly before. Can you please check to see if scanning works for you as well?

@Sticky12

This comment was marked as resolved.

@Gnonthgol
Copy link

Gnonthgol commented Jul 11, 2022

@B1ob with the mac address set in the configuration I get:

homeassistant | 2022-07-11 23:46:49 ERROR (SyncWorker_4) [custom_components.airthings_wave.airthings] Not getting device info because failed to connect to device.

When I comment out the mac address in the config file I get:

homeassistant | 2022-07-11 23:49:56 ERROR (SyncWorker_4) [custom_components.airthings_wave.sensor] Failed intial setup.
homeassistant | Traceback (most recent call last):
homeassistant | File "/config/custom_components/airthings_wave/sensor.py", line 213, in setup_platform
homeassistant | num_devices_found = asyncio.run(airthingsdetect.find_devices())
homeassistant | File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
homeassistant | return loop.run_until_complete(main)
homeassistant | File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
homeassistant | return future.result()
homeassistant | File "/config/custom_components/airthings_wave/airthings.py", line 222, in find_devices
homeassistant | advertisements = await BleakScanner.discover(timeout)
homeassistant | File "/usr/local/lib/python3.10/site-packages/bleak/backends/scanner.py", line 115, in discover
homeassistant | async with cls(**kwargs) as scanner:
homeassistant | File "/usr/local/lib/python3.10/site-packages/bleak/backends/scanner.py", line 95, in aenter
homeassistant | await self.start()
homeassistant | File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 88, in start
homeassistant | self._bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
homeassistant | File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 122, in init
homeassistant | super().init(bus_address, bus_type, ProxyObject)
homeassistant | File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 85, in init
homeassistant | self._setup_socket()
homeassistant | File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 575, in _setup_socket
homeassistant | raise err
homeassistant | File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 548, in _setup_socket
homeassistant | self._sock.connect(filename)
homeassistant | FileNotFoundError: [Errno 2] No such file or directory

This is all using the ghcr.io/home-assistant/home-assistant/homeassistant:stable docker image (27874d7ff7d9) on 64 bit arm. I am sure I can get this working but I fear for people with less technical knowledge.

@Sticky12
Copy link

Sticky12 commented Jul 11, 2022

Hi @B1ob How do I test your changes? I cannot restart home assistant, because of this custom component. I tried overwriting the files with your changes, but it keeps telling me that my configuration is invalid, because this component needs bluepy 1.3.0. I also tried removing it in HACS, but same error.

I am running with your changes now, it seems to work just as before. My device is an Airthings Wave Plus.

@Gnonthgol
Copy link

For the record I did get it to work. First I mounted /run/dbus/system_bus_socket inside my container. Secondly I also applied the changes from @mjmccans (mjmccans/airthings-mqtt-ha@a11a0a0) to @B1ob 's branch. I now get the data showing in home assistant.

@B1ob
Copy link
Contributor

B1ob commented Jul 12, 2022

I now incorporated the changes from @lymanepp and @mjmccans in my branch. Thanks for the feedback here, maybe you can have a look at the updates again (I tried to change the polling to an Event notification). For me it is now working in Home Assistant Operating System on a RPi4. It is also working with and without a mac specified. So, the discovery (at least for me) is also working.

@Gnonthgol you are using this custom-components on a Home Assistant Container? Or what is your environment? Do you see something that i can change to make it working out of the box?

https://github.com/B1ob/sensor.airthings_wave/tree/convert_to_bleak

Edit: I reopend my pull request again. When i get some positive feedback from the community i will put it in "Ready for review"

@Gnonthgol
Copy link

@B1ob I am using the setup at https://www.home-assistant.io/installation/raspberrypi#docker-compose

I did have a quick look at bleak and it looks like there is a hard dependency on dbus. It might be possible to run dbus inside the container but that does not sound like a good idea. So I am out of ideas.

I support your pull request as it is a huge from improvement, as it actualy have a chance of working. But for now it might be required to document the dbus volume mount in the README.

@mjmccans
Copy link

@Gnonthgol For what it is worth, mounting the /run/dbus in the container is what I have done, as you can see here. I believe that is how Home Assistant does it for addons as well, because there is an option to mount the host dbus service in the addon (see here) and I use that for the addon version of my script. Given that the Home Assistant developers know a lot more than I do I assume that is the correct way to do it and I agree that any documentation should be updated accordingly.

@mjmccans
Copy link

@B1ob I made a small suggested change in the PR to the event code to avoid blocking indefinitely if something goes wrong while waiting for the command to return data. Also, no need to add my name to the copyright notice, but if you do want to you can pull my name from the copyright notice in my repository. Thank you.

@B1ob
Copy link
Contributor

B1ob commented Jul 13, 2022

I now marked the pull request as ready to review. In my case it is now running fine. And if there are new problems in the future, we can fix them from there on. The main goal for now is to get the custom component working again at all.
#87

@MartyTremblay
Copy link
Member

Good stuff! I'll test it this evening, first on 2022.6.x for backwards compatibility, and then in 2022.7.3

@MartyTremblay
Copy link
Member

I want to thank @B1ob again and all of you for making this happen. Without you, this component would have become obsolete.

Cheers!

@mikeboiko
Copy link

Thank you @B1ob and @MartyTremblay for your work!
I'm still getting the following error with the latest code though:
ERROR (SyncWorker_0) [custom_components.airthings_wave.airthings] Not getting device info because failed to connect to device.

Has anyone else encountered this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests