mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-02-03 02:27:06 +00:00
Check for errors also in the command payload (#173)
For example, trying to set unsupported color temperature will cause such response. This gets ignored at the moment completely, so there is no indication at all why the command caused no effect on the device. > (93) {"smartlife.iot.smartbulb.lightingservice": {"transition_light_state": {"color_temp": 6000}}} < (125) {"smartlife.iot.smartbulb.lightingservice":{"transition_light_state":{"err_code":-10000,"err_msg":"Invalid input argument"}}}
This commit is contained in:
parent
60add6fa66
commit
a475233464
@ -125,13 +125,18 @@ class SmartDevice(object):
|
||||
|
||||
result = response[target]
|
||||
if "err_code" in result and result["err_code"] != 0:
|
||||
raise SmartDeviceException("Error on {}.{}: {}"
|
||||
raise SmartDeviceException("Error on {} {}: {}"
|
||||
.format(target, cmd, result))
|
||||
|
||||
if cmd not in result:
|
||||
raise SmartDeviceException("No command in response: {}"
|
||||
.format(response))
|
||||
|
||||
result = result[cmd]
|
||||
if "err_code" in result and result["err_code"] != 0:
|
||||
raise SmartDeviceException("Error on {} {}: {}"
|
||||
.format(target, cmd, result))
|
||||
|
||||
del result["err_code"]
|
||||
|
||||
return result
|
||||
|
Loading…
Reference in New Issue
Block a user