Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homekit broken on ipython 2.7 due to asyncio #7

Closed
GiantMolecularCloud opened this issue Jul 24, 2018 · 5 comments
Closed

Homekit broken on ipython 2.7 due to asyncio #7

GiantMolecularCloud opened this issue Jul 24, 2018 · 5 comments

Comments

@GiantMolecularCloud
Copy link

The homekit compatibility is missing a dependency on asyncio:

co2meter_server_homekit -H 192.168.200.100 -P 8000 -N co2
Traceback (most recent call last):
  File "/usr/local/bin/co2meter_server_homekit", line 11, in <module>
    sys.exit(start_server_homekit())
  File "/usr/local/lib/python2.7/dist-packages/co2meter/co2meter.py", line 433, in start_server_homekit
    start()
  File "/usr/local/lib/python2.7/dist-packages/co2meter/server.py", line 342, in start_server_homekit
    from homekit import PORT
  File "/usr/local/lib/python2.7/dist-packages/co2meter/homekit.py", line 9, in <module>
    from pyhap.accessory_driver import AccessoryDriver
  File "/home/pi/.local/lib/python2.7/site-packages/pyhap/accessory_driver.py", line 24, in <module>
    import asyncio
ImportError: No module named asyncio

However, manually installing asyncio (sudo pip install asyncio) on a RPI3B+ also does not work:

co2meter_server_homekit -H 192.168.200.100 -P 8000 -N co2
Traceback (most recent call last):
  File "/usr/local/bin/co2meter_server_homekit", line 11, in <module>
    sys.exit(start_server_homekit())
  File "/usr/local/lib/python2.7/dist-packages/co2meter/co2meter.py", line 433, in start_server_homekit
    start()
  File "/usr/local/lib/python2.7/dist-packages/co2meter/server.py", line 342, in start_server_homekit
    from homekit import PORT
  File "/usr/local/lib/python2.7/dist-packages/co2meter/homekit.py", line 9, in <module>
    from pyhap.accessory_driver import AccessoryDriver
  File "/home/pi/.local/lib/python2.7/site-packages/pyhap/accessory_driver.py", line 24, in <module>
    import asyncio
  File "/usr/local/lib/python2.7/dist-packages/asyncio/__init__.py", line 9, in <module>
    from . import selectors
  File "/usr/local/lib/python2.7/dist-packages/asyncio/selectors.py", line 39
    "{!r}".format(fileobj)) from None
                               ^
SyntaxError: invalid syntax

There is probably no fix to this bug as the asyncio port on 2.7 is not maintained anymore: trollius project on github
Also, the trollius port is not a complete replacement and asyncio is Python 3.4+ only. So co2meter_homekit requires python3 to run.

@GiantMolecularCloud
Copy link
Author

After installing co2meter into python3.5 I get these errors instead:

> co2meter_homekit
Traceback (most recent call last):
  File "/usr/local/bin/co2meter_homekit", line 11, in <module>
    sys.exit(start_homekit())
  File "/usr/local/lib/python3.5/dist-packages/co2meter/co2meter.py", line 422, in start_homekit
    from .homekit import start_homekit as start
  File "/usr/local/lib/python3.5/dist-packages/co2meter/homekit.py", line 10, in <module>
    from pyhap.accessory import Accessory, Category
ImportError: cannot import name 'Category'

and

> co2meter_server_homekit
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/co2meter/server.py", line 339, in start_server_homekit
    from .homekit import PORT
  File "/usr/local/lib/python3.5/dist-packages/co2meter/homekit.py", line 10, in <module>
    from pyhap.accessory import Accessory, Category
ImportError: cannot import name 'Category'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/co2meter_server_homekit", line 11, in <module>
    sys.exit(start_server_homekit())
  File "/usr/local/lib/python3.5/dist-packages/co2meter/co2meter.py", line 433, in start_server_homekit
    start()
  File "/usr/local/lib/python3.5/dist-packages/co2meter/server.py", line 342, in start_server_homekit
    from homekit import PORT
ImportError: No module named 'homekit'

@vfilimonov
Copy link
Owner

To be honest I have not tested it under Python 2.7. It very well could be that some libraries might not be compatible :-( And under Python 3 I don't remember any issues with installation of homekit..
Just checked history - it does not look like I needed much beyond pip install HAP-python

Just in case my setup is:

  • Raspbian Stretch 9 (Linux raspberrypi 4.9.59-v7+)
  • Python 3.5
  • HAP-python (1.1.5)
  • hidapi (0.7.99.post21)
  • Cython (0.27.3)
  • Flask (0.12.2)
  • pandas (0.22.0)

@GiantMolecularCloud
Copy link
Author

Thanks for your help!
This might be related to related to newer versions of some modules. An installation on Raspbian Stretch 9 (4.14.52-v7+) for python 3.5 this week (23 June 2018) gets these versions:

  • HAP-python (2.2.2)
  • hidapi (0.7.99post21)
  • cython (0.28.4)
  • flask (1.0.2)
  • pandas (0.23.3)
    Once I have the time, I will try to find a solution.

@GiantMolecularCloud
Copy link
Author

Success! Homekit works with HAP-python 1.1.5 instead of 2.2.2
Could you please add that co2meter requires version 1.1.5 of HAP-python?

@vfilimonov
Copy link
Owner

Great, I'm glad that it worked and thank you for the figuring it out, @GiantMolecularCloud !
I have added the version to the Readme.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants