From 8d66623036c324016bf2ab9a23adbb287292ad57 Mon Sep 17 00:00:00 2001 From: jjlawren Date: Wed, 22 Jun 2022 12:29:34 -0500 Subject: [PATCH] Add ZoneGroupState statistics to Sonos diagnostics (#73848) --- homeassistant/components/sonos/__init__.py | 8 ++++++++ homeassistant/components/sonos/diagnostics.py | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/homeassistant/components/sonos/__init__.py b/homeassistant/components/sonos/__init__.py index c26bf269a30..2e2290dff04 100644 --- a/homeassistant/components/sonos/__init__.py +++ b/homeassistant/components/sonos/__init__.py @@ -190,6 +190,14 @@ class SonosDiscoveryManager: for speaker in self.data.discovered.values(): speaker.activity_stats.log_report() speaker.event_stats.log_report() + if zgs := next( + speaker.soco.zone_group_state for speaker in self.data.discovered.values() + ): + _LOGGER.debug( + "ZoneGroupState stats: (%s/%s) processed", + zgs.processed_count, + zgs.total_requests, + ) await asyncio.gather( *(speaker.async_offline() for speaker in self.data.discovered.values()) ) diff --git a/homeassistant/components/sonos/diagnostics.py b/homeassistant/components/sonos/diagnostics.py index 077ca3a68cd..463884e1ea8 100644 --- a/homeassistant/components/sonos/diagnostics.py +++ b/homeassistant/components/sonos/diagnostics.py @@ -136,4 +136,8 @@ async def async_generate_speaker_info( payload["media"] = await async_generate_media_info(hass, speaker) payload["activity_stats"] = speaker.activity_stats.report() payload["event_stats"] = speaker.event_stats.report() + payload["zone_group_state_stats"] = { + "processed": speaker.soco.zone_group_state.processed_count, + "total_requests": speaker.soco.zone_group_state.total_requests, + } return payload