File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed
homeassistant/components/tplink Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -181,15 +181,14 @@ def _async_update_attrs(self) -> bool:
181181 HVACMode .HEAT if self ._thermostat_module .state else HVACMode .OFF
182182 )
183183
184- if (
185- self ._thermostat_module .mode not in STATE_TO_ACTION
186- and self ._attr_hvac_action is not HVACAction .OFF
187- ):
188- _LOGGER .warning (
189- "Unknown thermostat state, defaulting to OFF: %s" ,
190- self ._thermostat_module .mode ,
191- )
192- self ._attr_hvac_action = HVACAction .OFF
184+ if self ._thermostat_module .mode not in STATE_TO_ACTION :
185+ # Report a warning on the first non-default unknown mode
186+ if self ._attr_hvac_action is not HVACAction .OFF :
187+ _LOGGER .warning (
188+ "Unknown thermostat state, defaulting to OFF: %s" ,
189+ self ._thermostat_module .mode ,
190+ )
191+ self ._attr_hvac_action = HVACAction .OFF
193192 return True
194193
195194 self ._attr_hvac_action = STATE_TO_ACTION [self ._thermostat_module .mode ]
Original file line number Diff line number Diff line change @@ -225,6 +225,14 @@ async def test_unknown_mode(
225225 assert state .attributes [ATTR_HVAC_ACTION ] == HVACAction .OFF
226226 assert "Unknown thermostat state, defaulting to OFF" in caplog .text
227227
228+ # Second update, make sure the warning is not logged again
229+ caplog .clear ()
230+ async_fire_time_changed (hass , dt_util .utcnow () + timedelta (seconds = 30 ))
231+ await hass .async_block_till_done ()
232+ state = hass .states .get (ENTITY_ID )
233+ assert state .attributes [ATTR_HVAC_ACTION ] == HVACAction .OFF
234+ assert "Unknown thermostat state, defaulting to OFF" not in caplog .text
235+
228236
229237async def test_missing_feature_attributes (
230238 hass : HomeAssistant ,
You can’t perform that action at this time.
0 commit comments