icanos / hassio-plejd

Hass.io add-on for Plejd home automation devices
Apache License 2.0
126 stars 37 forks source link

BLE issues / Disconnects started happening after update to HAOS 11 #292

Closed waroen closed 10 months ago

waroen commented 10 months ago

Hi,

Plejd addon has been rock solid for a very long time for me on an RPi4. Now it suddenly responds very slowly and logs errors (see below).

The releasenotes for HAOS 11 list the following that might have something to do with it.

2023-10-14 15:44:19 WRN [plejd-ble] Write error indicates BLE is disconnected. Retry count 5. Reconnecting... 2023-10-14 15:44:19 INF [plejd-ble] Starting reconnect loop... 2023-10-14 15:44:19 INF [device-comm] Bluetooth reconnecting... 2023-10-14 15:44:24 INF [plejd-ble] Reconnecting BLE... 2023-10-14 15:44:24 INF [plejd-ble] init() 2023-10-14 15:44:29 INF [plejd-ble] disconnecting /org/bluez/hci0/dev_F8_B0_89_32_22_B2. This can take up to 180 seconds 2023-10-14 15:44:32 ERR [plejd-ble] 'Unlikely error' (0x0e) writing to Plejd. Will retry. Operation failed with ATT error: 0x0e DBusError: Operation failed with ATT error: 0x0e at _methodReturnHandlers. (/plejd/node_modules/dbus-next/lib/bus.js:343:27) at handleMessage (/plejd/node_modules/dbus-next/lib/bus.js:101:11) at EventEmitter. (/plejd/node_modules/dbus-next/lib/bus.js:151:9) at EventEmitter.emit (events.js:314:20) at /plejd/node_modules/dbus-next/lib/connection.js:116:14 at Socket. (/plejd/nodemodules/dbus-next/lib/message.js:63:9) at Socket.emit (events.js:314:20) at emitReadable (_stream_readable.js:557:12) at processTicksAndRejections (internal/process/task_queues.js:83:21) 2023-10-14 15:44:32 ERR [plejd-ble] 'Unlikely error' (0x0e) writing to Plejd. Will retry. Operation failed with ATT error: 0x0e DBusError: Operation failed with ATT error: 0x0e at _methodReturnHandlers. (/plejd/node_modules/dbus-next/lib/bus.js:343:27) at handleMessage (/plejd/node_modules/dbus-next/lib/bus.js:101:11) at EventEmitter. (/plejd/node_modules/dbus-next/lib/bus.js:151:9) at EventEmitter.emit (events.js:314:20) at /plejd/node_modules/dbus-next/lib/connection.js:116:14 at Socket. (/plejd/nodemodules/dbus-next/lib/message.js:63:9) at Socket.emit (events.js:314:20) at emitReadable (_stream_readable.js:557:12) at processTicksAndRejections (internal/process/task_queues.js:83:21) 2023-10-14 15:44:32 WRN [device-comm] BLE not connected, stopping write queue until connection is up again. 2023-10-14 15:44:32 INF [plejd-ble] BLE init done, waiting for devices. 2023-10-14 15:44:34 INF [plejd-ble] Device discovery done, found 1 Plejd devices 2023-10-14 15:44:34 INF [plejd-ble] Connecting to /org/bluez/hci0/dev_F8_B0_89_32_22_B2 2023-10-14 15:44:45 INF [plejd-ble] onDeviceConnected() 2023-10-14 15:44:45 INF [plejd-ble] Connected to Plejd device Gillestuga (F8B0893222B2, BLE id 14). 2023-10-14 15:44:45 INF [plejd-ble] authenticate() 2023-10-14 15:44:45 INF [plejd-ble] BLE Connected to Gillestuga 2023-10-14 15:44:45 INF [plejd-ble] Plejd clock updates disabled in configuration. 2023-10-14 15:44:45 INF [plejd-ble] startPing() 2023-10-14 15:44:45 INF [device-comm] Bluetooth connected. Plejd BLE up and running! 2023-10-14 15:44:45 INF [device-comm] startWriteQueue()

d96moe commented 10 months ago

Seem to be the same for all users, ie same here

netzor commented 10 months ago

Same for me on a Home Assistant Yellow.

moorgrove commented 10 months ago

+1

d96moe commented 10 months ago

Reverted back to hassos 10.5 and as expected, it resolved the issue.

Mats1717 commented 10 months ago

How to revert to 10.5?

d96moe commented 10 months ago

How to revert to 10.5?

From commandline (I use the ssh add on): ha os update --version 10.5

Mats1717 commented 10 months ago

It worked for me to 👍

Mats1717 commented 10 months ago

It worked for me to 👍

ha os update —version 10.5 Not upgrade for me

d96moe commented 10 months ago

It worked for me to 👍

ha os update —version 10.5 Not upgrade for me

Yes, my bad, noted the error and updated my comment when I noticed😀

agekristian commented 10 months ago

same here.

oleost commented 10 months ago

Also related to update to HA OS 11 the switches (WPH-01) stopped responding.

Home assistant didn’t recognize any presses on button. Downgrading to 10.5 makes them work again.

najs2000 commented 10 months ago

+1

downgrade to 10.5 and all works again

pierrei commented 10 months ago

Same problem here. Downgrading now until the bug is fixed 👍

SweVictor commented 10 months ago

Can confirm I see this as well. Agree with the release notes line in the first post. Below is the full release notes for reference. https://github.com/home-assistant/operating-system/releases/tag/11.0

Anyone thas has any knowledge on what more specifically broke behind the scenes?

Example below image

SweVictor commented 10 months ago

Tried updating package dependencies - no luck. I'm downgrading to 10.5 for now as well (using ha os update --version 10.5).

Any ideas on how to move forward appreciated!

faanskit commented 10 months ago

Any ideas on how to move forward appreciated!

I do not have an idea how to move this integration forward, but I have been fearing that something like this would eventually happen. The more Bluetooth capabilities that gets implemented in HA the higher the risk the add-on approach use by HA Plejd. I smell a race towards resources. I sure hope I am wrong.

My conclusion is that eventually this add-on will bite the dust, and have to become a [native] integration to HA.

I don't know what that entails, but I guess a full re-write in Python that use the Blueooth adapter is a good bet.

A lot of design ideas from this integration is likely to make it to a new integration, but refactored to match the new language and how to build [native] modules.

There are some good stuff that would come by moving it from an add-on to an integration. E.g. the complete config flow will be quite improved if done right.

But it is a behemoth of a task that lies ahead; maybe ChatGPT can help to dish out some code :-D Hey Chat, please convert the HA-Plejd add-on to a HA integration and publish it on HACS...

SweVictor commented 10 months ago

Posted a note in the OS release thread at https://community.home-assistant.io/t/home-assistant-os-11-low-latency-scheduler-and-vm-snapshot-improvements/626330/30, we'll see if someone is able to help. Potentially the wrong place to post, feel free to try to reach out to the HA maintainers in other places to get some hints on how to proceed.

For the record, I've tried

The above updates do not help on HAOS 11.0, but still has the addon working well on 10.5.

fpow1 commented 10 months ago

I have the same problem and its kills my other blutoth conections. It works fine woth the other integrations this one have a big blutoth issue right now :(

SweVictor commented 10 months ago

I have the same problem and its kills my other blutoth conections. It works fine woth the other integrations this one have a big bluetooth issue right now :(

@fpow1: My above message does actually originate from another Bluetooth HA integration that also has problems since the 11.0 release and are expecting them to go away with the next HAOS version. Could you link what addon works despite the update, maybe we can get some inspiration into what BT stack still works if this issue persists?

On a related note, I've seen other BT addons (Yale I think it was) having issues as well, so it's not only us at least 😄

SweVictor commented 10 months ago

Realize I posted in the OS thread what was meant for here... See below:

Looked around some other clips. Quoting from Dropped connection after HAOS 11 upgrade · Issue #44 · thomasloven/hass_plejd · GitHub 1

Seems like something happened in BlueZ [5.69] Somewhat broken, was the release pulled? · Issue #594 · bluez/bluez · GitHub 2.

Hopefully fixed with the next HAOS release, so potentially not a “forever” issue.

I belive this is a Home Assistant issue. Seems Bluez was updated in HAOS, and that’s potentially causing issues. See home-assistant/operating-system#2821 1 (also home-assistant/operating-system#2818)

I hear this can take two weeks or so to fix, due to developers also having a life. Please consider downgrading HAOS if you cannot wait.

bdraco commented 10 months ago

https://github.com/home-assistant/operating-system/pull/2835

Will probably fix it

If you need a quick fix (and have an esp32) disable the internal adapter and replace it with an esphome Bluetooth proxy https://esphome.io/projects/index.html

fpow1 commented 10 months ago

I have the same problem and its kills my other blutoth conections. It works fine woth the other integrations this one have a big bluetooth issue right now :(

@fpow1: My above message does actually originate from another Bluetooth HA integration that also has problems since the 11.0 release and are expecting them to go away with the next HAOS version. Could you link what addon works despite the update, maybe we can get some inspiration into what BT stack still works if this issue persists?

On a related note, I've seen other BT addons (Yale I think it was) having issues as well, so it's not only us at least 😄

The airthing addon in HA

SweVictor commented 10 months ago

home-assistant/operating-system#2835

Will probably fix it

If you need a quick fix (and have an esp32) disable the internal adapter and replace it with an esphome Bluetooth proxy https://esphome.io/projects/index.html

The HAOS 11.1.rc1 contains the fix https://github.com/home-assistant/operating-system/pull/2835 mentioned above. Anyone tried it yet?

https://github.com/home-assistant/operating-system/releases

/Victor

magicus commented 10 months ago

Is there some easy way to install an rc version of the OS? If so, I can give it a try.

SweVictor commented 10 months ago

Is there some easy way to install an rc version of the OS? If so, I can give it a try.

No idea 😄 Good luck though!

pierrei commented 10 months ago

Is there some easy way to install an rc version of the OS? If so, I can give it a try.

https://community.home-assistant.io/t/how-to-install-release-candidate/306307/2 (click on arrow top right to see the full reply)

(I googled "install rc version of home assistant" and that was the first result 😉)

magicus commented 10 months ago

@faanskit Your comment made me think of how much work that would be. Then I started looking at the inspiration for this project, https://github.com/klali/ha-plejd. That work has stalled, but an open PR sent me on towards what the author thought was the upcoming thing, https://github.com/thomasloven/hass_plejd.

And that, in turn, seems to be just what I was looking for. Integration with HACS, cooperating with the built-in Bluetooth support instead of fighting with it. It actually also got auto discovery, very nice! It is possible that it is not as fully fledged as this addon, but it was more than enough for my needs.

However, it too has the problem with HassOS 11.0. :-(

magicus commented 10 months ago

@pierrei Oh, I've been LMGTFY:ed! :-D The post you referred to where a bit cryptical, you needed to expand a reference to another post. Also, you needed to upgrade the supervisor, which was not mentioned but clearly explained by the error message.

Here is what I did:

~ $ ha os info
~ $ ha supervisor options --channel=beta
~ $ ha supervisor reload
~ $ ha supervisor update
~ $ ha os update
<this will update and reboot your system>
~ $ ha supervisor options --channel=stable
~ $ ha os info
<verify version has been updated>

According to the original post, you will automatically upgrade to the next stable version, so you do not need to do anything apart from this.

magicus commented 10 months ago

And then of course, the million dollar question: Does it work?!?

Yes, I believe it does. I have just tested it for a few minutes, and it was always intermittently failing on 11.0, but now it seems to be just as stable as it was on 10.5. So I believe this fix indeed solves the problem. I guess it is safe to install the rc, but if you are unsure, stay on 10.5 and upgrade to 11.1 once it arrives.

Mats1717 commented 10 months ago

And then of course, the million dollar question: Does it work?!?

Yes, I believe it does. I have just tested it for a few minutes, and it was always intermittently failing on 11.0, but now it seems to be just as stable as it was on 10.5. So I believe this fix indeed solves the problem. I guess it is safe to install the rc, but if you are unsure, stay on 10.5 and upgrade to 11.1 once it arrives.

I can confirm it working for me to.

SweVictor commented 10 months ago

... but an open PR sent me on towards what the author thought was the upcoming thing, https://github.com/thomasloven/hass_plejd.

... Integration with HACS, cooperating with the built-in Bluetooth support instead of fighting with it.

Exactly this is something I've been thinking about as well. However, I'm not so sure we actually do "fight" home assistant. I would be interested in exploring this and/or if someone has any "proof" one way or the other (but if so in a separate ticket). Anyway, I don't think the note "hassio-plejd requires exclusive access to the BLE adapter" is 100% correct since I do have a couple of other BLE integrations working well side-by-side with this one...

SweVictor commented 10 months ago

Also confirmed on my side.

Closing as fixed by HAOS 11.1.RC1

oleost commented 10 months ago

Seeing that 11.1 is released now I assume it “safe” to update? IMG_2991

najs2000 commented 10 months ago

I can confirm it works on 11.1

On Thu, Oct 26, 2023 at 23:44, Ole-Petter @.***(mailto:On Thu, Oct 26, 2023 at 23:44, Ole-Petter < wrote:

Seeing that 11.1 is released now I assume it “safe” to update? Uploading IMG_2991.jpeg…

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>