sensor.airthings_wave
sensor.airthings_wave copied to clipboard
make sure disconnect is getting called by using finally
I added finally blocks to the logic to make sure BleakClient disconnects as suggested in https://bleak.readthedocs.io/en/latest/usage.html
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.
You can't raise exceptions like that. They must be derived from the base Exception class.
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.
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.
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 :-)