diff --git a/custom_components/localthings/diagnostics.py b/custom_components/localthings/diagnostics.py index 7ed5870..8d75794 100644 --- a/custom_components/localthings/diagnostics.py +++ b/custom_components/localthings/diagnostics.py @@ -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 + }, } diff --git a/tests/localthings/test_diagnostics.py b/tests/localthings/test_diagnostics.py index 0c010af..e842125 100644 --- a/tests/localthings/test_diagnostics.py +++ b/tests/localthings/test_diagnostics.py @@ -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'] == {}