Fix response_code 5 error due to firmware update
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Nicolas Duhamel 2022-07-27 08:44:09 +02:00
parent 8806a816ef
commit 66e91e2ecd

View File

@ -53,7 +53,7 @@ class Yamaha:
except json.decoder.JSONDecodeError:
raise ApiInvalidResponseError()
if r_json['response_code'] != 0:
if r_json['response_code'] != 0 and r_json['response_code'] != 5:
raise ApiError(r.url, r_json['response_code'])
return r_json
@ -99,6 +99,8 @@ class Yamaha:
self.request(Zone().set_volume('main', param, ''))
r = self.request(Zone().get_status('main'))
if r['response_code'] != 0:
return
self._client.publish('yamaha/stat/volume', r['volume'])
self._client.publish('yamaha/stat/volume/max', r['max_volume'])
@ -113,6 +115,8 @@ class Yamaha:
self.request(Zone().set_power('main', 'standby'))
r = self.request(Zone().get_status('main'))
if r['response_code'] != 0:
return
state = r['power']
state = 'off' if state == 'standby' else state
self._client.publish('yamaha/stat/power', state)