/
main.go
43 lines (36 loc) · 967 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"flag"
"time"
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
)
func main() {
var configFile = flag.String("c", "./config.yaml", "Specify path to config.yaml")
flag.Parse()
config := GetConfig(*configFile)
influxClient := influxdb2.NewClient(config.InfluxConfig.Url, config.InfluxConfig.Token)
// Weather agents
if config.AccuWeatherConfig.Enabled {
go AccuWeatherWriteWeather(config, influxClient)
}
if config.OpenWeatherMapConfig.Enabled {
go OpenWeatherMapWriteWeather(config, influxClient)
}
if config.WeatherGovConfig.Enabled {
go NwsWriteWeather(config, influxClient)
}
// Thermostat agents
if config.NestConfig.Enabled {
go NestRefreshLogin(config)
time.Sleep(time.Second * 10)
go WriteNest(config, influxClient)
}
if config.EcobeeConfig.Enabled {
go EcobeeRefreshLogin(config)
time.Sleep(time.Second * 10)
go WriteEcobee(config, influxClient)
}
for {
time.Sleep(time.Hour * 1)
}
}