From a4b2a4cc1a9f296c0a5cda6283a2a2164b094e32 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 9 Feb 2020 00:16:29 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Re-branding=20of=20the=20Supervi?= =?UTF-8?q?sor=20API=20(#16)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :hammer: Re-branding of the Supervisor API * :ambulance: Fix typo in the supervisor token --- lib/addons.sh | 36 ++++---- lib/api.sh | 12 +-- lib/bashio.sh | 14 +-- lib/const.sh | 12 +-- lib/{homeassistant.sh => core.sh} | 140 +++++++++++++++--------------- lib/discovery.sh | 4 +- lib/dns.sh | 16 ++-- lib/hardware.sh | 4 +- lib/host.sh | 10 +-- lib/info.sh | 38 ++++---- lib/log.sh | 6 +- lib/{hassos.sh => os.sh} | 64 +++++++------- lib/repositories.sh | 4 +- lib/services.sh | 6 +- lib/supervisor.sh | 26 +++--- 15 files changed, 196 insertions(+), 196 deletions(-) rename lib/{homeassistant.sh => core.sh} (71%) rename lib/{hassos.sh => os.sh} (74%) diff --git a/lib/addons.sh b/lib/addons.sh index 2d4d274..9be6842 100644 --- a/lib/addons.sh +++ b/lib/addons.sh @@ -12,7 +12,7 @@ # ------------------------------------------------------------------------------ function bashio::addons.reload() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST /addons/reload + bashio::api.supervisor POST /addons/reload bashio::cache.flush_all } @@ -25,7 +25,7 @@ function bashio::addons.reload() { function bashio::addon.start() { local slug=${1:-'self'} bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST "/addons/${slug}/start" + bashio::api.supervisor POST "/addons/${slug}/start" } # ------------------------------------------------------------------------------ @@ -37,7 +37,7 @@ function bashio::addon.start() { function bashio::addon.restart() { local slug=${1:-'self'} bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST "/addons/${slug}/restart" + bashio::api.supervisor POST "/addons/${slug}/restart" } # ------------------------------------------------------------------------------ @@ -49,7 +49,7 @@ function bashio::addon.restart() { function bashio::addon.stop() { local slug=${1:-'self'} bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST "/addons/${slug}/stop" + bashio::api.supervisor POST "/addons/${slug}/stop" } # ------------------------------------------------------------------------------ @@ -61,7 +61,7 @@ function bashio::addon.stop() { function bashio::addon.install() { local slug=${1} bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST "/addons/${slug}/install" + bashio::api.supervisor POST "/addons/${slug}/install" } # ------------------------------------------------------------------------------ @@ -73,7 +73,7 @@ function bashio::addon.install() { function bashio::addon.rebuild() { local slug=${1:-'self'} bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST "/addons/${slug}/rebuild" + bashio::api.supervisor POST "/addons/${slug}/rebuild" } # ------------------------------------------------------------------------------ @@ -85,7 +85,7 @@ function bashio::addon.rebuild() { function bashio::addon.uninstall() { local slug=${1:-'self'} bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST "/addons/${slug}/uninstall" + bashio::api.supervisor POST "/addons/${slug}/uninstall" } # ------------------------------------------------------------------------------ @@ -97,7 +97,7 @@ function bashio::addon.uninstall() { function bashio::addon.update() { local slug=${1:-'self'} bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST "/addons/${slug}/update" + bashio::api.supervisor POST "/addons/${slug}/update" } # ------------------------------------------------------------------------------ @@ -109,7 +109,7 @@ function bashio::addon.update() { function bashio::addon.log() { local slug=${1:-'self'} bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio GET "/addons/${slug}/log" true + bashio::api.supervisor GET "/addons/${slug}/log" true } # ------------------------------------------------------------------------------ @@ -121,7 +121,7 @@ function bashio::addon.log() { function bashio::addon.changelog() { local slug=${1:-'self'} bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio GET "/addons/${slug}/changelog" true + bashio::api.supervisor GET "/addons/${slug}/changelog" true } # ------------------------------------------------------------------------------ @@ -150,14 +150,14 @@ function bashio::addons() { if bashio::cache.exists "addons.list"; then info=$(bashio::cache.get 'addons.list') else - info=$(bashio::api.hassio GET "/addons" false) + info=$(bashio::api.supervisor GET "/addons" false) bashio::cache.set "addons.list" "${info}" fi else if bashio::cache.exists "addons.${slug}.info"; then info=$(bashio::cache.get "addons.${slug}.info") else - info=$(bashio::api.hassio GET "/addons/${slug}/info" false) + info=$(bashio::api.supervisor GET "/addons/${slug}/info" false) bashio::cache.set "addons.${slug}.info" "${info}" fi fi @@ -275,7 +275,7 @@ function bashio::addon.auto_update() { if bashio::var.has_value "${auto_update}"; then auto_update=$(bashio::var.json auto_update "^${auto_update}") - bashio::api.hassio POST "/addons/${slug}/options" "${auto_update}" + bashio::api.supervisor POST "/addons/${slug}/options" "${auto_update}" bashio::cache.flush_all else bashio::addons \ @@ -432,7 +432,7 @@ function bashio::addon.boot() { if bashio::var.has_value "${boot}"; then boot=$(bashio::var.json boot "${boot}") - bashio::api.hassio POST "/addons/${slug}/options" "${boot}" + bashio::api.supervisor POST "/addons/${slug}/options" "${boot}" bashio::cache.flush_all else bashio::addons "${slug}" "addons.${slug}.boot" '.boot' @@ -869,7 +869,7 @@ function bashio::addon.audio_input() { if bashio::var.has_value "${audio_input}"; then audio_input=$(bashio::var.json audio_input "${audio_input}") - bashio::api.hassio POST "/addons/${slug}/options" "${audio_input}" + bashio::api.supervisor POST "/addons/${slug}/options" "${audio_input}" bashio::cache.flush_all else bashio::addons \ @@ -894,7 +894,7 @@ function bashio::addon.audio_output() { if bashio::var.has_value "${audio_output}"; then audio_output=$(bashio::var.json audio_output "${audio_output}") - bashio::api.hassio POST "/addons/${slug}/options" "${audio_output}" + bashio::api.supervisor POST "/addons/${slug}/options" "${audio_output}" bashio::cache.flush_all else bashio::addons \ @@ -905,7 +905,7 @@ function bashio::addon.audio_output() { } # ------------------------------------------------------------------------------ -# Returns IP address assigned on the hassio network for an add-on. +# Returns IP address assigned on the home assistant network for an add-on. # # Arguments: # $1 Add-on slug (optional, default: self) @@ -998,7 +998,7 @@ function bashio::addon.stats() { if bashio::cache.exists "addons.${slug}.stats"; then info=$(bashio::cache.get "addons.${slug}.stats") else - info=$(bashio::api.hassio GET "/addons/${slug}/stats" false) + info=$(bashio::api.supervisor GET "/addons/${slug}/stats" false) bashio::cache.set "addons.${slug}.stats" "${info}" fi diff --git a/lib/api.sh b/lib/api.sh index 4a2fe48..979d2aa 100644 --- a/lib/api.sh +++ b/lib/api.sh @@ -17,12 +17,12 @@ # $3 In case of a POST method, this parameter is the JSON to POST (optional) # $4 jq filter command (optional) # ------------------------------------------------------------------------------ -function bashio::api.hassio() { +function bashio::api.supervisor() { local method=${1} local resource=${2} local raw=${3:-} local filter=${4:-} - local auth_header='X-HASSIO-KEY;' + local auth_header='Authorization: Bearer' local response local status local data='{}' @@ -30,8 +30,8 @@ function bashio::api.hassio() { bashio::log.trace "${FUNCNAME[0]}" "$@" - if [[ -n "${HASSIO_TOKEN:-}" ]]; then - auth_header="X-HASSIO-KEY: ${__BASHIO_HASSIO_TOKEN}" + if [[ -n "${__BASHIO_SUPERVISOR_TOKEN:-}" ]]; then + auth_header="Authorization: Bearer ${__BASHIO_SUPERVISOR_TOKEN}" fi if [[ "${method}" = "POST" ]] && bashio::var.has_value "${raw}"; then @@ -43,7 +43,7 @@ function bashio::api.hassio() { -H "${auth_header}" \ -H "Content-Type: application/json" \ -d "${data}" \ - "${__BASHIO_HASSIO_API}${resource}" + "${__BASHIO_SUPERVISOR_API}${resource}" ); then bashio::log.debug "${response}" bashio::log.error "Something went wrong contacting the API" @@ -53,7 +53,7 @@ function bashio::api.hassio() { status=${response##*$'\n'} response=${response%$status} - bashio::log.debug "Requested API resource: ${__BASHIO_HASSIO_API}${resource}" + bashio::log.debug "Requested API resource: ${__BASHIO_SUPERVISOR_API}${resource}" bashio::log.debug "Request method: ${method}" bashio::log.debug "Request data: ${data}" bashio::log.debug "API HTTP Response code: ${status}" diff --git a/lib/bashio.sh b/lib/bashio.sh index a6e9afe..564a75c 100644 --- a/lib/bashio.sh +++ b/lib/bashio.sh @@ -25,9 +25,9 @@ readonly __BASHIO_LIB_DIR=$(dirname "${BASH_SOURCE[0]}") source "${__BASHIO_LIB_DIR}/const.sh" # Defaults -declare __BASHIO_HASSIO_API=${HASSIO_API:-${__BASHIO_DEFAULT_HASSIO_API}} -declare __BASHIO_HASSIO_TOKEN=${HASSIO_TOKEN:-${__BASHIO_DEFAULT_HASSIO_TOKEN}} -declare __BASHIO_ADDON_CONFIG=${HASSIO_ADDON_CONFIG:-${__BASHIO_DEFAULT_ADDON_CONFIG}} +declare __BASHIO_SUPERVISOR_API=${SUPERVISOR_API:-${__BASHIO_DEFAULT_SUPERVISOR_API}} +declare __BASHIO_SUPERVISOR_TOKEN=${SUPERVISOR_TOKEN:-${__BASHIO_DEFAULT_SUPERVISOR_TOKEN}} +declare __BASHIO_ADDON_CONFIG=${ADDON_CONFIG:-${__BASHIO_DEFAULT_ADDON_CONFIG}} declare __BASHIO_LOG_LEVEL=${LOG_LEVEL:-${__BASHIO_DEFAULT_LOG_LEVEL}} declare __BASHIO_LOG_FORMAT=${LOG_FORMAT:-${__BASHIO_DEFAULT_LOG_FORMAT}} declare __BASHIO_LOG_TIMESTAMP=${LOG_TIMESTAMP:-${__BASHIO_DEFAULT_LOG_TIMESTAMP}} @@ -53,6 +53,8 @@ source "${__BASHIO_LIB_DIR}/addons.sh" source "${__BASHIO_LIB_DIR}/api.sh" # shellcheck source=lib/config.sh source "${__BASHIO_LIB_DIR}/config.sh" +# shellcheck source=lib/core.sh +source "${__BASHIO_LIB_DIR}/core.sh" # shellcheck source=lib/debug.sh source "${__BASHIO_LIB_DIR}/debug.sh" # shellcheck source=lib/exit.sh @@ -63,10 +65,6 @@ source "${__BASHIO_LIB_DIR}/discovery.sh" source "${__BASHIO_LIB_DIR}/dns.sh" # shellcheck source=lib/hardware.sh source "${__BASHIO_LIB_DIR}/hardware.sh" -# shellcheck source=lib/hassos.sh -source "${__BASHIO_LIB_DIR}/hassos.sh" -# shellcheck source=lib/homeassistant.sh -source "${__BASHIO_LIB_DIR}/homeassistant.sh" # shellcheck source=lib/host.sh source "${__BASHIO_LIB_DIR}/host.sh" # shellcheck source=lib/info.sh @@ -75,6 +73,8 @@ source "${__BASHIO_LIB_DIR}/info.sh" source "${__BASHIO_LIB_DIR}/jq.sh" # shellcheck source=lib/net.sh source "${__BASHIO_LIB_DIR}/net.sh" +# shellcheck source=lib/os.sh +source "${__BASHIO_LIB_DIR}/os.sh" # shellcheck source=lib/pwned.sh source "${__BASHIO_LIB_DIR}/pwned.sh" # shellcheck source=lib/repositories.sh diff --git a/lib/const.sh b/lib/const.sh index 8eafe33..4dbcba2 100644 --- a/lib/const.sh +++ b/lib/const.sh @@ -8,14 +8,14 @@ # ============================================================================== # Defaults -readonly __BASHIO_DEFAULT_LOG_LEVEL=5 # Defaults to INFO -readonly __BASHIO_DEFAULT_LOG_FORMAT="[{TIMESTAMP}] {LEVEL}: {MESSAGE}" -readonly __BASHIO_DEFAULT_LOG_TIMESTAMP="%T" -readonly __BASHIO_DEFAULT_HASSIO_API="http://hassio" -readonly __BASHIO_DEFAULT_HASSIO_TOKEN="" readonly __BASHIO_DEFAULT_ADDON_CONFIG="/data/options.json" -readonly __BASHIO_DEFAULT_HIBP_ENDPOINT="https://api.pwnedpasswords.com/range" readonly __BASHIO_DEFAULT_CACHE_DIR="/dev/shm/bashio" +readonly __BASHIO_DEFAULT_HIBP_ENDPOINT="https://api.pwnedpasswords.com/range" +readonly __BASHIO_DEFAULT_LOG_FORMAT="[{TIMESTAMP}] {LEVEL}: {MESSAGE}" +readonly __BASHIO_DEFAULT_LOG_LEVEL=5 # Defaults to INFO +readonly __BASHIO_DEFAULT_LOG_TIMESTAMP="%T" +readonly __BASHIO_DEFAULT_SUPERVISOR_API="http://supervisor" +readonly __BASHIO_DEFAULT_SUPERVISOR_TOKEN="" # Exit codes readonly __BASHIO_EXIT_OK=0 # Successful termination diff --git a/lib/homeassistant.sh b/lib/core.sh similarity index 71% rename from lib/homeassistant.sh rename to lib/core.sh index 6a8d9fb..f9b94d0 100644 --- a/lib/homeassistant.sh +++ b/lib/core.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # ============================================================================== -# Community Hass.io Add-ons: Bashio -# Bashio is an bash function library for use with Hass.io add-ons. +# Community Home Assistant Add-ons: Bashio +# Bashio is an bash function library for use with Home Assistant add-ons. # # It contains a set of commonly used operations and can be used # to be included in add-on scripts to reduce code duplication across add-ons. @@ -10,25 +10,25 @@ # ------------------------------------------------------------------------------ # Starts Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.start() { +function bashio::core.start() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST /homeassistant/start + bashio::api.supervisor POST /core/start } # ------------------------------------------------------------------------------ # Stops Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.stop() { +function bashio::core.stop() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST /homeassistant/stop + bashio::api.supervisor POST /core/stop } # ------------------------------------------------------------------------------ # Restarts Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.restart() { +function bashio::core.restart() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST /homeassistant/restart + bashio::api.supervisor POST /core/restart } # ------------------------------------------------------------------------------ @@ -37,16 +37,16 @@ function bashio::homeassistant.restart() { # Arguments: # $1 Version to update to (optional) # ------------------------------------------------------------------------------ -function bashio::homeassistant.update() { +function bashio::core.update() { local version=${1:-} bashio::log.trace "${FUNCNAME[0]}:" "$@" if bashio::var.has_value "${version}"; then version=$(bashio::var.json version "${version}") - bashio::api.hassio POST /homeassistant/update "${version}" + bashio::api.supervisor POST /core/update "${version}" else - bashio::api.hassio POST /homeassistant/update + bashio::api.supervisor POST /core/update fi bashio::cache.flush_all } @@ -54,17 +54,17 @@ function bashio::homeassistant.update() { # ------------------------------------------------------------------------------ # Checks/validates your Home Assistant configuration. # ------------------------------------------------------------------------------ -function bashio::homeassistant.check() { +function bashio::core.check() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST /homeassistant/check + bashio::api.supervisor POST /core/check } # ------------------------------------------------------------------------------ # Returns the logs created by Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.logs() { +function bashio::core.logs() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio GET /homeassistant/logs true + bashio::api.supervisor GET /core/logs true } # ------------------------------------------------------------------------------ @@ -74,8 +74,8 @@ function bashio::homeassistant.logs() { # $1 Cache key to store results in (optional) # $2 jq Filter to apply on the result (optional) # ------------------------------------------------------------------------------ -function bashio::homeassistant() { - local cache_key=${1:-'homeassistant.info'} +function bashio::core() { + local cache_key=${1:-'core.info'} local filter=${2:-} local info local response @@ -87,11 +87,11 @@ function bashio::homeassistant() { return "${__BASHIO_EXIT_OK}" fi - if bashio::cache.exists 'homeassistant.info'; then - info=$(bashio::cache.get 'hassio.homeassistant') + if bashio::cache.exists 'core.info'; then + info=$(bashio::cache.get 'supervisor.core') else - info=$(bashio::api.hassio GET /homeassistant/info false) - bashio::cache.set 'homeassistant.info' "${info}" + info=$(bashio::api.supervisor GET /core/info false) + bashio::cache.set 'core.info' "${info}" fi response="${info}" @@ -108,17 +108,17 @@ function bashio::homeassistant() { # ------------------------------------------------------------------------------ # Returns the version of Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.version() { +function bashio::core.version() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant 'homeassistant.info.version' '.version' + bashio::core 'core.info.version' '.version' } # ------------------------------------------------------------------------------ # Returns the latest version of Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.last_version() { +function bashio::core.last_version() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant 'homeassistant.info.last_version' '.last_version' + bashio::core 'core.info.last_version' '.last_version' } # ------------------------------------------------------------------------------ @@ -130,8 +130,8 @@ function bashio::supervisor.update_available() { bashio::log.trace "${FUNCNAME[0]}" - version=$(bashio::homeassistant.version) - last_version=$(bashio::homeassistant.last_version) + version=$(bashio::core.version) + last_version=$(bashio::core.last_version) if [[ "${version}" = "${last_version}" ]]; then return "${__BASHIO_EXIT_NOK}" @@ -143,17 +143,17 @@ function bashio::supervisor.update_available() { # ------------------------------------------------------------------------------ # Returns the arch of Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.arch() { +function bashio::core.arch() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant 'homeassistant.info.arch' '.arch' + bashio::core 'core.info.arch' '.arch' } # ------------------------------------------------------------------------------ # Returns the machine info running Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.machine() { +function bashio::core.machine() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant 'homeassistant.info.machine' '.machine' + bashio::core 'core.info.machine' '.machine' } # ------------------------------------------------------------------------------ @@ -162,50 +162,50 @@ function bashio::homeassistant.machine() { # Arguments: # $1 Image to set (optional). # ------------------------------------------------------------------------------ -function bashio::homeassistant.image() { +function bashio::core.image() { local image=${1:-} bashio::log.trace "${FUNCNAME[0]}:" "$@" if bashio::var.has_value "${image}"; then image=$(bashio::var.json image "${image}") - bashio::api.hassio POST /homeassistant/options "${image}" + bashio::api.supervisor POST /core/options "${image}" bashio::cache.flush_all else - bashio::homeassistant 'homeassistant.info.image' '.image' + bashio::core 'core.info.image' '.image' fi } # ------------------------------------------------------------------------------ # Returns whether or not a custom version of Home Assistant is installed. # ------------------------------------------------------------------------------ -function bashio::homeassistant.custom() { +function bashio::core.custom() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant 'homeassistant.info.custom' '.custom // false' + bashio::core 'core.info.custom' '.custom // false' } # ------------------------------------------------------------------------------ # Returns whether or not Home Assistant starts at device boot. # ------------------------------------------------------------------------------ -function bashio::homeassistant.boot() { +function bashio::core.boot() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant 'homeassistant.info.boot' '.boot // false' + bashio::core 'core.info.boot' '.boot // false' # ------------------------------------------------------------------------------ } # Returns the port number on which Home Assistant is running. # ------------------------------------------------------------------------------ -function bashio::homeassistant.port() { +function bashio::core.port() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant 'homeassistant.port' '.port' + bashio::core 'core.port' '.port' } # ------------------------------------------------------------------------------ # Returns whether or not Home Assistant is running on SSL. # ------------------------------------------------------------------------------ -function bashio::homeassistant.ssl() { +function bashio::core.ssl() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant 'homeassistant.info.ssl' '.ssl // false' + bashio::core 'core.info.ssl' '.ssl // false' } # ------------------------------------------------------------------------------ @@ -214,17 +214,17 @@ function bashio::homeassistant.ssl() { # Arguments: # $1 True to enable watchdog, false otherwise (optional). # ------------------------------------------------------------------------------ -function bashio::homeassistant.watchdog() { +function bashio::core.watchdog() { local watchdog=${1:-} bashio::log.trace "${FUNCNAME[0]}:" "$@" if bashio::var.has_value "${watchdog}"; then watchdog=$(bashio::var.json watchdog "^${watchdog}") - bashio::api.hassio POST /homeassistant/options "${watchdog}" + bashio::api.supervisor POST /core/options "${watchdog}" bashio::cache.flush_all else - bashio::homeassistant 'homeassistant.info.watchdog' '.watchdog // false' + bashio::core 'core.info.watchdog' '.watchdog // false' fi } @@ -235,8 +235,8 @@ function bashio::homeassistant.watchdog() { # $1 Cache key to store results in (optional) # $2 jq Filter to apply on the result (optional) # ------------------------------------------------------------------------------ -function bashio::homeassistant.stats() { - local cache_key=${1:-'homeassistant.stats'} +function bashio::core.stats() { + local cache_key=${1:-'core.stats'} local filter=${2:-} local info local response @@ -248,11 +248,11 @@ function bashio::homeassistant.stats() { return "${__BASHIO_EXIT_OK}" fi - if bashio::cache.exists 'homeassistant.stats'; then - info=$(bashio::cache.get 'homeassistant.stats') + if bashio::cache.exists 'core.stats'; then + info=$(bashio::cache.get 'core.stats') else - info=$(bashio::api.hassio GET /homeassistant/stats false) - bashio::cache.set 'homeassistant.stats' "${info}" + info=$(bashio::api.supervisor GET /core/stats false) + bashio::cache.set 'core.stats' "${info}" fi response="${info}" @@ -269,69 +269,69 @@ function bashio::homeassistant.stats() { # ------------------------------------------------------------------------------ # Returns CPU usage from Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.cpu_percent() { +function bashio::core.cpu_percent() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant.stats 'homeassistant.stats.cpu_percent' '.cpu_percent' + bashio::core.stats 'core.stats.cpu_percent' '.cpu_percent' } # ------------------------------------------------------------------------------ # Returns memory usage from Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.memory_usage() { +function bashio::core.memory_usage() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant.stats \ - 'homeassistant.stats.memory_usage' \ + bashio::core.stats \ + 'core.stats.memory_usage' \ '.memory_usage' } # ------------------------------------------------------------------------------ # Returns memory limit from Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.memory_limit() { +function bashio::core.memory_limit() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant.stats \ - 'homeassistant.stats.memory_limit' \ + bashio::core.stats \ + 'core.stats.memory_limit' \ '.memory_limit' } # ------------------------------------------------------------------------------ # Returns memory usage in percent from Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.memory_percent() { +function bashio::core.memory_percent() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant.stats \ - 'homeassistant.stats.memory_percent' \ + bashio::core.stats \ + 'core.stats.memory_percent' \ '.memory_percent' } # ------------------------------------------------------------------------------ # Returns outgoing network usage from Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.network_tx() { +function bashio::core.network_tx() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant.stats 'homeassistant.stats.network_tx' '.network_tx' + bashio::core.stats 'core.stats.network_tx' '.network_tx' } # ------------------------------------------------------------------------------ # Returns incoming network usage from Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.network_rx() { +function bashio::core.network_rx() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant.stats 'homeassistant.stats.network_rx' '.network_rx' + bashio::core.stats 'core.stats.network_rx' '.network_rx' } # ------------------------------------------------------------------------------ # Returns disk read usage from Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.blk_read() { +function bashio::core.blk_read() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant.stats 'homeassistant.stats.blk_read' '.blk_read' + bashio::core.stats 'core.stats.blk_read' '.blk_read' } # ------------------------------------------------------------------------------ # Returns disk write usage from Home Assistant. # ------------------------------------------------------------------------------ -function bashio::homeassistant.blk_write() { +function bashio::core.blk_write() { bashio::log.trace "${FUNCNAME[0]}" - bashio::homeassistant.stats 'homeassistant.stats.blk_write' '.blk_write' + bashio::core.stats 'core.stats.blk_write' '.blk_write' } diff --git a/lib/discovery.sh b/lib/discovery.sh index ee30480..4bf2a6e 100644 --- a/lib/discovery.sh +++ b/lib/discovery.sh @@ -27,7 +27,7 @@ function bashio::discovery() { config "^${config}" \ ) - bashio::api.hassio "POST" "/discovery" "${payload}" ".uuid" + bashio::api.supervisor "POST" "/discovery" "${payload}" ".uuid" bashio::cache.flush_all } @@ -41,6 +41,6 @@ function bashio::discovery.delete() { local uuid=${1} bashio::log.trace "${FUNCNAME[0]}:" "$@" - bashio::api.hassio "DELETE" "/discovery/${uuid}" + bashio::api.supervisor "DELETE" "/discovery/${uuid}" bashio::cache.flush_all } diff --git a/lib/dns.sh b/lib/dns.sh index fa36e27..b7d17e8 100644 --- a/lib/dns.sh +++ b/lib/dns.sh @@ -20,9 +20,9 @@ function bashio::dns.update() { if bashio::var.has_value "${version}"; then version=$(bashio::var.json version "${version}") - bashio::api.hassio POST /dns/update "${version}" + bashio::api.supervisor POST /dns/update "${version}" else - bashio::api.hassio POST /dns/update + bashio::api.supervisor POST /dns/update fi bashio::cache.flush_all } @@ -32,7 +32,7 @@ function bashio::dns.update() { # ------------------------------------------------------------------------------ function bashio::dns.reset() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST /dns/reset + bashio::api.supervisor POST /dns/reset bashio::cache.flush_all } @@ -41,7 +41,7 @@ function bashio::dns.reset() { # ------------------------------------------------------------------------------ function bashio::dns.restart() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST /dns/restart + bashio::api.supervisor POST /dns/restart bashio::cache.flush_all } @@ -50,7 +50,7 @@ function bashio::dns.restart() { # ------------------------------------------------------------------------------ function bashio::dns.logs() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio GET /dns/logs true + bashio::api.supervisor GET /dns/logs true } # ------------------------------------------------------------------------------ @@ -76,7 +76,7 @@ function bashio::dns() { if bashio::cache.exists 'dns.info'; then info=$(bashio::cache.get 'dns.info') else - info=$(bashio::api.hassio GET /dns/info false) + info=$(bashio::api.supervisor GET /dns/info false) bashio::cache.set 'dns.info' "${info}" fi @@ -139,7 +139,7 @@ function bashio::dns.update_available() { # ------------------------------------------------------------------------------ function bashio::dns.servers() { bashio::log.trace "${FUNCNAME[0]}" - bashio::supervisor 'dns.info.servers' '.servers[]' + bashio::dns 'dns.info.servers' '.servers[]' } # ------------------------------------------------------------------------------ @@ -165,7 +165,7 @@ function bashio::dns.stats() { if bashio::cache.exists 'dns.stats'; then info=$(bashio::cache.get 'dns.stats') else - info=$(bashio::api.hassio GET /dns/stats false) + info=$(bashio::api.supervisor GET /dns/stats false) bashio::cache.set 'dns.stats' "${info}" fi diff --git a/lib/hardware.sh b/lib/hardware.sh index 33a615e..a229f76 100644 --- a/lib/hardware.sh +++ b/lib/hardware.sh @@ -30,7 +30,7 @@ function bashio::hardware() { if bashio::cache.exists 'hardware.info'; then info=$(bashio::cache.get 'hardware.info') else - info=$(bashio::api.hassio GET /hardware/info false) + info=$(bashio::api.supervisor GET /hardware/info false) bashio::cache.set 'hardware.info' "${info}" fi @@ -82,5 +82,5 @@ function bashio::hardware.gpio() { # ------------------------------------------------------------------------------ function bashio::hardware.trigger() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST /hardware/trigger + bashio::api.supervisor POST /hardware/trigger } diff --git a/lib/host.sh b/lib/host.sh index 794cffb..568ff31 100644 --- a/lib/host.sh +++ b/lib/host.sh @@ -12,7 +12,7 @@ # ------------------------------------------------------------------------------ function bashio::host.reload() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST /host/reload + bashio::api.supervisor POST /host/reload } # ------------------------------------------------------------------------------ @@ -20,7 +20,7 @@ function bashio::host.reload() { # ------------------------------------------------------------------------------ function bashio::host.shutdown() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST /host/shutdown + bashio::api.supervisor POST /host/shutdown } # ------------------------------------------------------------------------------ @@ -28,7 +28,7 @@ function bashio::host.shutdown() { # ------------------------------------------------------------------------------ function bashio::host.reboot() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST /host/reboot + bashio::api.supervisor POST /host/reboot } # ------------------------------------------------------------------------------ @@ -54,7 +54,7 @@ function bashio::host() { if bashio::cache.exists 'host.info'; then info=$(bashio::cache.get 'host.info') else - info=$(bashio::api.hassio GET /host/info false) + info=$(bashio::api.supervisor GET /host/info false) bashio::cache.set 'host.info' "${info}" fi @@ -79,7 +79,7 @@ function bashio::host.hostname() { if bashio::var.has_value "${hostname}"; then hostname=$(bashio::var.json hostname "${hostname}") - bashio::api.hassio POST /host/options "${hostname}" + bashio::api.supervisor POST /host/options "${hostname}" bashio::cache.flush_all else bashio::host 'host.info.hostname' '.hostname' diff --git a/lib/info.sh b/lib/info.sh index e18f736..44cabcf 100644 --- a/lib/info.sh +++ b/lib/info.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # ============================================================================== -# Community Hass.io Add-ons: Bashio -# Bashio is an bash function library for use with Hass.io add-ons. +# Community Home Assistant Add-ons: Bashio +# Bashio is an bash function library for use with Home Assistant add-ons. # # It contains a set of commonly used operations and can be used # to be included in add-on scripts to reduce code duplication across add-ons. @@ -15,7 +15,7 @@ # $2 jq Filter to apply on the result (optional) # ------------------------------------------------------------------------------ function bashio::info() { - local cache_key=${1:-'hassio.info'} + local cache_key=${1:-'supervisor.info'} local filter=${2:-} local info local response @@ -27,11 +27,11 @@ function bashio::info() { return "${__BASHIO_EXIT_OK}" fi - if bashio::cache.exists 'hassio.info'; then - info=$(bashio::cache.get 'hassio.info') + if bashio::cache.exists 'supervisor.info'; then + info=$(bashio::cache.get 'supervisor.info') else - info=$(bashio::api.hassio GET /info false) - bashio::cache.set 'hassio.info' "${info}" + info=$(bashio::api.supervisor GET /info false) + bashio::cache.set 'supervisor.info' "${info}" fi response="${info}" @@ -46,11 +46,11 @@ function bashio::info() { } # ------------------------------------------------------------------------------ -# Returns the Hass.io supervisor version used. +# Returns the Home Assistant Supervisor version used. # ------------------------------------------------------------------------------ function bashio::info.supervisor() { bashio::log.trace "${FUNCNAME[0]}" - bashio::info 'hassio.info.supervisor' '.supervisor' + bashio::info 'supervisor.info.supervisor' '.supervisor' } # ------------------------------------------------------------------------------ @@ -58,7 +58,7 @@ function bashio::info.supervisor() { # ------------------------------------------------------------------------------ function bashio::info.homeassistant() { bashio::log.trace "${FUNCNAME[0]}" - bashio::info 'hassio.info.homeassistant' '.homeassistant' + bashio::info 'supervisor.info.homeassistant' '.homeassistant' } # ------------------------------------------------------------------------------ @@ -66,7 +66,7 @@ function bashio::info.homeassistant() { # ------------------------------------------------------------------------------ function bashio::info.hassos() { bashio::log.trace "${FUNCNAME[0]}" - bashio::info 'hassio.info.hassos' '.hassos' + bashio::info 'supervisor.info.hassos' '.hassos' } # ------------------------------------------------------------------------------ @@ -74,7 +74,7 @@ function bashio::info.hassos() { # ------------------------------------------------------------------------------ function bashio::info.hostname() { bashio::log.trace "${FUNCNAME[0]}" - bashio::info 'hassio.info.hostname' '.hostname' + bashio::info 'supervisor.info.hostname' '.hostname' } # ------------------------------------------------------------------------------ @@ -82,7 +82,7 @@ function bashio::info.hostname() { # ------------------------------------------------------------------------------ function bashio::info.machine() { bashio::log.trace "${FUNCNAME[0]}" - bashio::info 'hassio.info.machine' '.machine' + bashio::info 'supervisor.info.machine' '.machine' } # ------------------------------------------------------------------------------ @@ -90,7 +90,7 @@ function bashio::info.machine() { # ------------------------------------------------------------------------------ function bashio::info.arch() { bashio::log.trace "${FUNCNAME[0]}" - bashio::info 'hassio.info.arch' '.arch' + bashio::info 'supervisor.info.arch' '.arch' } # ------------------------------------------------------------------------------ @@ -98,7 +98,7 @@ function bashio::info.arch() { # ------------------------------------------------------------------------------ function bashio::info.channel() { bashio::log.trace "${FUNCNAME[0]}" - bashio::info 'hassio.info.channel' '.channel' + bashio::info 'supervisor.info.channel' '.channel' } # ------------------------------------------------------------------------------ @@ -106,15 +106,15 @@ function bashio::info.channel() { # ------------------------------------------------------------------------------ function bashio::info.supported_arch() { bashio::log.trace "${FUNCNAME[0]}" - bashio::info 'hassio.info.supported_arch' '.supported_arch[]' + bashio::info 'supervisor.info.supported_arch' '.supported_arch[]' } # ------------------------------------------------------------------------------ -# Returns logging level of Hass.io universum. +# Returns logging level of Supervisor universum. # ------------------------------------------------------------------------------ function bashio::info.logging() { bashio::log.trace "${FUNCNAME[0]}" - bashio::info 'hassio.info.logging' '.logging' + bashio::info 'supervisor.info.logging' '.logging' } # ------------------------------------------------------------------------------ @@ -122,5 +122,5 @@ function bashio::info.logging() { # ------------------------------------------------------------------------------ function bashio::info.timezone() { bashio::log.trace "${FUNCNAME[0]}" - bashio::info 'hassio.info.timezone' '.timezone' + bashio::info 'supervisor.info.timezone' '.timezone' } diff --git a/lib/log.sh b/lib/log.sh index eeca90b..064a991 100644 --- a/lib/log.sh +++ b/lib/log.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # ============================================================================== -# Community Hass.io Add-ons: Bashio -# Bashio is an bash function library for use with Hass.io add-ons. +# Community Home Assistant Add-ons: Bashio +# Bashio is an bash function library for use with Home Assistant add-ons. # # It contains a set of commonly used operations and can be used # to be included in add-on scripts to reduce code duplication across add-ons. @@ -152,7 +152,7 @@ function bashio::log.info() { local message=$* bashio::log.log \ "${__BASHIO_LOG_LEVEL_INFO}" \ - "${__BASHIO_COLORS_BLUE}${message}${__BASHIO_COLORS_RESET}" + "${__BASHIO_COLORS_GREEN}${message}${__BASHIO_COLORS_RESET}" } # ------------------------------------------------------------------------------ diff --git a/lib/hassos.sh b/lib/os.sh similarity index 74% rename from lib/hassos.sh rename to lib/os.sh index 993f9cc..6400bcf 100644 --- a/lib/hassos.sh +++ b/lib/os.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # ============================================================================== -# Community Hass.io Add-ons: Bashio -# Bashio is an bash function library for use with Hass.io add-ons. +# Community Home Assistant Add-ons: Bashio +# Bashio is an bash function library for use with Home Assistant add-ons. # # It contains a set of commonly used operations and can be used # to be included in add-on scripts to reduce code duplication across add-ons. @@ -13,16 +13,16 @@ # Arguments: # $1 Version to update to (optional) # ------------------------------------------------------------------------------ -function bashio::hassos.update() { +function bashio::os.update() { local version=${1:-} bashio::log.trace "${FUNCNAME[0]}:" "$@" if bashio::var.has_value "${version}"; then version=$(bashio::var.json version "${version}") - bashio::api.hassio POST /hassos/update "${version}" + bashio::api.supervisor POST /os/update "${version}" else - bashio::api.hassio POST /hassos/update + bashio::api.supervisor POST /os/update fi bashio::cache.flush_all } @@ -33,16 +33,16 @@ function bashio::hassos.update() { # Arguments: # $1 Version to update to (optional) # ------------------------------------------------------------------------------ -function bashio::hassos.update_cli() { +function bashio::os.update_cli() { local version=${1:-} bashio::log.trace "${FUNCNAME[0]}:" "$@" if bashio::var.has_value "${version}"; then version=$(bashio::var.json version "${version}") - bashio::api.hassio POST /hassos/update/cli "${version}" + bashio::api.supervisor POST /os/update/cli "${version}" else - bashio::api.hassio POST /hassos/update/cli + bashio::api.supervisor POST /os/update/cli fi bashio::cache.flush_all } @@ -50,9 +50,9 @@ function bashio::hassos.update_cli() { # ------------------------------------------------------------------------------ # Load HassOS host configuration from USB stick. # ------------------------------------------------------------------------------ -function bashio::hassos.config_sync() { +function bashio::os.config_sync() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST /hassos/config/sync + bashio::api.supervisor POST /os/config/sync } # ------------------------------------------------------------------------------ @@ -62,8 +62,8 @@ function bashio::hassos.config_sync() { # $1 Cache key to store results in (optional) # $2 jq Filter to apply on the result (optional) # ------------------------------------------------------------------------------ -function bashio::hassos() { - local cache_key=${1:-'hassos.info'} +function bashio::os() { + local cache_key=${1:-'os.info'} local filter=${2:-} local info local response @@ -75,11 +75,11 @@ function bashio::hassos() { return "${__BASHIO_EXIT_OK}" fi - if bashio::cache.exists 'hassos.info'; then - info=$(bashio::cache.get 'hassio.hassos') + if bashio::cache.exists 'os.info'; then + info=$(bashio::cache.get 'supervisor.os') else - info=$(bashio::api.hassio GET /hassos/info false) - bashio::cache.set 'hassos.info' "${info}" + info=$(bashio::api.supervisor GET /os/info false) + bashio::cache.set 'os.info' "${info}" fi response="${info}" @@ -96,30 +96,30 @@ function bashio::hassos() { # ------------------------------------------------------------------------------ # Returns the version of HassOS. # ------------------------------------------------------------------------------ -function bashio::hassos.version() { +function bashio::os.version() { bashio::log.trace "${FUNCNAME[0]}" - bashio::hassos 'hassos.info.version' '.version' + bashio::os 'os.info.version' '.version' } # ------------------------------------------------------------------------------ # Returns the latest version of HassOS. # ------------------------------------------------------------------------------ -function bashio::hassos.version_latest() { +function bashio::os.version_latest() { bashio::log.trace "${FUNCNAME[0]}" - bashio::hassos 'hassos.info.version_latest' '.version_latest' + bashio::os 'os.info.version_latest' '.version_latest' } # ------------------------------------------------------------------------------ # Checks if there is an update available for the Supervisor. # ------------------------------------------------------------------------------ -function bashio::hassos.update_available() { +function bashio::os.update_available() { local version local last_version bashio::log.trace "${FUNCNAME[0]}" - version=$(bashio::hassos.version) - last_version=$(bashio::hassos.last_version) + version=$(bashio::os.version) + last_version=$(bashio::os.last_version) if [[ "${version}" = "${last_version}" ]]; then return "${__BASHIO_EXIT_NOK}" @@ -131,30 +131,30 @@ function bashio::hassos.update_available() { # ------------------------------------------------------------------------------ # Returns the CLI version of HassOS. # ------------------------------------------------------------------------------ -function bashio::hassos.version_cli() { +function bashio::os.version_cli() { bashio::log.trace "${FUNCNAME[0]}" - bashio::hassos 'hassos.info.version_cli' '.version_cli' + bashio::os 'os.info.version_cli' '.version_cli' } # ------------------------------------------------------------------------------ # Returns the latest CLI version of HassOS. # ------------------------------------------------------------------------------ -function bashio::hassos.version_cli_latest() { +function bashio::os.version_cli_latest() { bashio::log.trace "${FUNCNAME[0]}" - bashio::hassos 'hassos.info.version_cli_latest' '.version_cli_latest' + bashio::os 'os.info.version_cli_latest' '.version_cli_latest' } # ------------------------------------------------------------------------------ # Checks if there is an update available for the Supervisor. # ------------------------------------------------------------------------------ -function bashio::hassos.update_available_cli() { +function bashio::os.update_available_cli() { local version local last_version bashio::log.trace "${FUNCNAME[0]}" - version=$(bashio::hassos.version_cli) - last_version=$(bashio::hassos.version_cli_latest) + version=$(bashio::os.version_cli) + last_version=$(bashio::os.version_cli_latest) if [[ "${version}" = "${last_version}" ]]; then return "${__BASHIO_EXIT_NOK}" @@ -166,7 +166,7 @@ function bashio::hassos.update_available_cli() { # ------------------------------------------------------------------------------ # Returns the board running HassOS. # ------------------------------------------------------------------------------ -function bashio::hassos.board() { +function bashio::os.board() { bashio::log.trace "${FUNCNAME[0]}" - bashio::hassos 'hassos.info.board' '.board' + bashio::os 'os.info.board' '.board' } diff --git a/lib/repositories.sh b/lib/repositories.sh index 1567fb6..0ee8ca5 100644 --- a/lib/repositories.sh +++ b/lib/repositories.sh @@ -33,14 +33,14 @@ function bashio::repositories() { if bashio::cache.exists "repositories.list"; then info=$(bashio::cache.get 'repositories.list') else - info=$(bashio::api.hassio GET "/addons" false) + info=$(bashio::api.supervisor GET "/addons" false) bashio::cache.set "repositories.list" "${info}" fi else if bashio::cache.exists "repositories.${slug}.info"; then info=$(bashio::cache.get "repositories.${slug}.info") else - info=$(bashio::api.hassio GET "/addons" \ + info=$(bashio::api.supervisor GET "/addons" \ false ".repositories[] | select(.slug==\"${slug}\")") bashio::cache.set "repositories.${slug}.info" "${info}" fi diff --git a/lib/services.sh b/lib/services.sh index 4811415..6395cd4 100644 --- a/lib/services.sh +++ b/lib/services.sh @@ -27,7 +27,7 @@ function bashio::services() { if bashio::cache.exists "${cache_key}"; then config=$(bashio::cache.get "${cache_key}") else - config=$(bashio::api.hassio GET "/services/${service}" false) + config=$(bashio::api.supervisor GET "/services/${service}" false) bashio::cache.set "${cache_key}" "${config}" fi @@ -78,7 +78,7 @@ function bashio::services.publish() { bashio::log.trace "${FUNCNAME[0]}:" "$@" - bashio::api.hassio "POST" "/services/${service}" "${config}" + bashio::api.supervisor "POST" "/services/${service}" "${config}" bashio::cache.flush_all } @@ -92,6 +92,6 @@ function bashio::services.delete() { local service=${1} bashio::log.trace "${FUNCNAME[0]}:" "$@" - bashio::api.hassio "DELETE" "/services/${service}" + bashio::api.supervisor "DELETE" "/services/${service}" bashio::cache.flush_all } diff --git a/lib/supervisor.sh b/lib/supervisor.sh index 5b84188..eb1ae5f 100644 --- a/lib/supervisor.sh +++ b/lib/supervisor.sh @@ -12,7 +12,7 @@ # ------------------------------------------------------------------------------ function bashio::supervisor.ping() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio GET /supervisor/ping + bashio::api.supervisor GET /supervisor/ping } # ------------------------------------------------------------------------------ @@ -28,9 +28,9 @@ function bashio::supervisor.update() { if bashio::var.has_value "${version}"; then version=$(bashio::var.json version "${version}") - bashio::api.hassio POST /supervisor/update "${version}" + bashio::api.supervisor POST /supervisor/update "${version}" else - bashio::api.hassio POST /supervisor/update + bashio::api.supervisor POST /supervisor/update fi bashio::cache.flush_all } @@ -40,7 +40,7 @@ function bashio::supervisor.update() { # ------------------------------------------------------------------------------ function bashio::supervisor.reload() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio POST /supervisor/reload + bashio::api.supervisor POST /supervisor/reload bashio::cache.flush_all } @@ -49,7 +49,7 @@ function bashio::supervisor.reload() { # ------------------------------------------------------------------------------ function bashio::supervisor.logs() { bashio::log.trace "${FUNCNAME[0]}" - bashio::api.hassio GET /supervisor/logs true + bashio::api.supervisor GET /supervisor/logs true } # ------------------------------------------------------------------------------ @@ -75,7 +75,7 @@ function bashio::supervisor() { if bashio::cache.exists 'supervisor.info'; then info=$(bashio::cache.get 'supervisor.info') else - info=$(bashio::api.hassio GET /supervisor/info false) + info=$(bashio::api.supervisor GET /supervisor/info false) bashio::cache.set 'supervisor.info' "${info}" fi @@ -146,7 +146,7 @@ function bashio::supervisor.channel() { if bashio::var.has_value "${channel}"; then channel=$(bashio::var.json channel "${channel}") - bashio::api.hassio POST /supervisor/options "${channel}" + bashio::api.supervisor POST /supervisor/options "${channel}" bashio::cache.flush_all else bashio::supervisor 'supervisor.info.channel' '.channel // false' @@ -166,7 +166,7 @@ function bashio::supervisor.timezone() { if bashio::var.has_value "${timezone}"; then channel=$(bashio::var.json timezone "${timezone}") - bashio::api.hassio POST /supervisor/options "${timezone}" + bashio::api.supervisor POST /supervisor/options "${timezone}" bashio::cache.flush_all else bashio::supervisor 'supervisor.info.timezone' '.timezone' @@ -186,7 +186,7 @@ function bashio::supervisor.logging() { if bashio::var.has_value "${logging}"; then logging=$(bashio::var.json logging "${logging}") - bashio::api.hassio POST /supervisor/options "${logging}" + bashio::api.supervisor POST /supervisor/options "${logging}" bashio::cache.flush_all else bashio::supervisor 'supervisor.info.logging' '.logging' @@ -214,7 +214,7 @@ function bashio::supervisor.wait_boot() { if bashio::var.has_value "${wait}"; then wait=$(bashio::var.json wait_boot "${wait}") - bashio::api.hassio POST /supervisor/options "${wait}" + bashio::api.supervisor POST /supervisor/options "${wait}" bashio::cache.flush_all else bashio::supervisor 'supervisor.info.wait_boot' '.wait_boot' @@ -238,7 +238,7 @@ function bashio::supervisor.debug() { else debug=$(bashio::var.json debug "^false") fi - bashio::api.hassio POST /supervisor/options "${debug}" + bashio::api.supervisor POST /supervisor/options "${debug}" bashio::cache.flush_all else bashio::supervisor 'supervisor.info.debug' '.debug // false' @@ -262,7 +262,7 @@ function bashio::supervisor.debug_block() { else debug=$(bashio::var.json debug_block "^false") fi - bashio::api.hassio POST /supervisor/options "${debug}" + bashio::api.supervisor POST /supervisor/options "${debug}" bashio::cache.flush_all else bashio::supervisor 'supervisor.info.debug_block' '.debug_block // false' @@ -308,7 +308,7 @@ function bashio::supervisor.stats() { if bashio::cache.exists 'supervisor.stats'; then info=$(bashio::cache.get 'supervisor.stats') else - info=$(bashio::api.hassio GET /supervisor/stats false) + info=$(bashio::api.supervisor GET /supervisor/stats false) bashio::cache.set 'supervisor.stats' "${info}" fi