The homeassistant api for services has changed. I will update the component!
Could you please post your configuration.yaml. The code of the custom component looks good. I assume your configuration doesn’t looks like this:
switch:
- platform: chuangmi_ir
name: "livingroomirremote"
host: !secret chuangmi_ip
token: !secret chuangmi_key
switches:
tv:
command_on: ''
command_off: ''
Looks exactly like that. Problems started when updated to 0.61.
Will wait for the update of the component.
Alright. I found the issue. Please update your custom component:
Nice work! Works great.
But command is switch.send_command_192_xxx
Maybe it would be more convenient if it was switch.chuangmi_send_command_192_xxx
If one use different IR platforms
You are totally right. I will refactor the code soon.
I updated the component and I get this error.
Error while setting up platform chuangmi_ir
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 171, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
raise self._exception
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/switch/chuangmi_ir.py", line 64, in setup_platform
from miio import ChuangmiIr, DeviceException
File "/usr/lib/python3.6/site-packages/miio/__init__.py", line 2, in <module>
from miio.protocol import Message, Utils
File "/usr/lib/python3.6/site-packages/miio/protocol.py", line 21, in <module>
from construct import (Struct, Bytes, Const, Int16ub, Int32ub, GreedyBytes,
File "/config/deps/lib/python3.6/site-packages/construct/__init__.py", line 22, in <module>
from construct.core import *
File "/config/deps/lib/python3.6/site-packages/construct/core.py", line 11, in <module>
from construct.lib import *
File "/config/deps/lib/python3.6/site-packages/construct/lib/__init__.py", line 3, in <module>
from construct.lib.bitstream import RestreamedBytesIO, RebufferedBytesIO
ImportError: cannot import name 'RestreamedBytesIO'
This is my config file:
switch:
- platform: chuangmi_ir
name: Mi Remote
host: !secret chuangmi_ip
token: !secret chuangmi_key
timeout: 20
switches:
projector:
command_on: Z6VLAAkCAABpAgAAYgYAAKYIAACJEQAAoSMAAKScAABYeQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFAQEBAQEBAQEhISEhISEhIQEBISEBAQEBISEBASEhISFhNXE1AQ
command_off: Z6VHAPEBAACBAgAASQYAAIYIAABqEQAAySMAAECcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFAQEBAQEBAQEhISEhISEhIQEBASEhAQEBISEhAQEhISFhNQE
Name: not between " " ?
Nope, doesn’t make a difference. @syssi This is my error:
Log Details (ERROR)
Sun Jan 21 2018 19:23:02 GMT+0100 (W. Europe Standard Time)
Error while setting up platform chuangmi_ir
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 171, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
raise self._exception
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/switch/chuangmi_ir.py", line 64, in setup_platform
from miio import ChuangmiIr, DeviceException
File "/usr/lib/python3.6/site-packages/miio/__init__.py", line 2, in <module>
from miio.protocol import Message, Utils
File "/usr/lib/python3.6/site-packages/miio/protocol.py", line 21, in <module>
from construct import (Struct, Bytes, Const, Int16ub, Int32ub, GreedyBytes,
File "/config/deps/lib/python3.6/site-packages/construct/__init__.py", line 22, in <module>
from construct.core import *
File "/config/deps/lib/python3.6/site-packages/construct/core.py", line 11, in <module>
from construct.lib import *
File "/config/deps/lib/python3.6/site-packages/construct/lib/__init__.py", line 3, in <module>
from construct.lib.bitstream import RestreamedBytesIO, RebufferedBytesIO
ImportError: cannot import name 'RestreamedBytesIO'
config:
switch:
- platform: chuangmi_ir
name: "Mi Remote"
host: !secret chuangmi_ip
token: !secret chuangmi_key
switches:
projector:
command_on: 'Z6VLAAkCAABpAgAAYgYAAKYIAACJEQAAoSMAAKScAABYeQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFAQEBAQEBAQEhISEhISEhIQEBISEBAQEBISEBASEhISFhNXE1AQ'
command_off: 'Z6VHAPEBAACBAgAASQYAAIYIAABqEQAAySMAAECcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFAQEBAQEBAQEhISEhISEhIQEBASEhAQEBISEhAQEhISFhNQE'
This is strange. Could you try to call “python” and input the following lines:
from construct.lib.bitstream import RestreamedBytesIO, RebufferedBytesIO
Does it return the same error?
In this case please wait for the next homeassistant release. The miio components are broken at 0.61.1.
Hello.
Sorry if I missed something. After the latest update the service isn’t working anymore.
Both trying to call it in the dev tools like {“packet”:“Z6blabla”}, and in the scripts.yaml, like it used to do, using this format
lg_on_off:
sequence:
- service: switch.send_command_192_168_0_152
data:
packet:
- “Z6VHABsCAABEAgAAowYAAL8IAABkEQAAOyMAAKScAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFEBAgEBAQEBAgIBAgICAgIBAQECAQEBAQICAgECAgICBgNQA=”
No particular messages from log. I just replaced “chuangmi” with “switch” as domain, and stopped working.
The command_on: and command_off: declared in configuration.yaml work instead as expected.
Thanks!
@syssi with the latest Home assistant release (0.62.0) I’m still having problems.
This is my error:
Log Details (ERROR)
Sun Jan 28 2018 23:49:36 GMT+0100 (W. Europe Standard Time)
Error while setting up platform chuangmi_ir
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 189, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
raise self._exception
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/switch/chuangmi_ir.py", line 64, in setup_platform
from miio import ChuangmiIr, DeviceException
File "/usr/lib/python3.6/site-packages/miio/__init__.py", line 2, in <module>
from miio.protocol import Message, Utils
File "/usr/lib/python3.6/site-packages/miio/protocol.py", line 21, in <module>
from construct import (Struct, Bytes, Const, Int16ub, Int32ub, GreedyBytes,
File "/config/deps/lib/python3.6/site-packages/construct/__init__.py", line 22, in <module>
from construct.core import *
File "/config/deps/lib/python3.6/site-packages/construct/core.py", line 11, in <module>
from construct.lib import *
File "/config/deps/lib/python3.6/site-packages/construct/lib/__init__.py", line 3, in <module>
from construct.lib.bitstream import RestreamedBytesIO, RebufferedBytesIO
ImportError: cannot import name 'RestreamedBytesIO'
Please provide the output (version numbers) of this three commands:
cat /config/deps/lib/python3.6/site-packages/construct/version.py
cat /usr/lib/python3.6/site-packages/miio/version.py
grep REQUIRE /config/custom_components/switch/chuangmi_ir.py
A clever guy was able to encode proton ir commands in a chuang mir ir command (base64 string):
The feature is part of python-miio now and will be available soon at home assistant:
Stay tuned! My custom component will be obsolete then.
@syssi
Trying to get this to work on Hass.io 0.63.1 but got this error. Installed on custom components. Any help?
Error while setting up platform chuangmi_ir
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 84, in async_setup
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
raise self._exception
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/switch/chuangmi_ir.py", line 64, in setup_platform
from miio import ChuangmiIr, DeviceException
File "/usr/lib/python3.6/site-packages/miio/__init__.py", line 2, in <module>
from miio.protocol import Message, Utils
File "/usr/lib/python3.6/site-packages/miio/protocol.py", line 179, in <module>
Const(0x2131, Int16ub),
File "/usr/lib/python3.6/site-packages/construct/core.py", line 1894, in __init__
super(Const, self).__init__(subcon)
File "/usr/lib/python3.6/site-packages/construct/core.py", line 291, in __init__
raise TypeError("subcon should be a Construct field")
TypeError: subcon should be a Construct field
After updating to 0.63.3, chuangmi_ir is back. But it controls becomes an input boolean instead of separate on and off buttons like in the previous versions. And I get the following error when executing
Error executing service <ServiceCall switch.turn_on: entity_id=['switch.daikin_ac_full']>
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1010, in _event_to_service_call
yield from service_handler.func(service_call)
File "/usr/lib/python3.6/site-packages/homeassistant/components/switch/__init__.py", line 111, in async_handle_switch_service
yield from switch.async_turn_on()
File "/usr/lib/python3.6/asyncio/futures.py", line 332, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
future.result()
File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
raise self._exception
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/switch/chuangmi_ir.py", line 180, in turn_on
if self._send_command(self._command_on):
File "/config/custom_components/switch/chuangmi_ir.py", line 198, in _send_command
self._device.play(command, 38400)
TypeError: play() takes 2 positional arguments but 3 were given
Can’t send packets with the IR command either
Error executing service <ServiceCall switch.send_command_192_168_0_13: packet=['Z6XTAMIBAADtAQAAdQUAAD8HAADnDgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0ASEBIQEhASEBIQEhIQEhASEhISEBASEhAQEBASEBAQEhAQEBAQEhISEBAQEhAQEBASEBASEhAQEBAQEBAQEBAQEBASEBAQEBAQEBAQEBASEBAQEBAQEBAQEBIQEhISEhIQEBASEhASEB']>
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1010, in _event_to_service_call
yield from service_handler.func(service_call)
File "/usr/lib/python3.6/asyncio/coroutines.py", line 210, in coro
res = func(*args, **kw)
File "/config/custom_components/switch/chuangmi_ir.py", line 110, in _send_command
ir_remote.play(command, 38400)
TypeError: play() takes 2 positional arguments but 3 were given
Please remove the custom_components/switch/chuangmi_ir.py and update your configuration to use the official component remote.xiaomi_miio.
Quick & dirty solution: I fixed the custom_component. https://github.com/syssi/chuangmi_ir