From 94cd656670ecff6b0dde4ee42782a6df55bb80d7 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 22 Mar 2022 03:58:16 -1000 Subject: [PATCH] Use new internal_state property in tplink diagnostics (#68497) --- homeassistant/components/tplink/diagnostics.py | 11 +++-------- tests/components/tplink/test_diagnostics.py | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/tplink/diagnostics.py b/homeassistant/components/tplink/diagnostics.py index 5771bee5bd3..5121def2e47 100644 --- a/homeassistant/components/tplink/diagnostics.py +++ b/homeassistant/components/tplink/diagnostics.py @@ -36,11 +36,6 @@ async def async_get_config_entry_diagnostics( ) -> dict[str, Any]: """Return diagnostics for a config entry.""" coordinator: TPLinkDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id] - device = coordinator.device - - data = {} - data[ - "device_last_response" - ] = device._last_update # pylint: disable=protected-access - - return async_redact_data(data, TO_REDACT) + return async_redact_data( + {"device_last_response": coordinator.device.internal_state}, TO_REDACT + ) diff --git a/tests/components/tplink/test_diagnostics.py b/tests/components/tplink/test_diagnostics.py index d09ea72b70a..55dd1cee9c7 100644 --- a/tests/components/tplink/test_diagnostics.py +++ b/tests/components/tplink/test_diagnostics.py @@ -38,7 +38,7 @@ async def test_diagnostics( """Test diagnostics for config entry.""" diagnostics_data = json.loads(load_fixture(fixture_file, "tplink")) - mocked_dev._last_update = diagnostics_data["device_last_response"] + mocked_dev.internal_state = diagnostics_data["device_last_response"] config_entry = await initialize_config_entry_for_device(hass, mocked_dev) result = await get_diagnostics_for_config_entry(hass, hass_client, config_entry)