Skip to content

Commit

Permalink
add setting for storage path
Browse files Browse the repository at this point in the history
  • Loading branch information
pteich committed Apr 11, 2020
1 parent a5be133 commit 2af8a7a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 10 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()...)
Expand Down

0 comments on commit 2af8a7a

Please sign in to comment.