tplinkcmd/cmd/tpstate/config.go
2021-12-09 16:28:45 -06:00

50 lines
1.2 KiB
Go

package main
import (
"os"
"time"
"github.com/hashicorp/logutils"
"github.com/kelvins/sunrisesunset"
)
type configStructure struct {
// time configuration
TimeFormat string `json:"time_format"`
TimeZone *time.Location `json:"time_zone"`
// logging
LogLevel int `json:"log_level"`
Log *logutils.LevelFilter `json:"log_level_fileter"`
//sunriseset configuration
SunRiseSet *sunrisesunset.Parameters `json:"sun_rise_set_configuration"`
// mode of operation
CalculateDate time.Time `json:"sunrise_sunset_calculation_date"`
SecondsUntil bool `json:"seconds_until"`
NextSunrise bool `json:"next_sunrise"`
NextSunset bool `json:"next_sunset"`
GetState bool `json:"get_state"`
On bool `json:"on"`
Off bool `json:"off"`
// Host
Host string `json:"hostname"`
DeviceID int `json:"device_id"`
}
// Set Defaults
var config = configStructure{
LogLevel: 50,
TimeFormat: "2006-01-02 15:04:05",
Log: &logutils.LevelFilter{
Levels: []logutils.LogLevel{"TRACE", "DEBUG", "INFO", "WARNING", "ERROR"},
Writer: os.Stderr,
},
SunRiseSet: &sunrisesunset.Parameters{
Latitude: 38.749020,
Longitude: -90.521360,
},
}