From 66e91e2ecd2bccc5d95da76db0600957bab03733 Mon Sep 17 00:00:00 2001 From: Nicolas Duhamel Date: Wed, 27 Jul 2022 08:44:09 +0200 Subject: [PATCH] Fix response_code 5 error due to firmware update --- src/yamaha2mqtt/app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/yamaha2mqtt/app.py b/src/yamaha2mqtt/app.py index ce0a387..95e7879 100644 --- a/src/yamaha2mqtt/app.py +++ b/src/yamaha2mqtt/app.py @@ -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)