I’m converting a docker image to an addon and wanted to use the addon configuration options but I can’t seem to read the /data/options.json file.
The docker image is written in Go and when reading the options they seem to be empty. I want to clarify that I don’t experience any problems when outside of home assistant.
I don’t know much about the Go language so I may be mistaken
Here’s the part of the code that is responsible for the reading of the file.
viper.SetConfigName("options")
viper.SetConfigType("json")
viper.AddConfigPath(".")
viper.AddConfigPath("./data/")
viper.AddConfigPath("/data/")
err := viper.ReadInConfig()
if err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
fmt.Println("Config file not found, writing default config...")
//err := viper.SafeWriteConfig()
if err != nil {
panic(fmt.Errorf("error saving default config file: %s \n", err))
}
} else {
panic(fmt.Errorf("error reading config file: %s \n", err))
}
}
allSettings := viper.AllSettings()
// Pretty print as JSON
output, err := json.MarshalIndent(allSettings, "", " ")
fmt.Println(string(output))
Here is my config.yaml
name: "IP Camera Alarm Server"
description: "Universal Alarm Server for all your IP cameras in one place!"
version: "1.0.0"
slug: "ip_camera_alarm_server"
arch:
- aarch64
- amd64
- armhf
- armv7
- i386
url: "https://github.com/miroslav-pavlov/hassio-alarmserver"
boot: "auto"
ports:
15002/tcp: 15002
host_network: true
# map:
# - "config:rw"
options:
hisilicon:
enabled: true
port: 15002
ftp:
enabled: false
port: 21
password: "#dfV7fn%KfwVZhDKSzT"
allowFiles: true
rootPath: "./ftp"
mqtt:
enabled: true
username: mqtt-user
password: "Z9CVSuvjp0sbhg*@DfP"
port: 1883
server: "192.168.0.55"
topicroot: camera-alerts