Unable to setup xiaomi remote_ir

Hey im trying to setup the xiaomi ir-remote i used this guide:

but i got my tokken with the MiToolkit 1.6

my configuration.yaml files:

switch: !include yaml_includes/switch.yaml

switch.yaml:

  - platform: chuangmi_ir
    name: "irremote"
    host: !secret chuangmi_ip
    token: !secret chuangmi_key
    switches:
      wcfan:
        name: 'wcfan'
        command_on: 'Z6VLA'
        command_off: 'Z6VHA' 

but i get the following error:

> 2017-12-25 21:23:37 ERROR (SyncWorker_5) [homeassistant.util.package] Unable to install package python-miio==0.3.0: Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3cnd2omo/cryptography/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-wi7mu27a-record/install-record.txt --single-version-externally-managed --prefix  --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-3cnd2omo/cryptography/
> 2017-12-25 21:23:37 ERROR (MainThread) [homeassistant.setup] Not initializing switch.chuangmi_ir because could not install dependency python-miio==0.3.0
> 2017-12-25 21:23:37 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform switch.chuangmi_ir: Could not install all requirements.

i tried to install all of the tools one by one but i get this error:
Could not find a version that satisfies the requirement changmi_ir.py (from versions: )
No matching distribution found for changmi_ir.py

what am i missing? anyone know how i could solve this? im useing hassio 0.60 and windows 10

I think it’s caused by requirement … Actual python-miio = 0.3.2 or even 0.3.3 u might want to change this in REQUIREMENTS = [‘python-miio==0.3.0’] . make a “pip3 list” in your has env and watch your python-miio version. But I dunno if this would break the component .

hey thanks for your repley but it made no change now my error log looks like this:

> 2017-12-26 12:55:49 ERROR (SyncWorker_10) [homeassistant.util.package] Unable to install package python-miio==0.3.3: Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mj7ezl0i/cryptography/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-pwjaem8o-record/install-record.txt --single-version-externally-managed --prefix  --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-mj7ezl0i/cryptography/
> 2017-12-26 12:55:49 ERROR (MainThread) [homeassistant.setup] Not initializing switch.chuangmi_ir because could not install dependency python-miio==0.3.3
> 2017-12-26 12:55:49 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform switch.chuangmi_ir: Could not install all requirements.

What install method? Venv? Be sure u install python-miio in the virtual env if has is also installed in those

I tried it with cmd as admin with python 3.6 installed and this error i get by just restarting hassio
Virtual env whats that?

Okay, I got the exact same thing, so let’s figure this out together. I’m also quite a noob, I had a Unix starter course some 15 years ago, and I have only occasionally used it with Telnetting stuff.
I’m running 0.59.2 on a DietPi OS on a Pine64 machine. Hass runs in a virtual environment, which I setup using the guides provided.

These are my errors :

2017-12-27 22:06:59 ERROR (Thread-4) [homeassistant.util.package] Unable to install package python-miio==0.3.0: Command "/srv/homeassistant/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mhkd8lkv/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-u6sq4294-record/install-record.txt --single-version-externally-managed --compile --install-headers /srv/homeassistant/include/site/python3.4/cffi" failed with error code 1 in /tmp/pip-build-mhkd8lkv/cffi/
2017-12-27 22:06:59 ERROR (MainThread) [homeassistant.setup] Not initializing switch.chuangmi_ir because could not install dependency python-miio==0.3.0
2017-12-27 22:06:59 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform switch.chuangmi_ir: Could not install all requirements.

I am guessing, since the 1st error complains about not being able to install miio, that it has first checked if miio is already installed. Since it apparently wasn’t , it tries to install it. Else miio would need to be installed everytime the Home Assistant restarts, which makes no sense to me, as it would be a lot of overhead.

So, based on this assumption, I guess we need to figure out how to install miio in our environments ?

Okay, so I found this post describing a similar problem :

And a solution :

So, when logged into telnet from root I gave the first command

su - homeassistant

This gave me a $=sign prompt
Then I did

$ source /srv/homeassistant/bin/activate

but that gave an error :

-su: 1: source: not found

but I continued with

$ pip3 install -U setuptools
Downloading/unpacking setuptools from https://pypi.python.org/packages/4c/00/19a d1da0869e6699577d90ea843325036952015f924fc8488d181c140729/setuptools-38.2.5-py2. py3-none-any.whl#md5=f901fdbfffaa488aa93afd860235b15a
Downloading setuptools-38.2.5-py2.py3-none-any.whl (489kB): 489kB downloaded
Installing collected packages: setuptools
Found existing installation: setuptools 5.5.1
Not uninstalling setuptools at /usr/lib/python3/dist-packages, owned by OS
Can’t roll back setuptools; was not uninstalled
Cleaning up…
Exception:
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/pip/basecommand.py”, line 122, in main
status = self.run(options, args)
File “/usr/lib/python3/dist-packages/pip/commands/install.py”, line 295, in ru n
requirement_set.install(install_options, global_options, root=options.root_p ath)
File “/usr/lib/python3/dist-packages/pip/req.py”, line 1436, in install
requirement.install(install_options, global_options, *args, **kwargs)
File “/usr/lib/python3/dist-packages/pip/req.py”, line 672, in install
self.move_wheel_files(self.source_dir, root=root)
File “/usr/lib/python3/dist-packages/pip/req.py”, line 902, in move_wheel_file s
pycompile=self.pycompile,
File “/usr/lib/python3/dist-packages/pip/wheel.py”, line 214, in move_wheel_fi les
clobber(source, lib_dir, True)
File “/usr/lib/python3/dist-packages/pip/wheel.py”, line 208, in clobber
shutil.copy2(srcfile, destfile)
File “/usr/lib/python3.4/shutil.py”, line 244, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File “/usr/lib/python3.4/shutil.py”, line 108, in copyfile
with open(dst, ‘wb’) as fdst:
PermissionError: [Errno 13] Permission denied: ‘/usr/local/lib/python3.4/dist-pa ckages/easy_install.py’
Storing debug log for failure in /home/homeassistant/.pip/pip.log

So , seems to do something, although with some errors.
I continued with:

$ pip3 install python-miio
Downloading/unpacking python-miio
Downloading python_miio-0.3.3-py3-none-any.whl (51kB): 51kB downloaded
Downloading/unpacking cryptography (from python-miio)
Downloading cryptography-2.1.4.tar.gz (441kB): 441kB downloaded
Running setup.py (path:/tmp/pip-build-qbfbequ2/cryptography/setup.py) egg_info for package cryptography
error in cryptography setup command: Invalid environment marker: python_version < ‘3’
Complete output from command python setup.py egg_info:
error in cryptography setup command: Invalid environment marker: python_version < ‘3’


Cleaning up…
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-qbfbequ2/cryptography
Storing debug log for failure in /home/homeassistant/.pip/pip.log

So, I noticed it tried to install miio 0.3.3 and not 0.3.0
Then I did a “pip3 list” to see what was there, I expected to see the miio, but it wasn’t there.

So I continued to adjust the “chuangmi_ir.py” miio version to 0.3.3, cause in my mind that made sense. Then restarted the homeassistant. Waited…

And BOOOOM… same error…

I have a feeling I am on the right track, but a nudge would be nice.

@syssi perhaps ?

Please wait a few days. The dependency chain (HA → python-miio → construct) of HA 0.60 combines incompatible libraries. The fix will be part of the next release. Please cp.

okay, I did some more fiddling, as I thought the error must be because I was not in the vitual environment when manually installing miio.

So I did the following :

telnet into hass and login as root
cd … (as I do not login to the root directory it seems, and therefor does not recognize the /srv/homeassistant path later on)

apt-get install libffi-dev libssl-dev
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/bin/activate
pip3 install -U setuptools
pip3 install python-miio

No errors, and yes, the requirement is still set to miio=0.3.3

1 Like

python-miio 0.3.3 will be part of the next HA release. HA 0.60 comes with 0.3.2.

1 Like