Giter VIP home page Giter VIP logo

idasen's Introduction

idasen

PyPi Version Build Status Documentation Status Black

The IDÅSEN is an electric sitting standing desk with a Linak controller sold by ikea.

The position of the desk can controlled by a physical switch on the desk or via bluetooth using an phone app.

This is a command line interface written in python to control the Idasen via bluetooth from a desktop computer.

Set Up

Prerequisites

The desk should be connected to the computer.

Install

python3 -m pip install --upgrade idasen

Configuration

Configuration that is not expected to change frequently can be provided via a YAML configuration file located at ~/.config/idasen/idasen.yaml.

You can use this command to initialize a new configuartion file:

idasen init
mac_address: AA:AA:AA:AA:AA:AA
positions:
    sit: 0.75
    stand: 1.1

Configuartion options:

  • mac_address - The MAC address of the desk. This is required.
  • positions - A dictionary of positions with values of desk height from the floor in meters, sit and stand are provided as examples.

The program will try to discover the device address. The device needs to be in 'discover' mode for this to work.

If discovery fails the device MAC addresses can be found using blueoothctl and bluetooth adapter names can be found with hcitool dev on linux.

If the device has not yet been paired, this can be accomplished with:

idasen pair

Again, the device will need to be in 'discover' mode for this to work.

Usage

Command Line

To print the current desk height:

idasen height

To monitor for changes to height:

idasen monitor

To save the current height as the sitting position:

idasen save sit

To delete the saved sitting position:

idasen delete sit

Assuming the config file is populated to move the desk to sitting position:

idasen sit

Community

Related projects and packaging:

idasen's People

Contributors

abmantis avatar aklajnert avatar bachoseven avatar danielkza avatar dependabot[bot] avatar ftruzzi avatar lezuse avatar newam avatar sroebert avatar tjni avatar tommy-gilligan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

idasen's Issues

Desk is not connected automatically on command execution

Hi,
Thank you for this awesome program! I use it for about a year and I really can't live without it. I've integrated it with dmenu and use without even thinking about it - it's just like signal about need to change position goes straight from my body to hands and hands are typing right keyboard shortcut without even engaging my consciousness.
That leads my to my issue. From some of latest updates application does not automatically connect with my desk. I have to manually connect to desk via bluetooth after executing "idasen" command and only then position would be changed and laptop disconnected from desk afterwards. Without my interference program just hangs. It's really annoing. Do you have any idea what could be the source of this problem?
I use Arco linux with bluez-utils-compat.

Long execution time

Hey.

Thank you for great package. This issue isn't issue per se. I want to ask you guys how long is your execution time? I'm kind of worried because on my computer it takes around 20 seconds to execute a command, even if it's simple 'idasen height'. I can somehow live with that but I wonder if there is anything I can do to speed that up?

Thanks

Failed to connect when device is already connected

As per the Prerequisites

The desk should be connected and paired to the computer.

However, I was unable to execute a command until I specifically DISCONNECTED the device.

My theory: When f.e. executing bluetoothctl I'm directly on the desk already, so the script is likely trying to connect the desk with another device; instead of just doing its thing

As being connected already would avoid scanning & connecting; thus significantly reducing execution time (especially for simple commands) I'd propose to actually check if we're already connected, and just communicate directly in that case, instead of trying to scan & connect

OS: Ubuntu 20.04
bleak is using bluez as backend (in my case)
edit: regarding timing, a no-op (simple read) takes 4-5 seconds currently

Superfluous dependencies?

I dont fully understand several dependencies in the poetry build process and the installation.

Why are the following tools needed:
six <= code is pure python 3.8?
twisted <= code uses asyncio?
constantly
zope.interface
pyhamcrest
hyperlink
Automat - (but thank you for using this because it is quiet interesting :) )
attrs (same as automat)

Not that they are bad to have but diskspace and cpu power is sparse on a raspberry pi zero :)
I don't know anything about the internals on how poetry works so before messing around with it to maybe clean it up myself i just wanted to know if these attempts would be futile because above dependencies are there for nonobvious reasons?

Failed to install on a Raspberry Pi 4

Trying to run in on a Raspberry Pi 4
Python 3.9.1
pip 21.0.1

Output:

root@pi4:~ # python -V
Python 3.9.1
root@pi4:~ # pip -V
pip 21.0.1 from /root/.pyenv/versions/3.9.1/lib/python3.9/site-packages/pip (python 3.9)
root@pi4:~ # pip install --upgrade idasen
Collecting idasen
  Using cached idasen-0.6.0-py3-none-any.whl (8.5 kB)
Collecting pyyaml<6.0.0,>=5.3.1
  Using cached PyYAML-5.4.1.tar.gz (175 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting voluptuous<0.13.0,>=0.12.0
  Using cached voluptuous-0.12.1-py3-none-any.whl (29 kB)
Collecting bleak<0.10.0,>=0.9.0
  Using cached bleak-0.9.1-py2.py3-none-any.whl (110 kB)
Collecting txdbus
  Using cached txdbus-1.1.2.tar.gz (61 kB)
  Using cached txdbus-1.1.1.tar.gz (61 kB)
  Using cached txdbus-1.1.0-py2.py3-none-any.whl (44 kB)
Collecting six
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting txdbus
  Using cached txdbus-1.0.14.tar.gz (73 kB)
  Using cached txdbus-1.0.13.tar.gz (73 kB)
  Using cached txdbus-1.0.12.tar.gz (73 kB)
  Using cached txdbus-1.0.11.tar.gz (73 kB)
  Using cached txdbus-1.0.10.tar.gz (73 kB)
  Using cached txdbus-1.0.9.tar.gz (73 kB)
  Using cached txdbus-1.0.8.tar.gz (74 kB)
  Using cached txdbus-1.0.7.tar.gz (73 kB)
  Using cached txdbus-1.0.6.tar.gz (74 kB)
  Using cached txdbus-1.0.5.tar.gz (72 kB)
  Using cached txdbus-1.0.4.tar.gz (71 kB)
  Using cached txdbus-1.0.3.tar.gz (71 kB)
  Using cached txdbus-1.0.2.tar.gz (98 kB)
    ERROR: Command errored out with exit status 1:
     command: /root/.pyenv/versions/3.9.1/bin/python3.9 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-09dezgak/txdbus_fe8a0dce27f143d6aac17304e6885057/setup.py'"'"'; __file__='"'"'/tmp/pip-install-09dezgak/txdbus_fe8a0dce27f143d6aac17304e6885057/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-iz9iqog_                 
         cwd: /tmp/pip-install-09dezgak/txdbus_fe8a0dce27f143d6aac17304e6885057/                                                 
    Complete output (1 lines):                                                                                                   
    Missing requried dependency: Twisted                                                                                         
    ----------------------------------------                                                                                     
WARNING: Discarding https://files.pythonhosted.org/packages/cc/79/1ce9ed8e872fd2f3b288f55646d3f876dd0c4e7cd90a6593f7c080a13d46/txdbus-1.0.2.tar.gz#sha256=60c48892c7c1165b9effa1de5c23eb23fe3932604cfdbdd1c1a5b7533cc7990e (from https://pypi.org/simple/txdbus/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.                        
INFO: pip is looking at multiple versions of voluptuous to determine which version is compatible with other requirements. This could take a while.
Collecting voluptuous<0.13.0,>=0.12.0
  Using cached voluptuous-0.12.0-py3-none-any.whl (29 kB)
INFO: pip is looking at multiple versions of pyyaml to determine which version is compatible with other requirements. This could take a while.
Collecting pyyaml<6.0.0,>=5.3.1
  Using cached PyYAML-5.4.tar.gz (174 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
  Using cached PyYAML-5.3.1.tar.gz (269 kB)
INFO: pip is looking at multiple versions of bleak to determine which version is compatible with other requirements. This could take a while.
Collecting bleak<0.10.0,>=0.9.0
  Using cached bleak-0.9.0-py2.py3-none-any.whl (109 kB)
INFO: pip is looking at multiple versions of voluptuous to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of <Python from Requires-Python> to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of idasen to determine which version is compatible with other requirements. This could take a while.
Collecting idasen
  Using cached idasen-0.5.0-py3-none-any.whl (8.4 kB)
  Using cached idasen-0.4.0-py3-none-any.whl (8.0 kB)
  Using cached idasen-0.3.0-py3-none-any.whl (7.5 kB)
  Using cached idasen-0.2.1-py3-none-any.whl (7.2 kB)
  Using cached idasen-0.2.0-py3-none-any.whl (7.2 kB)
  Using cached idasen-0.1.0-py3-none-any.whl (7.2 kB)
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. If you want to abort this run, you can press Ctrl + C to do so. To improve how pip performs, tell us what happened here: https://pip.pypa.io/surveys/backtracking
INFO: pip is looking at multiple versions of pyyaml to determine which version is compatible with other requirements. This could take a while.
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. If you want to abort this run, you can press Ctrl + C to do so. To improve how pip performs, tell us what happened here: https://pip.pypa.io/surveys/backtracking
Collecting bleak<0.9.0,>=0.8.0
  Using cached bleak-0.8.0-py2.py3-none-any.whl (108 kB)
Collecting voluptuous<0.12.0,>=0.11.7
  Using cached voluptuous-0.11.7.tar.gz (45 kB)
INFO: pip is looking at multiple versions of bleak to determine which version is compatible with other requirements. This could take a while.
Collecting bleak<0.8.0,>=0.7.1
  Using cached bleak-0.7.1-py2.py3-none-any.whl (100 kB)
ERROR: Cannot install bleak because these package versions have conflicting dependencies.

The conflict is caused by:
    txdbus 1.1.2 depends on twisted>=10.1
    txdbus 1.1.1 depends on twisted>=10.1
    txdbus 1.1.0 depends on twisted>=10.1
    txdbus 1.0.14 depends on twisted>=10.1
    txdbus 1.0.13 depends on twisted>=10.1
    txdbus 1.0.12 depends on twisted>=10.1
    txdbus 1.0.11 depends on twisted>=10.1
    txdbus 1.0.10 depends on twisted>=10.1
    txdbus 1.0.9 depends on twisted>=10.1
    txdbus 1.0.8 depends on twisted>=10.1
    txdbus 1.0.7 depends on twisted>=10.1
    txdbus 1.0.6 depends on twisted>=10.1
    txdbus 1.0.5 depends on twisted>=10.1
    txdbus 1.0.4 depends on twisted>=10.1
    txdbus 1.0.3 depends on twisted>=10.1

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

Linak Bluetooth Adapter

Hi! I have a standing desk with a Linak controller, but it doesn't have bluetooth. However, I can buy an Bluetooth® Adapter BLE2LIN002 for it. Should it also work with this application? I am running Linux, so I'd like to know before I'm going to buy it. :)

Thank you!

DPG1C Linak controller not supported

Many people including myself have replaced the original Idasen Desk controller with the upgraded Linak DPG1C controller.

There is an issue when using it with the Home Assistant idasen_desk integration which uses this library though. After a number of hours, moving the desk no longer works, only the current height continues to show. Usually this can be fixed temporarily by disconnecting the controller from HA bluetooth, connecting it to the phone app, moving the desk using the official app to "wake it up again" and then disconnecting and reconnecting to HA.

This has recently been fixed in version 2.1.0 of the project that this one was forked from, rhyst/linak-controller project in rhyst/linak-controller#32

Could the same fix be added here so that it also supports the DPG1C controller please?

Possibility of unpinning requirements max version?

As mentioned a while ago, I am using this library as a dependency for an Home Assistant integration.
During review, the current pinning of dependencies (specially bleak) came up as a concern, as it would prevent Home Assistant to jump to the latest version of bleak without also updating this library (and the integration dependency version). See home-assistant/core#99173 (comment) for context.

Would it be OK to remove the upper version pinning? Do you have any other suggestion on how to solve this?
As an alternative last resort, I can also fork this to make it more friendlier to HA, but I would prefer not to.

Let me know your thoughts on this!

Python 3.8?

Hi,

I tried to install this package on a Raspbian PI system which only has Python 3.7 and get this error:
"Could not find a version that satisfies the requirement idasen (from versions: ) No matching distribution found for idasen"

Does this package only work for Python 3.8? If so, could it be made available for Python 3.7 as well?

Thx
Matthias

Tolerate misbehaving desks

Hi
I was getting really erratic behavior from this tool, so I added debug info on the _bytes_to_meters_and_speed function and the 2nd byte was always stuck at 0xff, basically reporting my desk was at ~7meters:

$ idasen height
['0x17', '0xff', '0x0', '0x0']
7.150 meters

After lowering my desk all the way to zero, it started reporting proper values and idasen starting behaving well again.
In the meantime, I had asked it to save my position with idasen save stand and it "corrupted" the configuration, by storing a 7m height.

I think that

  • there should be a warning by the tool if the second byte is 0xff
  • invalid heights shouldn't be saved to the config

App opens under other open programs

Whenever I click on the System Tray icon for the controller app, it opens below any already open apps, like a browser, meeting instance, etc. I then have to minimize whatever is open over the app in order to change desk heights.

Ideally, whenever the app is selected in the System Tray, it would open over any already open apps so we can select the height. Then when the desk reaches its designated height, we can minimize it back to the System Tray.

`idasen init` writes bad value for MAC

When I run idasen init I get

mac_address: !!python/object/apply:builtins.str
- D9F5C393-E014-5A2B-B16F-17883801C32E

written to config file. This then causes idasen to crash when I try to use it.

% idasen height                  
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/tom/idasen/idasen/cli.py", line 267, in main
    config = load_config()
             ^^^^^^^^^^^^^
  File "/Users/tom/idasen/idasen/cli.py", line 52, in load_config
    config = yaml.load(f, Loader=yaml.FullLoader)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/Library/Caches/pypoetry/virtualenvs/idasen-CkcHTofi-py3.11/lib/python3.11/site-packages/yaml/__init__.py", line 81, in load
    return loader.get_single_data()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/Library/Caches/pypoetry/virtualenvs/idasen-CkcHTofi-py3.11/lib/python3.11/site-packages/yaml/constructor.py", line 51, in get_single_data
    return self.construct_document(node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/Library/Caches/pypoetry/virtualenvs/idasen-CkcHTofi-py3.11/lib/python3.11/site-packages/yaml/constructor.py", line 60, in construct_document
    for dummy in generator:
  File "/Users/tom/Library/Caches/pypoetry/virtualenvs/idasen-CkcHTofi-py3.11/lib/python3.11/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
    value = self.construct_mapping(node)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/Library/Caches/pypoetry/virtualenvs/idasen-CkcHTofi-py3.11/lib/python3.11/site-packages/yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/Library/Caches/pypoetry/virtualenvs/idasen-CkcHTofi-py3.11/lib/python3.11/site-packages/yaml/constructor.py", line 143, in construct_mapping
    value = self.construct_object(value_node, deep=deep)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/Library/Caches/pypoetry/virtualenvs/idasen-CkcHTofi-py3.11/lib/python3.11/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tom/Library/Caches/pypoetry/virtualenvs/idasen-CkcHTofi-py3.11/lib/python3.11/site-packages/yaml/constructor.py", line 427, in construct_undefined
    raise ConstructorError(None, None,
yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/object/apply:builtins.str'
  in "/Users/tom/.config/idasen/idasen.yaml", line 2, column 14

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.