mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Improve MQTT json color_temp validation (#133174)
* Improve MQTT json color_temp validation * Revert unrelated changes and assert on logs * Typo
This commit is contained in:
parent
74e4654c26
commit
16ad2d52c7
@ -490,7 +490,7 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity):
|
||||
)
|
||||
except KeyError:
|
||||
pass
|
||||
except ValueError:
|
||||
except (TypeError, ValueError):
|
||||
_LOGGER.warning(
|
||||
"Invalid color temp value '%s' received for entity %s",
|
||||
values["color_temp"],
|
||||
|
@ -2185,7 +2185,9 @@ async def test_white_scale(
|
||||
],
|
||||
)
|
||||
async def test_invalid_values(
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test that invalid color/brightness/etc. values are ignored."""
|
||||
await mqtt_mock_entry()
|
||||
@ -2287,6 +2289,10 @@ async def test_invalid_values(
|
||||
async_fire_mqtt_message(
|
||||
hass, "test_light_rgb", '{"state":"ON", "color_temp": "badValue"}'
|
||||
)
|
||||
assert (
|
||||
"Invalid color temp value 'badValue' received for entity light.test"
|
||||
in caplog.text
|
||||
)
|
||||
|
||||
# Color temperature should not have changed
|
||||
state = hass.states.get("light.test")
|
||||
|
Loading…
x
Reference in New Issue
Block a user