Don't combine old and new value on scene update (#49248)

This commit is contained in:
Bram Kragten 2021-04-26 23:38:30 +02:00 committed by GitHub
parent 1527b9cad7
commit 9e7d83b2d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -66,13 +66,11 @@ class EditSceneConfigView(EditIdBasedConfigView):
# Iterate through some keys that we want to have ordered in the output
updated_value = OrderedDict()
for key in ("id", "name", "entities"):
if key in cur_value:
updated_value[key] = cur_value[key]
if key in new_value:
updated_value[key] = new_value[key]
# We cover all current fields above, but just in case we start
# supporting more fields in the future.
updated_value.update(cur_value)
updated_value.update(new_value)
data[index] = updated_value

View File

@ -16,7 +16,7 @@ async def async_setup(hass):
await hass.services.async_call(DOMAIN, SERVICE_RELOAD)
hass.http.register_view(
EditKeyBasedConfigView(
EditScriptConfigView(
DOMAIN,
"config",
SCRIPT_CONFIG_PATH,
@ -27,3 +27,11 @@ async def async_setup(hass):
)
)
return True
class EditScriptConfigView(EditKeyBasedConfigView):
"""Edit script config."""
def _write_value(self, hass, data, config_key, new_value):
"""Set value."""
data[config_key] = new_value