-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
32 lines (26 loc) · 853 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
package main
import (
"fmt"
"os"
"github.com/SoftwareDefinedBuildings/bw2-contrib/driver/pelican/storage"
"github.com/SoftwareDefinedBuildings/bw2-contrib/driver/pelican/types"
"github.com/immesys/spawnpoint/spawnable"
_ "github.com/lib/pq"
)
func main() {
params := spawnable.GetParamsOrExit()
username := params.MustString("username")
password := params.MustString("password")
sitename := params.MustString("sitename")
pelicans, err := types.DiscoverPelicans(username, password, sitename)
if err != nil {
fmt.Printf("Failed to discover Pelican thermostats: %s\n", err)
os.Exit(1)
}
fmt.Printf("Discovered %d Pelican(s), writing to remote DB...\n", len(pelicans))
if err = storage.WritePelicans(pelicans, sitename); err != nil {
fmt.Printf("Failed to write to database: %s\n", err)
os.Exit(1)
}
fmt.Println("Success!")
}