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 Franck Nijhof
parent 91023cf132
commit 2b0e828736
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3

View File

@ -91,9 +91,13 @@ async def async_generate_media_info(
payload[attrib] = getattr(speaker.media, attrib) payload[attrib] = getattr(speaker.media, attrib)
def poll_current_track_info(): def poll_current_track_info():
return speaker.soco.avTransport.GetPositionInfo( try:
[("InstanceID", 0), ("Channel", "Master")] return speaker.soco.avTransport.GetPositionInfo(
) [("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( payload["current_track_poll"] = await hass.async_add_executor_job(
poll_current_track_info poll_current_track_info