Closed dacrypt closed 4 years ago
I get the same
I get the same
I presume this happens because my air conditioner unit (and yours) has no Speaker Volume capabilities. My suggestion to @sampsyo is to run on a "best effort" mode, ignoring those errors and just reporting as warnings. So for example, if you try to get SpkVolume and it results in "failed", just report 0 or -1 and don't panic the script.
For @salanki you can just replace the following inside ac.py
file:
def get_volume(self):
"""Get the speaker volume level."""
value = self._get_control('SpkVolume')
return int(value)
with
def get_volume(self):
"""Get the speaker volume level."""
# value = self._get_control('SpkVolume')
# return int(value)
return 0
Sounds reasonable! We could add an APIError
subclass corresponding to that 0100 error code, handle it in the get_volume
method, and report a default value there.
OK, I've done that in the above commit.
python3 example.py -c BR -l pt-BR ac-config d27c7740-7149-11d3-10b4-7440be9deeb2 {'UseTime': '74', 'ChangePeriod': '720', 'ChangeDate': '00000000'} {'RemainTime': '0', 'ChangePeriod': '0'} {'Day': '0', 'Week': '0', 'Month': '0'} Traceback (most recent call last): File "example.py", line 230, in
main()
File "example.py", line 226, in main
example(args.country, args.language, args.cmd, args.args)
File "example.py", line 186, in example
example_command(client, cmd, args)
File "example.py", line 162, in example_command
func(client, *args)
File "example.py", line 145, in ac_config
print(ac.get_volume())
File "/Users/david/dev/unsorted/wideq/wideq/ac.py", line 259, in get_volume
value = self._get_control('SpkVolume')
File "/Users/david/dev/unsorted/wideq/wideq/client.py", line 447, in _get_control
'Control',
File "/Users/david/dev/unsorted/wideq/wideq/core.py", line 397, in get_device_config
'data': '',
File "/Users/david/dev/unsorted/wideq/wideq/core.py", line 299, in post
return lgedm_post(url, data, self.auth.access_token, self.session_id)
File "/Users/david/dev/unsorted/wideq/wideq/core.py", line 133, in lgedm_post
raise APIError(code, message)
wideq.core.APIError: ('0100', '실패')