Herlix / homebridge-plejd

Homebridge plugin for Plejd
MIT License
1 stars 2 forks source link

Plejd not connecting to mesh network #15

Open helangen opened 1 month ago

helangen commented 1 month ago

Describe Your Problem:

I used to run Homebridge on my Raspberry Pi 2, Model B without issue. Now I am migrating the setup to my Intel NUC running Manjaro Linux and Homebridge in a container. I did a backup of the config and restored to the NUC. Now the Plejd won't connect to the mesh network like I use to see on the RasPi (see image uploaded). I get the "UpdateState | characteristic (null) or address (null) not found" issue which I assume is related to this mesh connection issue. I have checked that bluetooth is working.

Since I couldn't get it to work I decided to revert to my old setup, but now I experience the same issue there (not changing a thing). Except that I see that it connects to the mesh network. The only difference now is that I don't get the message "UpdateState....", but the state of the lamps still won't change.

I have tried to delete the plejd-bridge from Homekit and add it again, cleared cached devices, swapped bluetooth dongles, updating the plugin, updating node, and I also tried installing Homebridge directly (not via Docker) to see if this was an issue. Still, no dice.

How do I troubleshoot this issue? I really liked this plugin and don't want to buy the gateway.

EDIT: So I reinstalled the OS on the RasPi. Set up homebridge from scratch. Now its working. Is the Plejd network blocking previous installs somehow? Now I get multiple of these in the log running HB v1.8.4 and Plejd v1.4.6.

[8/13/2024, 11:00:47 AM] [Plejd] Unknown | command: 23f2 | id: 64 | 406e9723f2dd364394 [8/13/2024, 11:01:03 AM] [Plejd] Unknown | command: 23f2 | id: 121 | 796e9723f2dd25f494 [8/13/2024, 11:01:21 AM] [Plejd] Unknown | command: 23f2 | id: 111 | 6f6e9723f2dd0ac694 [8/13/2024, 11:02:14 AM] [Plejd] Unknown | command: 23fd | id: 111 | 6f6e9723fddc [8/13/2024, 11:02:15 AM] [Plejd] Unknown | command: 23fd | id: 111 | 6f6e9723fddd [8/13/2024, 11:02:16 AM] [Plejd] Unknown | command: 23fd | id: 111 | 6f6e9723fddc [8/13/2024, 11:02:16 AM] [Plejd] Unknown | command: 23f2 | id: 111 | 6f6e9723f2dd0ac694 [8/13/2024, 11:02:16 AM] [Plejd] Unknown | command: 23fd | id: 111 | 6f6e9723fddc [8/13/2024, 11:02:17 AM] [Plejd] Unknown | command: 23fd | id: 111 | 6f6e9723fddd [8/13/2024, 11:02:18 AM] [Plejd] Unknown | command: 23f2 | id: 111 | 6f6e9723f2dd0ac694 [8/13/2024, 11:02:28 AM] [Plejd] Unknown | command: 23fd | id: 106 | 6a6e9723fddd [8/13/2024, 11:02:29 AM] [Plejd] Unknown | command: 23f2 | id: 106 | 6a6e9723f2dd928494 [8/13/2024, 11:02:29 AM] [Plejd] Unknown | command: 23fd | id: 106 | 6a6e9723fddc [8/13/2024, 11:02:30 AM] [Plejd] Unknown | command: 23f2 | id: 106 | 6a6e9723f2dc928494 [8/13/2024, 11:02:37 AM] [Plejd] Unknown | command: 2371 | id: 96 | 606e9723719d42c0f215 [8/13/2024, 11:02:59 AM] [Plejd] Unknown | command: 23f2 | id: 127 | 7f6e9723f2dc928494 [8/13/2024, 11:03:00 AM] [Plejd] Unknown | command: 23f2 | id: 109 | 6d6e9723f2dc928494

Logs:

As above.

Plugin Config:

It is just the login information and site info.

Screenshots:

Environment:

Screenshot 2024-08-11 at 18 17 57
helangen commented 3 weeks ago

Update #2

So I figured I'd try again to setup Plejd again with my old setup. I restored my homebridge backup from the old RasPi to the same RasPi but now with the updated OS. And now Plejd works again on the old setup. Upgraded Plejd to v1.4.7 and still working. I still get the error messages listed in my original post with "Unknown ....", but the lights do switch on/off. I also wanted to switch the BT dongle som I swapped them on the RasPi. Then the lights do not respond anymore and I do not get the message that the Homebridge is connected to the Plejd mesh network. I only get that it has discovered the mesh network.

So it seems that swapping the BT dongle on the same setup doesn't play nice. I would still like to migrate this whole setup to my NUC though so any thoughts how to fix this is appreciated.

Herlix commented 3 weeks ago

Hi!

I'm looking into the connection issues. Lately i've had the same issues and i'm investigating.

For me it works for a while then it stops working sporadically. I don't seem to get a hand at the issue. It's never popping up during development.

I'll see if I can have a look at it and solve it soon. I have not had time to investigate properly.

Thanks for the notes, they'll help 😊

I can ofc backtrack to see if a previous version works out of the box and take it from there. I know i had to update the ble lib at some point due to install issues.

Herlix commented 3 weeks ago

Don't forget to install the base dependencies on the host machine. I think they are located in the readme of this project or at least in @abandonware/noble which is the one and only dependency of this project.

I have not looked into other solutions.

helangen commented 3 weeks ago

I have installed the base dependencies on the NUC and «bluetoothctl show» says it is working. Do you have an idea why it doesn’t connect to the mesh network? It is the same config and same BT dongle, but just another host OS. The containers are identical. Do you know of any security policies in Plejd that could block it. I feel like I’ve tried everything.

Herlix commented 3 weeks ago

The latest release has some major refactorings done and I seem to have solved a connection issue, at least on a non-dockerized install on my rpi4.

I'll look into docker again to see if it works.

I don't have a nuc atm but I might be able to able to set one up if i can borrow one from work 😊

helangen commented 3 weeks ago

I just tried installing the new Plejd plugin v1.5.0 in a new container in Docker on the NUC. It doesn't load devices even. Nothing happens.

Herlix commented 3 weeks ago

Right. This is another issue than the stability issue I've been looking into. It would be fun to see if it finds anything at all. Does the device have BLE capabilities?

Can you scan for devices separately using something like bluetoothctl or if you have a GUI setup?

helangen commented 3 weeks ago

How do I find out if it does? It is a TP-Link UB5A (https://www.tp-link.com/uk/home-networking/adapter/ub5a/). I use CLI so it have to be bluetoothctl. I can try scanning for my phone e.g.

EDIT: Yes, it discovers my TV and I can discover the adapter via my phone

helangen commented 3 weeks ago

I can't see any installation instructions for noble BLE for Arch Linux which Manjaro is based on. Only Debian-based and Fedora-based. It seems strange that it shouldn't support Arch Linux though.

Herlix commented 3 weeks ago

Have you installed bluez bluez-libs bluez-libs-devel ?

helangen commented 3 weeks ago

Have you installed bluez bluez-libs bluez-libs-devel ?

I have installed bluez and some other packages related to bluetooth, bluez. The bluez-libs-devel is not in Arch Linux

EDIT: Might be just easier switching to a Debian-based distro on the NUC to see if it is Arch Linux-related problem or not.

Herlix commented 3 weeks ago

Sure you could try debian.

Though if you can scan using your host system, are we sure docker gets BLE access?

Are you running as privileged?

helangen commented 3 weeks ago

Sure you could try debian.

Though if you can scan using your host system, are we sure docker gets BLE access?

Are you running as privileged?

I am running the container as privileged and network: host. Yeah, I thought maybe the Docker/BLE access was an issue in the start, but I use exactly the same compose file for the RasPi as the NUC. But Arch can be troublesome at times.

Herlix commented 3 weeks ago

At this point, it does not connect at all? You're not getting the Unknown command error?

Sorry for being a bit distracted. I saw you're earlier commend about the can working fine.

helangen commented 3 weeks ago

At this point, it does not connect at all? You're not getting the Unknown command error?

Sorry for being a bit distracted. I saw you're earlier commend about the can working fine.

No, It just says loading payload and that's it. I doesn't state discovering mesh or connecting mesh. The log is just empty.

helangen commented 3 weeks ago

Sure you could try debian.

Though if you can scan using your host system, are we sure docker gets BLE access?

Are you running as privileged?

I also already tried running Homebridge on the host and not via Docker. Still not working, so probably not an issue with BT and Docker.

Herlix commented 3 weeks ago

Maybe it would be worth if for me to try to set it up on arch/manjaro too. Though I'm glad you're able to look into it.

If there are no logs at all it means that the ble lib is not throwing anything either. Which makes it a bit harder to debug.

Have you added the -D flag in homebridge settings?

helangen commented 3 weeks ago

Maybe it would be worth if for me to try to set it up on arch/manjaro too. Though I'm glad you're able to look into it.

If there are no logs at all it means that the ble lib is not throwing anything either. Which makes it a bit harder to debug.

Have you added the -D flag in homebridge settings?

Unsure if i did.

I re-installed Ubuntu 24.04 just now and spun up a fresh container with homebridge. First tried the TP Link BT dongle. No dice. REmoved the container and config. Started fresh again with a the BT dongle on the RasPi. No dice. Same problem as before. Not showing anything after "Setting up payload".

I started with -D and I just see Plejd adding the accessories, but thats it.

I do think its weird that the BT dongle works with the same config/setup in Docker on the RasPi but not a fresh install of Ubuntu. Both Debian based.

Herlix commented 3 weeks ago

Your Rpi should work after a sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev. I have mine running locally atm. Will migrate to docker again to test this out. This is ofc a Should.

It prints Using login information to fetch devices & crypto key with no errors after?

just to make sure that part works.

helangen commented 3 weeks ago

Maybe it would be worth if for me to try to set it up on arch/manjaro too. Though I'm glad you're able to look into it. If there are no logs at all it means that the ble lib is not throwing anything either. Which makes it a bit harder to debug. Have you added the -D flag in homebridge settings?

Unsure if i did.

I re-installed Ubuntu 24.04 just now and spun up a fresh container with homebridge. First tried the TP Link BT dongle. No dice. REmoved the container and config. Started fresh again with a the BT dongle on the RasPi. No dice. Same problem as before. Not showing anything after "Setting up payload".

I started with -D and I just see Plejd adding the accessories, but thats it.

Your Rpi should work after a sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev. I have mine running locally atm. Will migrate to docker again to test this out. This is ofc a Should.

It prints Using login information to fetch devices & crypto key with no errors after?

just to make sure that part works.

Yeah, thats the last of the log. I just tried restoring the current config/setup from Homebridge on the Pi to the NUC. Still doesn't work. So I figure there has to be a problem with the NUC and BT. Since I already tried two different OS and two different BT dongles.

The RasPi works flawlessly with my Asus BT dongle. Never go the TP Link dongle to work with the RasPi

Herlix commented 3 weeks ago

Right. The devices that you find, are they BLE?

Usually, you'll find loads of BLE beacons when you look for them with a scanner.

Herlix commented 3 weeks ago

I mean on amazon it says that your device should have BLE so this is not the issue here.

Herlix commented 3 weeks ago

Have you checked out this: https://github.com/abandonware/noble?tab=readme-ov-file#running-without-rootsudo-linux-specific ? ?

helangen commented 3 weeks ago

Have you checked out this: https://github.com/abandonware/noble?tab=readme-ov-file#running-without-rootsudo-linux-specific ? ?

Yeah, but hte container runs as sudo so that should no be an issue. I can even control the BT without using sudo.

helangen commented 3 weeks ago

I mean on amazon it says that your device should have BLE so this is not the issue here.

No, I have no clue why it just doesn't work on Ubuntu in Docker. It runs fine on RasPi Debian in Docker without issues.

Herlix commented 3 weeks ago

I mean on amazon it says that your device should have BLE so this is not the issue here.

No, I have no clue why it just doesn't work on Ubuntu in Docker. It runs fine on RasPi Debian in Docker without issues.

But the dongle did not work on rpi right?

helangen commented 3 weeks ago

I mean on amazon it says that your device should have BLE so this is not the issue here.

No, I have no clue why it just doesn't work on Ubuntu in Docker. It runs fine on RasPi Debian in Docker without issues.

But the dongle did not work on rpi right?

No, the TP Link BT dongle I can't get working on the RasPi. But the ASUS BT dongle (BT400) works on the RasPi, but not on the NUC.

Herlix commented 2 weeks ago

I might be able to purchase a dongle and try this out. We'll see if i pass by a kjell&Company or something similar this weekend.

I do believe it has to do with the base setup.

the default one it looks for is: hci0

Herlix commented 2 weeks ago

I've bought the UB500, it's supposed to be the same product according to TP link

helangen commented 2 weeks ago

I might be able to purchase a dongle and try this out. We'll see if i pass by a kjell&Company or something similar this weekend.

I do believe it has to do with the base setup.

the default one it looks for is: hci0

I am pretty sure I checked that it was set up as hci0

helangen commented 2 weeks ago

I've bought the UB500, it's supposed to be the same product according to TP link

Let me know. I returned mine as I couldn't get it working on the RasPi or the NUC