al-one / hass-xiaomi-miot

Automatic integrate all Xiaomi devices to HomeAssistant via miot-spec, support Wi-Fi, BLE, ZigBee devices. 小米米家智能家居设备接入Hass集成
https://miot-spec.com
Apache License 2.0
4.59k stars 654 forks source link

Service "remote.learn_command" does not work #276

Closed ReWiG closed 4 days ago

ReWiG commented 2 years ago

I connected the "chuangmi.ir.v2" device to my HomeAssistant using the "MIOT" integration. I want to teach him a few commands, for this I try to use the "remote.learn_command" service but it doesn't work and keeps giving an "Unknown error" error. In this case, the following error is recorded in the log:

ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [1746101584] Error handling message: Unknown error Traceback (most recent call last): File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response await func(hass, connection, msg) File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/websocket_api/commands.py", line 523, in handle_execute_script await script_obj.async_run(msg.get("variables"), context=context) File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/script.py", line 1243, in async_run await asyncio.shield(run.async_run()) File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/script.py", line 353, in async_run await self._async_step(log_exceptions=False) File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/script.py", line 371, in _async_step await getattr(self, handler)() File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/script.py", line 571, in _async_call_service_step await service_task File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/core.py", line 1495, in async_call task.result() File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/core.py", line 1530, in _execute_service await handler.job.target(service_call) File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_component.py", line 213, in handle_service await self.hass.helpers.service.entity_service_call( File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/service.py", line 667, in entity_service_call future.result() # pop exception if have File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 863, in async_request_call await coro File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/service.py", line 704, in _handle_entity_call await result File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/remote/init.py", line 202, in async_learn_command await self.hass.async_add_executor_job(ft.partial(self.learn_command, *kwargs)) File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(self.args, **self.kwargs) File "/home/homeassistant/.homeassistant/custom_components/xiaomi_miot/remote.py", line 163, in learn_command raise NotImplementedError() NotImplementedError

al-one commented 2 years ago

Added in https://github.com/al-one/hass-xiaomi-miot/commit/c3bd723f30e643029413861356f0d1726500ebd6

service: remote.learn_command
data:
  entity_id: remote.chuangmi_v2_a0d5
  device: 666 # For store ir command, 1 - 1000000

https://github.com/rytilahti/python-miio/blob/master/miio/chuangmi_ir.py#L38-L50

al-one commented 2 years ago

Does it work ?

ReWiG commented 2 years ago

Does it work ?

No. The error, of course, is gone and does not appear in the log anymore, but no action is taken when the service is called. I am trying to teach the remote a command, but I am not getting it in any way. Maybe I don’t understand how to use it?

doobes commented 11 months ago

Has this been resolved?

I'm trying to use the service and I get the following:

"Failed to call service remote.learn_command. Unknown error"

Thanks

al-one commented 4 days ago

Add in v0.7.21