Suddenly getting An error occurred: unknow command,
Had a hub mini set up for over a year now, to turn the AC on and off, works from the Switchbot app, but not from HA any more...
Logs are...
File "/config/custom_components/switchbotremote/remote.py", line 53, in turn_on self.sb.command(self._on_command) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^ File "/config/custom_components/switchbotremote/client/remote.py", line 72, in command super().command(action, parameter, customize) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/switchbotremote/client/remote.py", line 53, in command self.client.post(f"devices/{self.id}/commands", json=payload) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/switchbotremote/client/client.py", line 89, in post return self.request("POST", path, **kwargs) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/switchbotremote/client/client.py", line 75, in request result = self.__request(method, path, **kwargs) File "/config/custom_components/switchbotremote/client/client.py", line 64, in __request raise HomeAssistantError(f'An error occurred: {response_in_json["message"]}') homeassistant.exceptions.HomeAssistantError: An error occurred: unknown command 2025-04-30 08:37:36.101 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for de142c8a61f2bbb2c8be6e32f8d2990820db6fe8b3eadad4dfb0b20ef901578a 2025-04-30 08:37:43.552 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [546024716128] Unexpected exception Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service response = await hass.services.async_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<7 lines>... ) ^ File "/usr/src/homeassistant/homeassistant/core.py", line 2794, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2837, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1007, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ hass, entity, func, data, call.context ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1079, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1711, in async_turn_off await self.hass.async_add_executor_job(ft.partial(self.turn_off, **kwargs)) File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/switchbotremote/remote.py", line 60, in turn_off self.sb.command(self._on_command) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^ File "/config/custom_components/switchbotremote/client/remote.py", line 72, in command super().command(action, parameter, customize) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/switchbotremote/client/remote.py", line 53, in command self.client.post(f"devices/{self.id}/commands", json=payload) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/switchbotremote/client/client.py", line 89, in post return self.request("POST", path, **kwargs) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/switchbotremote/client/client.py", line 75, in request result = self.__request(method, path, **kwargs) File "/config/custom_components/switchbotremote/client/client.py", line 64, in __request raise HomeAssistantError(f'An error occurred: {response_in_json["message"]}') homeassistant.exceptions.HomeAssistantError: An error occurred: unknown command 2025-04-30 08:37:48.841 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for de142c8a61f2bbb2c8be6e32f8d2990820db6fe8b3eadad4dfb0b20ef901578a 2025-04-30 08:37:50.883 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for 74ebedda971e2cd59ed482839166590e 2025-04-30 08:37:53.421 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for de142c8a61f2bbb2c8be6e32f8d2990820db6fe8b3eadad4dfb0b20ef901578a 2025-04-30 08:37:56.704 DEBUG (SyncWorker_7) [custom_components.switchbotremote.client.remote] Sending command On/Off 2025-04-30 08:37:56.705 DEBUG (SyncWorker_7) [custom_components.switchbotremote.client.remote] Command payload {'commandType': 'command', 'command': 'On/Off', 'parameter': 'default'} 2025-04-30 08:37:56.705 DEBUG (SyncWorker_7) [custom_components.switchbotremote.client.client] Calling service https://api.switch-bot.com/v1.1/devices/01-202310101051-89550138/commands 2025-04-30 08:37:57.129 DEBUG (SyncWorker_7) [custom_components.switchbotremote.client.client] Received error in response {'status_code': 160, 'message': 'unknown command'} 2025-04-30 08:37:57.131 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [546024716128] Unexpected exception Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service response = await hass.services.async_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<7 lines>... ) ^ File "/usr/src/homeassistant/homeassistant/core.py", line 2794, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2837, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1007, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ hass, entity, func, data, call.context ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1079, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1703, in async_turn_on await self.hass.async_add_executor_job(ft.partial(self.turn_on, **kwargs)) File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/switchbotremote/remote.py", line 53, in turn_on self.sb.command(self._on_command) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^ File "/config/custom_components/switchbotremote/client/remote.py", line 72, in command super().command(action, parameter, customize) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/switchbotremote/client/remote.py", line 53, in command self.client.post(f"devices/{self.id}/commands", json=payload) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/switchbotremote/client/client.py", line 89, in post return self.request("POST", path, **kwargs) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/switchbotremote/client/client.py", line 75, in request result = self.__request(method, path, **kwargs) File "/config/custom_components/switchbotremote/client/client.py", line 64, in __request raise HomeAssistantError(f'An error occurred: {response_in_json["message"]}') homeassistant.exceptions.HomeAssistantError: An error occurred: unknown command
I'm facing the same issue.
I'm sorry but if this appear sporadically it should be related to switchbot APIs
Sorry to be a pain, tried it all times of the day and rebuilt the API link, still getting the same thing, any pointers would be good, cheers.
I can see from the logs
2025-04-30 08:37:56.704 DEBUG (SyncWorker_7) [custom_components.switchbotremote.client.remote] Sending command On/Off
2025-04-30 08:37:56.705 DEBUG (SyncWorker_7) [custom_components.switchbotremote.client.remote] Command payload {'commandType': 'command', 'command': 'On/Off', 'parameter': 'default'}
2025-04-30 08:37:56.705 DEBUG (SyncWorker_7) [custom_components.switchbotremote.client.client] Calling service https://api.switch-bot.com/v1.1/devices/01-202310101051-89550138/commands
You are sending a command On/Off but the APIs specification is "turnOff" or "turnOn" https://github.com/OpenWonderLabs/SwitchBotAPI?tab=readme-ov-file#command-set-for-virtual-infrared-remote-devices
My integration does not send any command like that. So you should configured it manually