sensor.airthings_wave icon indicating copy to clipboard operation
sensor.airthings_wave copied to clipboard

make sure disconnect is getting called by using finally

Open flecmart opened this issue 3 years ago • 5 comments

I added finally blocks to the logic to make sure BleakClient disconnects as suggested in https://bleak.readthedocs.io/en/latest/usage.html

flecmart avatar Jul 18 '22 20:07 flecmart

For what it is worth, I think @flecmart's changes are good, subject to some minor formatting cleanup, and is a better way to ensure that disconnect is called. I have been using these changes for a little while with my script and addon and they are working well so far.

mjmccans avatar Jul 27 '22 15:07 mjmccans

You can't raise exceptions like that. They must be derived from the base Exception class.

lone-cloud avatar Aug 04 '22 22:08 lone-cloud

You're right @lone-cloud - I fixed the raising of exceptions in this PR. Thank's for the hint. I can't confirm that my changes make the sensor work in the newest home assistant release - there is still the conflicting bleak versions.

flecmart avatar Aug 05 '22 04:08 flecmart

I already tested your changes in #93 and I know that it won't work. We believe that this custom component needs to be rewritten using the new bluetooth integration. I'm leaving for vacation tomorrow, so I won't have time to mess around with it until next Tuesday at the earliest.

lone-cloud avatar Aug 05 '22 05:08 lone-cloud

Yeah, I was reading through that issue, too. I think you're right about moving to the official bluetooth integration. Did not wan't to have a broken PR here, though :-)

flecmart avatar Aug 05 '22 05:08 flecmart