@syssi this is the output when i try to learn a remote:
2017-08-30 17:12:13 ERROR (MainThread) [miio.miio] got error when receiving: timed out
2017-08-30 17:12:13 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
result = next(coro)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/core.py", line 1025, in _event_to_service_call
yield from service_handler.func(service_call)
File "/home/homeassistant/.homeassistant/custom_components/switch/chuangmi_ir.py", line 67, in _learn_command
ir_remote.send("miIO.ir_learn", {'key': str(key)})
File "/srv/homeassistant/lib/python3.4/site-packages/miio/miio.py", line 128, in send
data, addr = s.recvfrom(1024)
socket.timeout: timed out
2017-08-30 17:12:14 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting
this is when i try to send a ir command
2017-08-30 17:16:13 ERROR (MainThread) [miio.miio] got error when receiving: timed out
2017-08-30 17:16:13 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/home/homeassistant/.homeassistant/custom_components/switch/chuangmi_ir.py", line 98, in _send_packet
ir_remote.send("miIO.ir_play", {'freq':38400, 'code': str(packet)})
File "/srv/homeassistant/lib/python3.4/site-packages/miio/miio.py", line 128, in send
data, addr = s.recvfrom(1024)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/tasks.py", line 237, in _step
result = next(coro)
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/core.py", line 1025, in _event_to_service_call
yield from service_handler.func(service_call)
File "/usr/lib/python3.4/asyncio/coroutines.py", line 141, in coro
res = func(*args, **kw)
File "/home/homeassistant/.homeassistant/custom_components/switch/chuangmi_ir.py", line 100, in _send_packet
except (socket.timeout, ValueError):
NameError: name 'socket' is not defined
2017-08-30 17:16:13 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting
I think changing the timeout doesn’t help because the timeout is used at L71 and the code fails at L68 already.
@hangy Could you try to change the following line:
Increase the timeout a bit (10 seconds?) for testing. This timeout is applied here and later used at L128. The implementation and used library is pretty old… I will try to rewrite the component this weekend.
Sorry, I didn’t get the thread notification until late night, although I see that you solved it.
I am using the same component by SchumiHao, and I got that error only twice: once when I hadn’t set the timeout parameter and another time that I couldn’t understand why. I solved this last one by rebooting my router.
i have tried this and learn_command works perfect, but when i try to send_command i get this error:
2017-09-03 13:15:09 ERROR (MainThread) [mirobo.device] Unable to discover a device at address 192.168.1.143
2017-09-03 13:15:09 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 237, in _step
result = next(coro)
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py”, line 1025, in _event_to_service_call
yield from service_handler.func(service_call)
File “/usr/lib/python3.4/asyncio/coroutines.py”, line 141, in coro
res = func(*args, **kw)
File “/home/homeassistant/.homeassistant/custom_components/switch/chuangmi_ir.py”, line 101, in _send_packet
“miIO.ir_play”, {‘freq’: 38400, ‘code’: str(packet)})
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/mirobo/device.py”, line 120, in send
self.do_discover()
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/mirobo/device.py”, line 72, in do_discover
raise DeviceException(“Unable to discover the device %s” % self.ip)
mirobo.device.DeviceException: Unable to discover the device 192.168.1.143
2017-09-03 13:15:09 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting
Yes, it works with that command. I’ve replaced [] to {} to make it work.
Now, back in homeassistant, when i try to send this same captured command, the blue led flashed several times and then it turned off. I’ve must to reset manually the chuangmi_ir to make it be usable again.
i’ve updated the python-miio and python-mirobo to version 0.0.11 and 0.1.4.
Right, i’m using Developer Tools
Domain chuangmi
Service send_packet_IP
Service_data:
{“packet”:“command_captured”}
I was trying to make it work with developer tools but now i’ve tried to add this command to switch configuration and it works perfectly.
I cannot test it right now, but I remember that the packet must be an array of strings (may be just with one element). If you send the parameter as a string, the service interprets it as an array of chars and sends a lot of packets making the device collapse. Most of the times you have to reset or disconnect it to make it work again.
Mine works flawlesly as a switch. But I have an automatio based on a slider that aims to set the air conditioner temperature sending different IR codes for each temperature setting. It uses the component service, but it fails as I must provide the packet as an array of one string element, and I don’t have the expression set very well yet…