Prevent enable watchdog on startup once (#2005)

* Prevent enable watchdog on startup once

* Update supervisor/addons/addon.py

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>

* fix black

Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
This commit is contained in:
Pascal Vizeli 2020-09-03 16:36:45 +02:00 committed by GitHub
parent e4d49bb459
commit 02872b5e75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -6,6 +6,8 @@ repos:
args:
- --safe
- --quiet
- --target-version
- py38
files: ^((supervisor|tests)/.+)?[^/]+\.py$
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3

View File

@ -39,6 +39,7 @@ from ..const import (
ATTR_VERSION,
ATTR_WATCHDOG,
DNS_SUFFIX,
AddonStartup,
AddonState,
)
from ..coresys import CoreSys
@ -185,7 +186,12 @@ class Addon(AddonModel):
@watchdog.setter
def watchdog(self, value: bool) -> None:
"""Set watchdog enable/disable."""
self.persist[ATTR_WATCHDOG] = value
if value and self.startup == AddonStartup.ONCE:
_LOGGER.warning(
"Ignoring watchdog for %s because startup type is 'once'", self.slug
)
else:
self.persist[ATTR_WATCHDOG] = value
@property
def uuid(self) -> str: