rhyst / linak-controller

A Python script to control Linak standing desks.
MIT License
355 stars 52 forks source link

Locking computer stops table from moving #57

Closed Slade01202 closed 11 months ago

Slade01202 commented 1 year ago

First of all, thank you for this script.

I use KDE running on Manjaro as well as the Linak DPG1C. The script runs fine until I lock my PC. After locking and unlocking, executing the script produces the following output:

Connected EA:69:XX:CE:XX:9C
Height:  641mm
Moving to favourite height: stand
Height:  641mm Speed:  0mm/s
Final height:  641mm (Target: 1116mm)
Disconnected 

I have only been able to fix it by connecting the phone app to my desk, moving it a centimeter, disconnecting, and executing the script again:

Connected EA:69:XX:CE:XX:9C
Height:  641mm
Moving to favourite height: stand
Height:  644mm Speed: 25mm/s
Height:  660mm Speed: 61mm/s
Height:  681mm Speed: 62mm/s
Height:  706mm Speed: 62mm/s
Height:  728mm Speed: 62mm/s
Height:  750mm Speed: 62mm/s
Height:  772mm Speed: 62mm/s
Height:  796mm Speed: 62mm/s
Height:  818mm Speed: 62mm/s
Height:  839mm Speed: 62mm/s
Height:  862mm Speed: 62mm/s
Height:  886mm Speed: 62mm/s
Height:  911mm Speed: 62mm/s
Height:  934mm Speed: 62mm/s
Height:  957mm Speed: 62mm/s
Height:  978mm Speed: 62mm/s
Height: 1001mm Speed: 62mm/s
Height: 1022mm Speed: 62mm/s
Height: 1045mm Speed: 62mm/s
Height: 1068mm Speed: 62mm/s
Height: 1091mm Speed: 62mm/s
Height: 1114mm Speed: 62mm/s
Height: 1116mm Speed:  0mm/s
Final height: 1116mm (Target: 1116mm)
Disconnected
rhyst commented 1 year ago

If you lock and then unlock and then re-pair with the desk without using the phone, does that also fix it? Or not?

Slade01202 commented 1 year ago

Yes, that doesn't work either, unfortunately.

rhyst commented 1 year ago

What about if you restart your computer? Is it just locking that causes this issue?

And do you happen to have a second device to test with? I.e. does it work if you run run idasen controller on some other device rather than using the phone?

mensfeld commented 1 year ago

Similar issue here. Same solution: I can only get it back to work if I connect with my phone, move it a bit and then unpair the phone and connect to idasen back again

mensfeld commented 1 year ago
Received command
Height:  762mm
Moving to height: 730
Height:  762mm Speed:  0mm/s
Final height:  762mm (Target:  730mm)

never moves

rhyst commented 1 year ago

What about if you restart your computer?

And do you have a second device to test with? I.e. does it work if you run run idasen-controller on some other device rather than using the phone?

mensfeld commented 1 year ago

What about if you restart your computer?

Didn't help. What i noticed, is that it does not respond to action commands (move up, move down) but the position and speed can be read without any issues.

The only other device I have at the moment is my phone I use to "unblock" the desk.

I am using Ubuntu and my Bluetooth adapter has a second device (headphones) connected to it in a multi profile mode.

It seems, like my desk is ignoring the commands for any reason (write pace or something else). I will try getting a second bluettoh dongle and check if a single device - single connection via independent Bluetooth adapters help here.

mensfeld commented 1 year ago

Yeah, it just seems to ignore the action commands (move, stop) but it does not ignore the status command (height / speed)

rhyst commented 1 year ago

That is quite strange. Both reading characteristics (height/speed) and writing characteristics (commands like move) are both just BLE requests to the desk so if reading works then the controller is connected and capable of communicating with the desk.

It suggests that somehow something happens to the desk when you lock your computer vs when you shut it down. I don't think there should be any communication between the desk and computer at that point so I don't know what is going on.

Some other questions if you are willing:

Trying to work out if your computer is maintaining some sort of connection to the desk while it is paired and locking messes it up somehow. Otherwise I don't know how the desk would "know" that your computer had been locked.

mensfeld commented 1 year ago
  1. Ubuntu 20.04
  2. Server mode. After long inactivity and lock screen. I don't think that "locking" does that per se but rather something related to 3. IMHO power management on ubuntu USB. I disabled the USB suspend from Bluetooth and we will see once I have time to get back to this.
  3. I don't use a laptop :( sorry

Otherwise I don't know how the desk would "know" that your computer had been locked.

I don't think it's that. I think it's related to some sort of a faulty communication when Bluetooth is switched via USB suspend or something similar.

I also consider it weird because I can read position and I can observe it and speed when moving the desk manually.

I wonder if the wake up command is not sufficient / not fully waking up but :shrug:

mensfeld commented 1 year ago

I disabled USB suspend and after a full restart I'm certain there's something "extra" that needs to be sent to the desk to activate it back.

rhyst commented 1 year ago

Does this happen if you don't use the server mode?

rhyst commented 1 year ago

Also what happens if you restart the idasen-controller server after locking? Do the move commands till fail?

mensfeld commented 1 year ago

Also what happens if you restart the idasen-controller server after locking? Do the move commands till fail?

Yes

Does this happen if you don't use the server mode?

It happened to me once when it was NOT in the server mode. I will do my best to get a reproducibility here.

rhyst commented 1 year ago

It makes more sense if this is an issue with the server mode as that does maintain a persistent connection so I can imagine that somehow messing up due to locking/power saving things. Would be interested to know if you can reproduce in non server mode.

Also I disabled the USB suspend from Bluetooth - let me know if that improves things and I could add it to the readme.

I'm seeing if I can reproduce on Windows as well (now that I know its more likely a server mode issue).

mensfeld commented 1 year ago

Sure. I will keep you posted. For now I did few things:

  1. I disabled the USB suspend completely via kernel, so it does not switch the Bluetooth dongle off / low power.
  2. I disabled the wakeup command in the script "just to see" what will happen.
  3. I set up probing of the server process to get the desk status once every minute - just to see if having a constant (one time a minute) ping to the desk makes things better.
mensfeld commented 1 year ago

Didn't help. During the night it went down. That is, it started returning height 0 and then it started returning height 9123 :D my script pings it every minute. Will unlock and switch to a non-server mode and see what will happen then.

mensfeld commented 1 year ago

I also don't think it's "locking" that causes this but it seems to be more related to persistent Bluetooth connection maybe or something like this.

Switched to non-server mode, we will see how it goes. I still track the metrics so it should operate ok.

mensfeld commented 1 year ago

Same thing happens despite disconnecting working:

Moving the desk down in 15 seconds
Connected E6:8E:71:B5:6B:FD
Height: 1236mm
Moving to height: 750
Height: 1236mm Speed:  0mm/s
Final height: 1236mm (Target:  750mm)

no movement at all

rhyst commented 1 year ago

How are you running idasen-controller ? Can you post the exact command/script?

mensfeld commented 1 year ago

nothing fancy just moving up and down.

idasen-controller --move-to 750

now as it is stuck, if I pair it with my phone, unpair it, pair it with the computer, it can move like nothing happened. I still can get the position though with --watch :shrug:

It's like the desk decides "ok, this Bluetooth device was moving me or sampling me too much, won't allow it to move the desk anymore'

mensfeld commented 1 year ago

ref https://github.com/alex20465/deskbluez/issues/7

rhyst commented 11 months ago

@mensfeld does the DPGC1 update also fix this issue?

rhyst commented 11 months ago

Fixed by DPC1 updates (reopen if that is not the case)

mensfeld commented 11 months ago

@rhyst it does fix the issue :)