Lovelace fix: badges are removed from view after update (#18983)

* badges are removed from view after update

* Only add badges and cards when not provided in new config
This commit is contained in:
Bram Kragten 2018-12-04 09:56:30 +01:00 committed by Paulus Schoutsen
parent d8a7e9ded8
commit 75b855ef93

View file

@ -380,7 +380,10 @@ def update_view(fname: str, view_id: str, view_config, data_format:
"View with ID: {} was not found in {}.".format(view_id, fname))
if data_format == FORMAT_YAML:
view_config = yaml.yaml_to_object(view_config)
view_config['cards'] = found.get('cards', [])
if not view_config.get('cards') and found.get('cards'):
view_config['cards'] = found.get('cards', [])
if not view_config.get('badges') and found.get('badges'):
view_config['badges'] = found.get('badges', [])
found.clear()
found.update(view_config)
yaml.save_yaml(fname, config)