Fix default value handling for configuration options (#90)

This commit is contained in:
Franck Nijhof 2021-11-10 10:50:07 +01:00 committed by GitHub
parent 256198ff88
commit 4d2fa76db6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,10 +12,11 @@
# #
# Arguments: # Arguments:
# $1 Key of the config option # $1 Key of the config option
# $2 Default value for not set config option (optional: defaults to 'null')
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
function bashio::config() { function bashio::config() {
local key=${1} local key=${1}
local default_value=${2:-} local default_value=${2:-null}
local query local query
local result local result
@ -48,7 +49,7 @@ QUERY
options=$(bashio::addon.config) options=$(bashio::addon.config)
result=$(bashio::jq "${options}" "${query}") result=$(bashio::jq "${options}" "${query}")
if [[ "${result}" == "null" ]] && bashio::var.has_value "${default_value}"; if [[ "${result}" == "null" ]];
then then
echo "${default_value}" echo "${default_value}"
else else