Add the current supervisor version as default (#1791)

* Add the current supervisor version as default

* Fix lint

* Improve new version handling
This commit is contained in:
Pascal Vizeli 2020-06-15 14:47:27 +02:00 committed by GitHub
parent e27c5dad15
commit 351c45da75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 8 deletions

View File

@ -3,7 +3,7 @@ from datetime import datetime
import logging
import os
from pathlib import Path, PurePath
from typing import List, Optional
from typing import List
from .const import (
ATTR_ADDONS_CUSTOM_LIST,
@ -62,9 +62,9 @@ class CoreConfig(JsonConfig):
self._data[ATTR_TIMEZONE] = value
@property
def version(self) -> Optional[str]:
def version(self) -> str:
"""Return config version."""
return self._data.get(ATTR_VERSION)
return self._data[ATTR_VERSION]
@version.setter
def version(self, value: str) -> None:

View File

@ -28,10 +28,7 @@ class Core(CoreSysAttributes):
# If a update is failed?
if self.sys_dev:
self.sys_config.version = self.sys_supervisor.version
elif (
self.sys_config.version
and self.sys_config.version != self.sys_supervisor.version
):
elif self.sys_config.version != self.sys_supervisor.version:
self.healthy = False
_LOGGER.critical("Update of Supervisor fails!")

View File

@ -37,6 +37,7 @@ from .const import (
ATTR_WAIT_BOOT,
ATTR_WATCHDOG,
LogLevel,
SUPERVISOR_VERSION,
UpdateChannels,
)
from .utils.validate import validate_timezone
@ -176,7 +177,7 @@ SCHEMA_SUPERVISOR_CONFIG = vol.Schema(
{
vol.Optional(ATTR_TIMEZONE, default="UTC"): validate_timezone,
vol.Optional(ATTR_LAST_BOOT): vol.Coerce(str),
vol.Optional(ATTR_VERSION): simple_version,
vol.Optional(ATTR_VERSION, default=SUPERVISOR_VERSION): simple_version,
vol.Optional(
ATTR_ADDONS_CUSTOM_LIST,
default=["https://github.com/hassio-addons/repository"],