Skip to content

Commit

Permalink
Suppress unnecessary errors (#23)
Browse files Browse the repository at this point in the history
Relates to - #22
  • Loading branch information
RogerSelwyn authored Mar 12, 2022
1 parent 8659dd4 commit 1e182a4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions braviapsk/sony_bravia_psk.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,17 @@ def get_command_code(self, command_name):
def get_volume_info(self):
"""Get volume info."""
resp = self.bravia_req_json(
"sony/audio", self._jdata_build("getVolumeInformation", None)
"sony/audio",
self._jdata_build("getVolumeInformation", None),
log_errors=False,
)
if not resp.get("error"):
error = resp.get("error")
if not error:
results = resp.get("result")[0]
for result in results:
if result.get("target") == "speaker":
return result
else:
elif 40005 not in error: # 40005 = "Display is Turned off"
_LOGGER.error("JSON request error:" + json.dumps(resp, indent=4))
return None

Expand Down Expand Up @@ -435,7 +438,9 @@ def turn_on_command(self):
if self.get_power_status() != "active":
self.send_req_ircc(self.get_command_code("TvPower"))
self.bravia_req_json(
"sony/system", self._jdata_build("setPowerStatus", {"status": True})
"sony/system",
self._jdata_build("setPowerStatus", {"status": True}),
log_errors=False,
)

def turn_off(self):
Expand Down

0 comments on commit 1e182a4

Please sign in to comment.