python-kasa / python-kasa

🏠🤖 Python API for TP-Link smarthome products
https://python-kasa.readthedocs.io/en/stable/
Other
1.2k stars 194 forks source link

No command in response (HS103) #587

Open jiehanzheng opened 8 months ago

jiehanzheng commented 8 months ago

Hello!

I have a TP-Link Kasa switch HS103 in Home Assistant 2023.12.3 and I occasionally get this error message:

No command in response: {'system': {'get_sysinfo': {'sw_ver': '1.0.6 Build 220726 Rel.153854', 'hw_ver': '5.0', 'model': 'HS103(US)', 'deviceId': '80065A916FA6486F5B8D3142B86CDEA5217DF1D0', 'oemId': '211C91F3C6FA93568D818524FE170CEC', 'hwId': 'B25CBC5351DD892EA69AB42199F59E41', 'rssi': -39, 'latitude_i': -1879048193, 'longitude_i': -1879048193, 'alias': 'TP-LINK_Smart Plug_B9F2', 'status': 'new', 'mic_type': 'IOT.SMARTPLUGSWITCH', 'feature': 'TIM', 'mac': '40:ED:00:70:B9:F2', 'updating': 0, 'led_off': 0, 'relay_state': 0, 'on_time': 0, 'icon_hash': '', 'dev_name': 'Smart Wi-Fi Plug Mini', 'active_mode': 'none', 'next_action': {'type': -1}, 'err_code': 0}}, 'schedule': {'get_rules': {'err_code': -11, 'err_msg': 'time not sync'}, 'get_next_action': {'type': -1, 'err_code': 0}, 'get_realtime': {'err_code': -2, 'err_msg': 'member not support'}, 'get_daystat': {'day_list': [{'year': 2023, 'month': 12, 'day': 4, 'time': 9}], 'err_code': 0}, 'get_monthstat': {'month_list': [{'year': 2023, 'month': 12, 'time': 9}], 'err_code': 0}}, 'anti_theft': {'get_rules': {'err_code': -11, 'err_msg': 'time not sync'}, 'get_next_action': {'err_code': -2, 'err_msg': 'member not support'}}, 'time': {'get_time': {'year': 2000, 'month': 1, 'mday': 7, 'hour': 21, 'min': 54, 'sec': 31, 'err_code': 0}, 'get_timezone': {'index': 6, 'err_code': 0}}, 'cnCloud': {'get_info': {'username': '', 'server': 'n-devs.tplinkcloud.com', 'binded': 0, 'cld_connection': 0, 'illegalType': 0, 'stopConnect': 0, 'tcspStatus': 0, 'fwDlPage': '', 'tcspInfo': '', 'fwNotifyType': -1, 'err_code': 0}}}

It seems that I am hitting this condition. https://github.com/python-kasa/python-kasa/blob/b66347116f3d535447c89b722672fba3347886f8/kasa/smartdevice.py#L272-L273

The smart plug seems to correctly turn on/off on demand, however the switch entity becomes unavailable for several seconds after each toggling of the switch.

Is this condition expected? Would like some advice on how to get rid of this message. Thanks!

rytilahti commented 8 months ago

It isn't expected, but I think I have seen similar reports on the home assistant repository. It could be a firmware bug if it only happens sometimes.

If you know your way around modifying the code, you could make it a bit more verbose to include the command it tries to locate in that response?