mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 22:37:11 +00:00
Fix invalid configuration of MQTT device QoS option in subentry flow (#147837)
This commit is contained in:
parent
ddf56f053b
commit
4f7348b8bc
@ -2771,11 +2771,10 @@ class MQTTSubentryFlowHandler(ConfigSubentryFlow):
|
||||
reconfig=True,
|
||||
)
|
||||
if user_input is not None:
|
||||
new_device_data, errors = validate_user_input(
|
||||
user_input, MQTT_DEVICE_PLATFORM_FIELDS
|
||||
)
|
||||
if "mqtt_settings" in user_input:
|
||||
new_device_data["mqtt_settings"] = user_input["mqtt_settings"]
|
||||
new_device_data: dict[str, Any] = user_input.copy()
|
||||
_, errors = validate_user_input(user_input, MQTT_DEVICE_PLATFORM_FIELDS)
|
||||
if "advanced_settings" in new_device_data:
|
||||
new_device_data |= new_device_data.pop("advanced_settings")
|
||||
if not errors:
|
||||
self._subentry_data[CONF_DEVICE] = cast(MqttDeviceData, new_device_data)
|
||||
if self.source == SOURCE_RECONFIGURE:
|
||||
|
@ -4077,6 +4077,7 @@ async def test_subentry_reconfigure_update_device_properties(
|
||||
"model": "Beer bottle XL",
|
||||
"model_id": "bn003",
|
||||
"configuration_url": "https://example.com",
|
||||
"mqtt_settings": {"qos": 1},
|
||||
},
|
||||
)
|
||||
assert result["type"] is FlowResultType.MENU
|
||||
@ -4090,12 +4091,15 @@ async def test_subentry_reconfigure_update_device_properties(
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reconfigure_successful"
|
||||
|
||||
# Check our device was updated
|
||||
# Check our device and mqtt data was updated correctly
|
||||
device = deepcopy(dict(subentry.data))["device"]
|
||||
assert device["name"] == "Beer notifier"
|
||||
assert "hw_version" not in device
|
||||
assert device["model"] == "Beer bottle XL"
|
||||
assert device["model_id"] == "bn003"
|
||||
assert device["sw_version"] == "1.1"
|
||||
assert device["mqtt_settings"]["qos"] == 1
|
||||
assert "qos" not in device
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
Loading…
x
Reference in New Issue
Block a user