Adds support for new Supervisor options (#10)

*  Adds support for new Supervisor options

* 👕 Make sure Supervisor debug calls are always retuning a boolean
This commit is contained in:
Franck Nijhof 2019-08-19 20:28:18 +02:00 committed by GitHub
parent 2fcaf2ef49
commit 4533f16649
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -173,6 +173,34 @@ function bashio::supervisor.timezone() {
fi
}
# ------------------------------------------------------------------------------
# Returns the current logging level of the Supervisor.
#
# Arguments:
# $1 Logging level to set (optional).
# ------------------------------------------------------------------------------
function bashio::supervisor.logging() {
local logging=${1:-}
bashio::log.trace "${FUNCNAME[0]}:" "$@"
if bashio::var.has_value "${logging}"; then
logging=$(bashio::var.json logging "${logging}")
bashio::api.hassio POST /supervisor/options "${logging}"
bashio::cache.flush_all
else
bashio::supervisor 'supervisor.info.logging' '.logging'
fi
}
# ------------------------------------------------------------------------------
# Returns the ip address of the supervisor.
# ------------------------------------------------------------------------------
function bashio::supervisor.ip_address() {
bashio::log.trace "${FUNCNAME[0]}"
bashio::supervisor 'supervisor.info.ip_address' '.ip_address'
}
# ------------------------------------------------------------------------------
# Returns the time to wait after boot in seconds.
#
@ -193,6 +221,54 @@ function bashio::supervisor.wait_boot() {
fi
}
# ------------------------------------------------------------------------------
# Returns if debug is enabled on the supervisor
#
# Arguments:
# $1 Set debug (optional).
# ------------------------------------------------------------------------------
function bashio::supervisor.debug() {
local debug=${1:-}
bashio::log.trace "${FUNCNAME[0]}:" "$@"
if bashio::var.has_value "${debug}"; then
if bashio::var.true "${debug}"; then
debug=$(bashio::var.json debug "^true")
else
debug=$(bashio::var.json debug "^false")
fi
bashio::api.hassio POST /supervisor/options "${debug}"
bashio::cache.flush_all
else
bashio::supervisor 'supervisor.info.debug' '.debug // false'
fi
}
# ------------------------------------------------------------------------------
# Returns if debug block is enabled on the supervisor
#
# Arguments:
# $1 Set debug block (optional).
# ------------------------------------------------------------------------------
function bashio::supervisor.debug_block() {
local debug=${1:-}
bashio::log.trace "${FUNCNAME[0]}:" "$@"
if bashio::var.has_value "${debug}"; then
if bashio::var.true "${debug}"; then
debug=$(bashio::var.json debug_block "^true")
else
debug=$(bashio::var.json debug_block "^false")
fi
bashio::api.hassio POST /supervisor/options "${debug}"
bashio::cache.flush_all
else
bashio::supervisor 'supervisor.info.debug_block' '.debug_block // false'
fi
}
# ------------------------------------------------------------------------------
# Returns a list of add-on slugs of the add-ons installed.
# ------------------------------------------------------------------------------