File tree Expand file tree Collapse file tree 3 files changed +38
-2
lines changed Expand file tree Collapse file tree 3 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -336,6 +336,36 @@ def schema(self):
336336 return vol .Schema (dict )
337337 return vol .Schema (vol .All (dict , validate_options (raw_schema )))
338338
339+ def test_udpate_schema (self ):
340+ """Check if the exists config valid after update."""
341+ if not self .is_installed or self .is_detached :
342+ return True
343+
344+ # load next schema
345+ new_raw_schema = self .data .cache [self ._id ][ATTR_SCHEMA ]
346+ default_options = self .data .cache [self ._id ][ATTR_OPTIONS ]
347+
348+ # if disabled
349+ if isinstance (new_raw_schema , bool ):
350+ return True
351+
352+ # merge options
353+ options = {
354+ ** self .data .user [self ._id ][ATTR_OPTIONS ],
355+ ** default_options ,
356+ }
357+
358+ # create voluptuous
359+ new_schema = \
360+ vol .Schema (vol .All (dict , validate_options (new_raw_schema )))
361+
362+ # validate
363+ try :
364+ new_schema (options )
365+ except vol .Invalid :
366+ return False
367+ return True
368+
339369 async def install (self , version = None ):
340370 """Install a addon."""
341371 if self .config .arch not in self .supported_arch :
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ def _migrate_startup(value):
9898# pylint: disable=no-value-for-parameter
9999SCHEMA_ADDON_USER = vol .Schema ({
100100 vol .Required (ATTR_VERSION ): vol .Coerce (str ),
101- vol .Required (ATTR_OPTIONS ): dict ,
101+ vol .Optional (ATTR_OPTIONS , default = {} ): dict ,
102102 vol .Optional (ATTR_AUTO_UPDATE , default = False ): vol .Boolean (),
103103 vol .Optional (ATTR_BOOT ):
104104 vol .In ([BOOT_AUTO , BOOT_MANUAL ]),
Original file line number Diff line number Diff line change @@ -27,8 +27,14 @@ async def _addons_update():
2727 if not addon .is_installed or not addon .auto_update :
2828 continue
2929
30- if addon .version_installed != addon .last_version :
30+ if addon .version_installed == addon .last_version :
31+ continue
32+
33+ if addon .test_udpate_schema ():
3134 tasks .append (addon .update ())
35+ else :
36+ _LOGGER .warning (
37+ "Addon %s will be ignore, schema tests fails" , addon .slug )
3238
3339 if tasks :
3440 _LOGGER .info ("Addon auto update process %d tasks" , len (tasks ))
You can’t perform that action at this time.
0 commit comments