feat(observe): surface observe-mode state in diagnostics

This commit is contained in:
Marc Billow
2026-07-09 20:05:58 -05:00
parent ff9a20eff9
commit 8042fe715b
2 changed files with 23 additions and 0 deletions
@@ -33,4 +33,12 @@ async def async_get_config_entry_diagnostics(
"resources": redact_resources(coordinator.last_resources),
"integration_version": integration.version,
"smartthings_local_version": pkg_version("smartthings-local"),
"observe_mode": coordinator.observe_mode,
"observe_subscribed_hrefs": sorted(coordinator._observe.subscribed_hrefs),
"observe_fallback_hrefs": sorted(coordinator._observe.fallback_hrefs),
"observe_last_mode_change": coordinator._observe.last_mode_change_wall,
"observe_href_freshness_s": {
href: coordinator._cache.freshness_s(href)
for href in coordinator._observe.subscribed_hrefs
},
}
+15
View File
@@ -27,3 +27,18 @@ async def test_diagnostics_shape_and_redaction(
assert resources['/wirelessinfo/vs/0']['macaddressWiFi'] == REDACTED
# Ordinary state survives.
assert resources['/status/lock/vs/0']['x.com.samsung.da.ado.devicecontrol'] == 'On'
async def test_diagnostics_include_observe_mode_fields(
hass: HomeAssistant, mock_entry, mock_coordinator_session
) -> None:
await hass.config_entries.async_setup(mock_entry.entry_id)
await hass.async_block_till_done()
diag = await async_get_config_entry_diagnostics(hass, mock_entry)
assert diag['observe_mode'] == 'poll'
assert diag['observe_subscribed_hrefs'] == []
assert diag['observe_fallback_hrefs'] == []
assert 'observe_last_mode_change' in diag
assert diag['observe_href_freshness_s'] == {}