From a7b855ed07f20dddebc556dc5d768bd36eba756f Mon Sep 17 00:00:00 2001 From: Evan Severson <208220+eseverson@users.noreply.github.com> Date: Wed, 19 Aug 2026 11:45:33 -0700 Subject: [PATCH] Fix tplink crash logging device unavailable warning (#173314) Co-authored-by: Joost Lekkerkerker --- homeassistant/components/tplink/entity.py | 2 +- tests/components/tplink/test_init.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/tplink/entity.py b/homeassistant/components/tplink/entity.py index 12abb7913c0a..02724d4ceeb0 100644 --- a/homeassistant/components/tplink/entity.py +++ b/homeassistant/components/tplink/entity.py @@ -279,7 +279,7 @@ class CoordinatedTPLinkEntity(CoordinatorEntity[TPLinkDataUpdateCoordinator], AB if self._attr_available: _LOGGER.warning( "Unable to read data for %s %s: %s", - self._device, + self._device.host, self.entity_id, ex, ) diff --git a/tests/components/tplink/test_init.py b/tests/components/tplink/test_init.py index 0d757a3fc310..3cb8f8bf8064 100644 --- a/tests/components/tplink/test_init.py +++ b/tests/components/tplink/test_init.py @@ -375,7 +375,8 @@ async def test_update_attrs_fails_in_init( assert entity state = hass.states.get(entity_id) assert state.state == STATE_UNAVAILABLE - assert f"Unable to read data for MockLight {entity_id}:" in caplog.text + assert f"Unable to read data for {IP_ADDRESS} {entity_id}:" in caplog.text + assert "MockLight" not in caplog.text async def test_update_attrs_fails_on_update( @@ -418,7 +419,8 @@ async def test_update_attrs_fails_on_update( assert entity state = hass.states.get(entity_id) assert state.state == STATE_UNAVAILABLE - assert f"Unable to read data for MockLight {entity_id}:" in caplog.text + assert f"Unable to read data for {IP_ADDRESS} {entity_id}:" in caplog.text + assert "MockLight" not in caplog.text # Check only logs once caplog.clear() freezer.tick(5) @@ -427,7 +429,7 @@ async def test_update_attrs_fails_on_update( assert entity state = hass.states.get(entity_id) assert state.state == STATE_UNAVAILABLE - assert f"Unable to read data for MockLight {entity_id}:" not in caplog.text + assert f"Unable to read data for {IP_ADDRESS} {entity_id}:" not in caplog.text async def test_feature_no_category(