-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
discovery.sh
46 lines (40 loc) · 1.49 KB
/
discovery.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
# ==============================================================================
# Home Assistant Community Add-ons: Bashio
# Bashio is a 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.
# ==============================================================================
# ------------------------------------------------------------------------------
# Publish a new configuration object for discovery.
#
# Arguments:
# $1 Service name
# $2 Configuration object (JSON)
# ------------------------------------------------------------------------------
function bashio::discovery() {
local service=${1}
local config=${2}
local payload
bashio::log.trace "${FUNCNAME[0]}:" "$@"
payload=$(\
bashio::var.json \
service "${service}" \
config "^${config}" \
)
bashio::api.supervisor "POST" "/discovery" "${payload}" ".uuid"
bashio::cache.flush_all
}
# ------------------------------------------------------------------------------
# Deletes configuration object for this discovery.
#
# Arguments:
# $1 Discovery UUID
# ------------------------------------------------------------------------------
function bashio::discovery.delete() {
local uuid=${1}
bashio::log.trace "${FUNCNAME[0]}:" "$@"
bashio::api.supervisor "DELETE" "/discovery/${uuid}"
bashio::cache.flush_all
}