Compare commits

...

16 commits

Author SHA1 Message Date
Stefan Agner
5059ff133e
Add Supervisor country (#165) 2025-04-29 11:37:24 +02:00
Stefan Agner
445707a903
Avoid caching when API call fails (#164) 2025-04-22 12:28:35 +02:00
Franck Nijhof
d70505aada
🎆 Updates maintenance/license year to 2025 (#161) 2025-02-16 12:09:54 +01:00
dependabot[bot]
e297fa5c2c
Bump release-drafter/release-drafter from 6.0.0 to 6.1.0 (#160) 2025-01-20 07:55:54 +01:00
dependabot[bot]
c6de3e5756
Bump frenck/action-yamllint from 1.4 to 1.5 (#156) 2024-02-19 07:50:29 +01:00
dependabot[bot]
b0219ef6f1
Bump release-drafter/release-drafter from 5.25.0 to 6.0.0 (#153) 2024-02-02 07:34:51 +01:00
hrzlgnm
2b21846d28
Fix typo in var.true() and var.false() documentation (#151) 2024-01-17 10:18:35 +01:00
hrzlgnm
dc3e044064
Fix duplicated bashio::network.enabled() function (#152) 2024-01-17 08:24:43 +01:00
Franck Nijhof
f3bd57130c
🎆 Updates maintenance/license year to 2024 (#150) 2024-01-06 22:41:28 +01:00
Bao
324f46b5c4
Fix exit code when calling supervisor api with raw=true (#148) 2023-12-08 10:14:39 +01:00
Bao
8b96a704cc
Fix arguments for sourced script (#147) 2023-12-08 10:13:11 +01:00
dependabot[bot]
68464b7655
Bump actions/stale from 8 to 9 (#149)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-08 08:51:27 +01:00
Bao
2de0c2304a
Properly quote replacment string in param expansion (#146) 2023-12-07 10:54:46 +01:00
dependabot[bot]
fe0f961efc
Bump dessant/lock-threads from 5.0.0 to 5.0.1 (#145)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-23 08:56:39 +01:00
dependabot[bot]
e98156103b
Bump dessant/lock-threads from 4.0.1 to 5.0.0 (#144)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-14 08:24:05 +01:00
Laszlo Magyar
52d3a9b40c
Fix comment/docs typo in info.state (#143) 2023-10-23 12:20:23 +02:00
25 changed files with 142 additions and 16 deletions

View file

@ -39,7 +39,7 @@ jobs:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4
- name: 🚀 Run YAMLLint
uses: frenck/action-yamllint@v1.4
uses: frenck/action-yamllint@v1.5
lint-prettier:
name: Prettier

View file

@ -12,7 +12,7 @@ jobs:
name: 🔒 Lock closed issues and PRs
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v4.0.1
- uses: dessant/lock-threads@v5.0.1
with:
github-token: ${{ github.token }}
issue-inactive-days: "30"

View file

@ -13,6 +13,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🚀 Run Release Drafter
uses: release-drafter/release-drafter@v5.25.0
uses: release-drafter/release-drafter@v6.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🚀 Run stale
uses: actions/stale@v8
uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 30

View file

@ -1,6 +1,6 @@
# MIT License
Copyright (c) 2019-2023 Franck Nijhof
Copyright (c) 2019-2025 Franck Nijhof
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -147,7 +147,7 @@ check [the contributor's page][contributors].
MIT License
Copyright (c) 2019-2023 Franck Nijhof
Copyright (c) 2019-2025 Franck Nijhof
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -185,7 +185,7 @@ SOFTWARE.
[issue]: https://github.com/hassio-addons/bashio/issues
[keepchangelog]: http://keepachangelog.com/en/1.0.0/
[license-shield]: https://img.shields.io/github/license/hassio-addons/bashio.svg
[maintenance-shield]: https://img.shields.io/maintenance/yes/2023.svg
[maintenance-shield]: https://img.shields.io/maintenance/yes/2025.svg
[patreon-shield]: https://frenck.dev/wp-content/uploads/2019/12/patreon.png
[patreon]: https://www.patreon.com/frenck
[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg

View file

@ -164,6 +164,10 @@ function bashio::addons() {
info=$(bashio::cache.get 'addons.list')
else
info=$(bashio::api.supervisor GET "/addons" false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get addons from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set "addons.list" "${info}"
fi
else
@ -171,6 +175,10 @@ function bashio::addons() {
info=$(bashio::cache.get "addons.${slug}.info")
else
info=$(bashio::api.supervisor GET "/addons/${slug}/info" false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get addon info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set "addons.${slug}.info" "${info}"
fi
fi
@ -1202,6 +1210,10 @@ function bashio::addon.stats() {
info=$(bashio::cache.get "addons.${slug}.stats")
else
info=$(bashio::api.supervisor GET "/addons/${slug}/stats" false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get addon stats from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set "addons.${slug}.stats" "${info}"
fi

View file

@ -93,7 +93,7 @@ function bashio::api.supervisor() {
if bashio::var.true "${raw}"; then
echo "${response}"
return "${__BASHIO_EXIT_NOK}"
return "${__BASHIO_EXIT_OK}"
fi
result=$(bashio::jq "${response}" 'if .data == {} then empty else .data end')

View file

@ -77,6 +77,10 @@ function bashio::audio() {
info=$(bashio::cache.get 'audio.info')
else
info=$(bashio::api.supervisor GET /audio/info false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get audio info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'audio.info' "${info}"
fi
@ -147,6 +151,10 @@ function bashio::audio.stats() {
info=$(bashio::cache.get 'audio.stats')
else
info=$(bashio::api.supervisor GET /audio/stats false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get audio stats from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'audio.stats' "${info}"
fi

View file

@ -22,5 +22,7 @@ __BASHIO_LIB_DIR=$(dirname "${__BASHIO_BIN}")
source "${__BASHIO_LIB_DIR}/bashio.sh"
# Execute source
BASH_ARGV0=${1:?script to source must be provided}
shift
# shellcheck source=/dev/null
source "$@"
source "$0" "$@"

View file

@ -51,6 +51,10 @@ function bashio::cli() {
info=$(bashio::cache.get 'cli.info')
else
info=$(bashio::api.supervisor GET /cli/info false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get cli info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'cli.info' "${info}"
fi
@ -113,6 +117,10 @@ function bashio::cli.stats() {
info=$(bashio::cache.get 'cli.stats')
else
info=$(bashio::api.supervisor GET /cli/stats false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get cli stats from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'cli.stats' "${info}"
fi

View file

@ -99,6 +99,10 @@ function bashio::core() {
info=$(bashio::cache.get 'core.info')
else
info=$(bashio::api.supervisor GET /core/info false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get core info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'core.info' "${info}"
fi
@ -249,6 +253,10 @@ function bashio::core.stats() {
info=$(bashio::cache.get 'core.stats')
else
info=$(bashio::api.supervisor GET /core/stats false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get core stats from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'core.stats' "${info}"
fi

View file

@ -77,6 +77,10 @@ function bashio::dns() {
info=$(bashio::cache.get 'dns.info')
else
info=$(bashio::api.supervisor GET /dns/info false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get dns info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'dns.info' "${info}"
fi
@ -163,6 +167,10 @@ function bashio::dns.stats() {
info=$(bashio::cache.get 'dns.stats')
else
info=$(bashio::api.supervisor GET /dns/stats false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get dns stats from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'dns.stats' "${info}"
fi

View file

@ -31,6 +31,10 @@ function bashio::hardware() {
info=$(bashio::cache.get 'hardware.info')
else
info=$(bashio::api.supervisor GET /hardware/info false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get hardware info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'hardware.info' "${info}"
fi

View file

@ -63,6 +63,10 @@ function bashio::host() {
info=$(bashio::cache.get 'host.info')
else
info=$(bashio::api.supervisor GET /host/info false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get host info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'host.info' "${info}"
fi

View file

@ -31,6 +31,10 @@ function bashio::info() {
info=$(bashio::cache.get 'info')
else
info=$(bashio::api.supervisor GET /info false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'info' "${info}"
fi
@ -150,7 +154,7 @@ function bashio::info.operating_system() {
}
# ------------------------------------------------------------------------------
# Returns the current state of Home Assistant Core
# Returns the current state of Home Assistant Supervisor
# ------------------------------------------------------------------------------
function bashio::info.state() {
bashio::log.trace "${FUNCNAME[0]}"

View file

@ -111,9 +111,9 @@ function bashio::log.log() {
timestamp=$(date +"${__BASHIO_LOG_TIMESTAMP}")
output="${__BASHIO_LOG_FORMAT}"
output="${output//\{TIMESTAMP\}/${timestamp}}"
output="${output//\{MESSAGE\}/${message}}"
output="${output//\{LEVEL\}/${__BASHIO_LOG_LEVELS[$level]}}"
output="${output//\{TIMESTAMP\}/"${timestamp}"}"
output="${output//\{MESSAGE\}/"${message}"}"
output="${output//\{LEVEL\}/"${__BASHIO_LOG_LEVELS[$level]}"}"
echo -e "${output}" >&2

View file

@ -68,6 +68,10 @@ function bashio::multicast() {
info=$(bashio::cache.get 'multicast.info')
else
info=$(bashio::api.supervisor GET /multicast/info false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get multicast info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'multicast.info' "${info}"
fi
@ -130,6 +134,10 @@ function bashio::multicast.stats() {
info=$(bashio::cache.get 'multicast.stats')
else
info=$(bashio::api.supervisor GET /multicast/stats false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get multicast stats from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'multicast.stats' "${info}"
fi

View file

@ -41,6 +41,10 @@ function bashio::network() {
info=$(bashio::cache.get 'network.info')
else
info=$(bashio::api.supervisor GET /network/info false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get network info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'network.info' "${info}"
fi
@ -105,6 +109,10 @@ function bashio::network.interface() {
info=$(bashio::cache.get "network.interface.${interface}.info")
else
info=$(bashio::api.supervisor GET "/network/interface/${interface}/info" false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get network interface info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set "network.interface.${interface}.info" "${info}"
fi
@ -164,7 +172,7 @@ function bashio::network.enabled() {
# Arguments:
# $1 Interface name for this operation (optional)
# ------------------------------------------------------------------------------
function bashio::network.enabled() {
function bashio::network.connected() {
local interface=${1:-'default'}
bashio::log.trace "${FUNCNAME[0]}"

View file

@ -51,6 +51,10 @@ function bashio::observer() {
info=$(bashio::cache.get 'observer.info')
else
info=$(bashio::api.supervisor GET /observer/info false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get observer info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'observer.info' "${info}"
fi
@ -121,6 +125,10 @@ function bashio::observer.stats() {
info=$(bashio::cache.get 'observer.stats')
else
info=$(bashio::api.supervisor GET /observer/stats false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get observer stats from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'observer.stats' "${info}"
fi

View file

@ -59,6 +59,10 @@ function bashio::os() {
info=$(bashio::cache.get 'os.info')
else
info=$(bashio::api.supervisor GET /os/info false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get os info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'os.info' "${info}"
fi

View file

@ -34,6 +34,10 @@ function bashio::repositories() {
info=$(bashio::cache.get 'repositories.list')
else
info=$(bashio::api.supervisor GET "/addons" false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get addons from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set "repositories.list" "${info}"
fi
else
@ -42,6 +46,10 @@ function bashio::repositories() {
else
info=$(bashio::api.supervisor GET "/addons" \
false ".repositories[] | select(.slug==\"${slug}\")")
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get repositories info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set "repositories.${slug}.info" "${info}"
fi
fi

View file

@ -28,6 +28,10 @@ function bashio::services() {
config=$(bashio::cache.get "${cache_key}")
else
config=$(bashio::api.supervisor GET "/services/${service}" false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get services from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set "${cache_key}" "${config}"
fi

View file

@ -76,6 +76,10 @@ function bashio::supervisor() {
info=$(bashio::cache.get 'supervisor.info')
else
info=$(bashio::api.supervisor GET /supervisor/info false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get supervisor info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'supervisor.info' "${info}"
fi
@ -178,6 +182,26 @@ function bashio::supervisor.timezone() {
fi
}
# ------------------------------------------------------------------------------
# Returns or sets the current country of the system.
#
# Arguments:
# $1 Country to set (optional).
# ------------------------------------------------------------------------------
function bashio::supervisor.country() {
local country=${1:-}
bashio::log.trace "${FUNCNAME[0]}:" "$@"
if bashio::var.has_value "${country}"; then
channel=$(bashio::var.json country "${country}")
bashio::api.supervisor POST /supervisor/options "${country}"
bashio::cache.flush_all
else
bashio::supervisor 'supervisor.info.country' '.country'
fi
}
# ------------------------------------------------------------------------------
# Returns the current logging level of the Supervisor.
#
@ -314,6 +338,10 @@ function bashio::supervisor.stats() {
info=$(bashio::cache.get 'supervisor.stats')
else
info=$(bashio::api.supervisor GET /supervisor/stats false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get supervisor stats from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set 'supervisor.stats' "${info}"
fi

View file

@ -8,7 +8,7 @@
# ==============================================================================
# ------------------------------------------------------------------------------
# Checks if a give value is true.
# Checks if a given value is true.
#
# Arguments:
# $1 value
@ -26,7 +26,7 @@ function bashio::var.true() {
}
# ------------------------------------------------------------------------------
# Checks if a give value is false.
# Checks if a given value is false.
#
# Arguments:
# $1 value