rhyst / linak-controller

A Python script to control Linak standing desks.
MIT License
359 stars 50 forks source link

Add REST API #78

Closed voruti closed 1 year ago

voruti commented 1 year ago

Just found a bug: After moving, the desk disconnects, so this is still too bugged. In the end I know Python too little...

rhyst commented 1 year ago

I think this is probably going a little beyond the scope of this project anyway. I think the existing server mode is probably sufficient for most use cases.

voruti commented 1 year ago

I did this (and still am doing this on a private branch), because most of my services are REST based and I want to control my desk with my smart home setup (https://github.com/openhab), from which it's quite hard/laborious to create raw TCP or websocket requests. Solutions like https://github.com/rhyst/linak-controller/blob/ceb58fa6ff139e48c7a1dbcc75e99b605d80a7bf/README.md?plain=1#L134 also are quite suboptimal, because depending on the choosen timeout request may never get through or add quite the delay to everything (even 1 second is quite some time).

rhyst commented 1 year ago

I just pushed 1.2.0-dev. This allows you to use HTTP post to send the config object:

curl -X POST http://127.0.0.1:9123 --data '{"command": "move_to", "move_to": 640}'

Does that work for you?

voruti commented 1 year ago

Works like a charm