Fix Sonos diagnostics with offline device (#65393)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
jjlawren 2022-02-01 22:10:53 -06:00 committed by GitHub
parent 3da60355a9
commit c80d6810b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,9 +91,13 @@ async def async_generate_media_info(
payload[attrib] = getattr(speaker.media, attrib)
def poll_current_track_info():
try:
return speaker.soco.avTransport.GetPositionInfo(
[("InstanceID", 0), ("Channel", "Master")]
[("InstanceID", 0), ("Channel", "Master")],
timeout=3,
)
except OSError as ex:
return f"Error retrieving: {ex}"
payload["current_track_poll"] = await hass.async_add_executor_job(
poll_current_track_info