mirror of
https://github.com/home-assistant/core.git
synced 2025-06-04 13:17:06 +00:00
Ensure all default MQTT subentry option values are saved (#144347)
* Ensure all default MQTT subentry option values are saved * Apply correct filter
This commit is contained in:
parent
ccffe19611
commit
de63dddc96
@ -1385,8 +1385,11 @@ def subentry_schema_default_data_from_fields(
|
||||
return {
|
||||
key: field.default
|
||||
for key, field in data_schema_fields.items()
|
||||
if field.is_schema_default
|
||||
or (field.default is not vol.UNDEFINED and key not in component_data)
|
||||
if _check_conditions(field, component_data)
|
||||
and (
|
||||
field.is_schema_default
|
||||
or (field.default is not vol.UNDEFINED and key not in component_data)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -2212,7 +2215,10 @@ class MQTTSubentryFlowHandler(ConfigSubentryFlow):
|
||||
for component_data in self._subentry_data["components"].values():
|
||||
platform = component_data[CONF_PLATFORM]
|
||||
subentry_default_data = subentry_schema_default_data_from_fields(
|
||||
PLATFORM_ENTITY_FIELDS[platform] | COMMON_ENTITY_FIELDS, component_data
|
||||
COMMON_ENTITY_FIELDS
|
||||
| PLATFORM_ENTITY_FIELDS[platform]
|
||||
| PLATFORM_MQTT_FIELDS[platform],
|
||||
component_data,
|
||||
)
|
||||
component_data.update(subentry_default_data)
|
||||
|
||||
|
@ -153,6 +153,10 @@ MOCK_SUBENTRY_LIGHT_BASIC_KELVIN_COMPONENT = {
|
||||
"state_topic": "test-topic",
|
||||
"color_temp_kelvin": True,
|
||||
"state_value_template": "{{ value_json.value }}",
|
||||
"brightness_scale": 255,
|
||||
"max_kelvin": 6535,
|
||||
"min_kelvin": 2000,
|
||||
"white_scale": 255,
|
||||
"entity_picture": "https://example.com/8131babc5e8d4f44b82e0761d39091a2",
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user