From 2af8a7a1dd73535314b96b326d65d515b394fef2 Mon Sep 17 00:00:00 2001 From: Peter Teich Date: Sat, 11 Apr 2020 11:03:30 +0200 Subject: [PATCH] add setting for storage path --- README.md | 3 ++- config/config.go | 17 ++++++++++------- main.go | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 67a8be4..20d8998 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ Compile (`make build-arm` for Raspberry Pis) and run ESPHomeKit with a specific **Commandline flags:** `-pin` the 8 digit pin for HomeKit -`-config` path to config file with all you accessories +`-config` path to config file with all you accessories (default: ./accessories.json) +`-storage` path storage for HomeKit transport data (default: ./) `-logConsole` log in human readable format to console, otherwise json log is created `-logLevel` one of debug info or error - defaults to debug diff --git a/config/config.go b/config/config.go index 63933cb..fb56799 100644 --- a/config/config.go +++ b/config/config.go @@ -3,17 +3,20 @@ package config import "github.com/pteich/configstruct" type Config struct { - LogLevel string `cli:"logLevel"` - LogConsole bool `cli:"logConsole"` - Pin string `cli:"pin"` - ConfigFile string `cli:"config"` + LogLevel string `cli:"logLevel" env:"LOG_LEVEL"` + LogConsole bool `cli:"logConsole" env:"LOG_CONSOLE"` + Pin string `cli:"pin" env:"HOMEKIT_PIN"` + ConfigFile string `cli:"config" env:"CONFIG_FILE"` + StoragePath string `cli:"storage" env:"STORAGE_PATH"` } func New() Config { cfg := Config{ - LogLevel: "debug", - LogConsole: false, - Pin: "12345678", + LogLevel: "debug", + LogConsole: false, + Pin: "12345678", + ConfigFile: "./accessories.json", + StoragePath: "./", } configstruct.Parse(&cfg) diff --git a/main.go b/main.go index 9b6cca8..beb0b81 100644 --- a/main.go +++ b/main.go @@ -67,7 +67,8 @@ func main() { log.Info().Int("count", len(deviceList)).Msg("add accessories") // init HomeKit ip connection with pin hcConfig := hc.Config{ - Pin: cfg.Pin, + Pin: cfg.Pin, + StoragePath: cfg.StoragePath, } hcTransport, err := hc.NewIPTransport(hcConfig, bridge.Accessory, deviceList.GetAccessories()...)