Skip to content

Commit 76ad359

Browse files
committed
feat: add support for config via homeassistant addon
1 parent 21cc812 commit 76ad359

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

main.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,23 @@ import (
99
"github.com/rs/zerolog"
1010
"github.com/rs/zerolog/log"
1111
"github.com/spf13/viper"
12+
"os"
1213
"strings"
1314
"time"
1415
)
1516

1617
func main() {
1718

18-
log.Info().Msg("starting frigabun")
19-
log.Info().Msg("reading config")
19+
_, err := os.Stat("/data/options.json")
20+
if err != nil {
21+
viper.AddConfigPath(".")
22+
viper.SetConfigType("toml")
23+
} else {
24+
viper.AddConfigPath("/data")
25+
viper.SetConfigName("options")
26+
}
2027

21-
viper.SetConfigName("config")
22-
viper.SetConfigType("toml")
23-
viper.AddConfigPath(".")
24-
err := viper.ReadInConfig()
28+
err = viper.ReadInConfig()
2529
if err != nil {
2630
log.Fatal().Err(err).Msg("could not read config file")
2731
}

0 commit comments

Comments
 (0)