62 lines
2.0 KiB
Bash
62 lines
2.0 KiB
Bash
#!/usr/bin/with-contenv bashio
|
|
set -euo pipefail
|
|
|
|
export ADVERTISE_IP="$(bashio::config 'advertise_ip')"
|
|
export TZ="$(bashio::config 'timezone')"
|
|
export LOG_LEVEL="$(bashio::config 'log_level')"
|
|
|
|
mqtt_source=""
|
|
if bashio::services.available "mqtt"; then
|
|
export MQTT_HOST="$(bashio::services mqtt 'host')"
|
|
export MQTT_PORT="$(bashio::services mqtt 'port')"
|
|
export MQTT_USERNAME="$(bashio::services mqtt 'username')"
|
|
export MQTT_PASSWORD="$(bashio::services mqtt 'password')"
|
|
export MQTT_TLS="$(bashio::services mqtt 'ssl')"
|
|
mqtt_source="Supervisor MQTT service"
|
|
fi
|
|
|
|
export_option() {
|
|
local option="$1"
|
|
local variable="$2"
|
|
if bashio::config.exists "${option}"; then
|
|
export "${variable}=$(bashio::config "${option}")"
|
|
if [[ "${option}" == mqtt_* ]]; then
|
|
if [[ -n "${mqtt_source}" ]]; then
|
|
mqtt_source="${mqtt_source} with option overrides"
|
|
else
|
|
mqtt_source="add-on options"
|
|
fi
|
|
fi
|
|
fi
|
|
}
|
|
|
|
export_option bind_address BIND_ADDRESS
|
|
export_option port_lookup PORT_LOOKUP
|
|
export_option port_firmware PORT_FIRMWARE
|
|
export_option port_xmpp PORT_XMPP
|
|
export_option health_port HEALTH_PORT
|
|
export_option mqtt_host MQTT_HOST
|
|
export_option mqtt_port MQTT_PORT
|
|
export_option mqtt_tls MQTT_TLS
|
|
export_option mqtt_ca_file MQTT_CA_FILE
|
|
export_option mqtt_username MQTT_USERNAME
|
|
export_option mqtt_password MQTT_PASSWORD
|
|
export_option mqtt_client_id MQTT_CLIENT_ID
|
|
export_option mqtt_base MQTT_BASE
|
|
export_option ha_discovery_prefix HA_DISCOVERY_PREFIX
|
|
export_option controller_jid CONTROLLER_JID
|
|
export_option raw_commands RAW_COMMANDS
|
|
|
|
if [[ -z "${MQTT_HOST:-}" ]]; then
|
|
bashio::log.fatal "No MQTT broker is available. Configure a Supervisor MQTT service or set mqtt_host."
|
|
exit 1
|
|
fi
|
|
|
|
bashio::log.info "Starting Deebot N95 Local Control"
|
|
bashio::log.info "Advertising ${ADVERTISE_IP}; MQTT settings from ${mqtt_source}"
|
|
if [[ "${RAW_COMMANDS:-false}" == "true" ]]; then
|
|
bashio::log.warning "Raw MQTT commands are enabled; use them only for protocol testing."
|
|
fi
|
|
|
|
exec /n95bridge
|