mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Generic Hygrostat: Do not log warning if the hygrostat is already not active (#102662)
* Generic Hygrostat: Do not log warning if the hygrostat is already not active * add test
This commit is contained in:
parent
085f75ef1f
commit
2d74dafd3f
@ -396,9 +396,12 @@ class GenericHygrostat(HumidifierEntity, RestoreEntity):
|
|||||||
try:
|
try:
|
||||||
self._cur_humidity = float(humidity)
|
self._cur_humidity = float(humidity)
|
||||||
except ValueError as ex:
|
except ValueError as ex:
|
||||||
_LOGGER.warning("Unable to update from sensor: %s", ex)
|
if self._active:
|
||||||
|
_LOGGER.warning("Unable to update from sensor: %s", ex)
|
||||||
|
self._active = False
|
||||||
|
else:
|
||||||
|
_LOGGER.debug("Unable to update from sensor: %s", ex)
|
||||||
self._cur_humidity = None
|
self._cur_humidity = None
|
||||||
self._active = False
|
|
||||||
if self._is_device_active:
|
if self._is_device_active:
|
||||||
await self._async_device_turn_off()
|
await self._async_device_turn_off()
|
||||||
|
|
||||||
|
@ -468,6 +468,35 @@ async def test_sensor_bad_value(hass: HomeAssistant, setup_comp_2) -> None:
|
|||||||
assert hass.states.get(ENTITY).state == STATE_UNAVAILABLE
|
assert hass.states.get(ENTITY).state == STATE_UNAVAILABLE
|
||||||
|
|
||||||
|
|
||||||
|
async def test_sensor_bad_value_twice(
|
||||||
|
hass: HomeAssistant, setup_comp_2, caplog
|
||||||
|
) -> None:
|
||||||
|
"""Test sensor that the second bad value is not logged as warning."""
|
||||||
|
assert hass.states.get(ENTITY).state == STATE_ON
|
||||||
|
|
||||||
|
_setup_sensor(hass, "forty")
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert hass.states.get(ENTITY).state == STATE_UNAVAILABLE
|
||||||
|
assert [
|
||||||
|
rec.levelname
|
||||||
|
for rec in caplog.records
|
||||||
|
if "Unable to update from sensor" in rec.message
|
||||||
|
] == ["WARNING"]
|
||||||
|
|
||||||
|
caplog.clear()
|
||||||
|
|
||||||
|
_setup_sensor(hass, "fifty")
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert hass.states.get(ENTITY).state == STATE_UNAVAILABLE
|
||||||
|
assert [
|
||||||
|
rec.levelname
|
||||||
|
for rec in caplog.records
|
||||||
|
if "Unable to update from sensor" in rec.message
|
||||||
|
] == ["DEBUG"]
|
||||||
|
|
||||||
|
|
||||||
async def test_set_target_humidity_humidifier_on(
|
async def test_set_target_humidity_humidifier_on(
|
||||||
hass: HomeAssistant, setup_comp_2
|
hass: HomeAssistant, setup_comp_2
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user