Add watchdog to add-on (#32)

This commit is contained in:
Pascal Vizeli 2020-08-28 17:29:26 +02:00 committed by GitHub
parent dc6ba0d6d5
commit 3bf2267431
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1009,6 +1009,31 @@ function bashio::addon.ingress_port() {
'.ingress_port // empty'
}
# ------------------------------------------------------------------------------
# Returns or sets whether or not watchdog is enabled for this add-on.
#
# Arguments:
# $1 Add-on slug (optional, default: self)
# $2 Set current watchdog state (Optional)
# ------------------------------------------------------------------------------
function bashio::addon.watchdog() {
local slug=${1:-'self'}
local watchdog=${2:-}
bashio::log.trace "${FUNCNAME[0]}" "$@"
if bashio::var.has_value "${watchdog}"; then
watchdog=$(bashio::var.json watchdog "^${watchdog}")
bashio::api.supervisor POST "/addons/${slug}/options" "${watchdog}"
bashio::cache.flush_all
else
bashio::addons \
"${slug}" \
"addons.${slug}.watchdog" \
'.watchdog // false'
fi
}
# ------------------------------------------------------------------------------
# List all available stats about an add-on.
#