rhyst / linak-controller

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

Keep connection alive #12

Closed MeTimesThree closed 3 years ago

MeTimesThree commented 3 years ago

Hi,

is there a way to always keep the desk connected so that move-commands can be sped up?

Sadly I am using Windows 10, so I don't get the pickling-benefits.

rhyst commented 3 years ago

This person forked the repo to add a http interface: https://github.com/narthollis/idasen-controller

I think it'd need that or something similar so that you could set up the connection and keep it running but still accept commands.

That is a good idea for working around the lack of pickling. I might look into this but no promises :D

noxhirsch commented 3 years ago

Oh yes, keeping the connection alive would be a really great addition. At the moment it takes about 10 seconds on my Win10 machine before the desk starts moving (but it is moving - so thank you very much for this!). Maybe a socket connection is a good alternative to a http interface (https://stackoverflow.com/a/23149098). Then main.py could connect to the table in the background and for example command.py would send the commands.

rhyst commented 3 years ago

I've had a go at making a server to keep the connection alive on a branch server-test.

To use it start a server with: python3 main.py --server And then send commands with python3 main.py --forward --<command> where <command> is one of sit, stand, move-to.

Seems to work. On Windows it raises some random exceptions which I just catch and pass but it doesn't seem to care so 🤷

Let me know if this improves things for you.

noxhirsch commented 3 years ago

Wow, that was quick - thank you very much!

For me it works perfectly fine (just a few random exeptions as you said) The server also seems to handle unpluggin the Bluetooth usb stick and standby very well :)

EDIT: Forgot to mention: Now the desk is moving instantly 🚀

MeTimesThree commented 3 years ago

Here i am bothering with other repos instead of keeping track of this post. The new branch works brilliantly, thanks!