Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress unnecessary errors #23

Merged
merged 1 commit into from
Mar 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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