fix: sync and fetch temperatures
changes: - add sync command to synchronize device sensor information with remote servers - fix fetch functions to get temperatures
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
"git.cryptic.systems/fh-trier/go-flucky/cmd/config"
|
||||
"git.cryptic.systems/fh-trier/go-flucky/cmd/remote"
|
||||
"git.cryptic.systems/fh-trier/go-flucky/cmd/sensor"
|
||||
"git.cryptic.systems/fh-trier/go-flucky/cmd/temperature"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -23,7 +24,7 @@ func Execute(version string) {
|
||||
config.InitCmd(rootCmd, configDir)
|
||||
remote.InitCmd(rootCmd, configDir)
|
||||
sensor.InitCmd(rootCmd, configDir)
|
||||
//temperature.InitCmd(rootCmd, configDir)
|
||||
temperature.InitCmd(rootCmd, configDir)
|
||||
|
||||
rootCmd.Execute()
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ var configDir string
|
||||
var configCmd = &cobra.Command{
|
||||
Use: "config",
|
||||
Short: "Manage Configuration",
|
||||
Args: cobra.ExactArgs(2),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if args[0] == "device.name" {
|
||||
config.DeviceName(args[1], configDir)
|
||||
|
@ -1,26 +0,0 @@
|
||||
package remote
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"git.cryptic.systems/fh-trier/go-flucky/pkg/httpcall"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var force bool
|
||||
|
||||
var registerRemoteCmd = &cobra.Command{
|
||||
Use: "register",
|
||||
Short: "register on remote servers",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
if err := httpcall.RegisterDevice(configDir, force); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
remoteCmd.AddCommand(registerRemoteCmd)
|
||||
registerRemoteCmd.Flags().BoolVarP(&force, "force", "f", false, "Force register on a remote server")
|
||||
}
|
26
cmd/remote/sync.go
Normal file
26
cmd/remote/sync.go
Normal file
@ -0,0 +1,26 @@
|
||||
package remote
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"git.cryptic.systems/fh-trier/go-flucky/pkg/httpcall"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var force bool
|
||||
|
||||
var syncRemoteCmd = &cobra.Command{
|
||||
Use: "sync",
|
||||
Short: "Synchronise Device Values with Remote Servers",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
if err := httpcall.SyncDevice(configDir, force); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
remoteCmd.AddCommand(syncRemoteCmd)
|
||||
syncRemoteCmd.Flags().BoolVarP(&force, "force", "f", false, "Include disabled remote links")
|
||||
}
|
@ -15,7 +15,7 @@ var addSensorCmd = &cobra.Command{
|
||||
Short: "Add Sensor",
|
||||
Args: cobra.ExactArgs(3),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if err := sensor.Add(&args[0], &sensorLocation, &args[1], &wireID, &args[2], wirePath, configDir, enabled); err != nil {
|
||||
if err := sensor.Add(&args[0], &sensorLocation, &args[1], &wireID, &args[2], wirePath, configDir, &enabled); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
},
|
||||
|
26
cmd/sensor/sync.go
Normal file
26
cmd/sensor/sync.go
Normal file
@ -0,0 +1,26 @@
|
||||
package sensor
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"git.cryptic.systems/fh-trier/go-flucky/pkg/httpcall"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var force bool
|
||||
|
||||
var syncSensorCmd = &cobra.Command{
|
||||
Use: "sync",
|
||||
Short: "Synchronise Sensors with Remote Servers",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
if err := httpcall.SyncSensors(configDir, force); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
sensorCmd.AddCommand(syncSensorCmd)
|
||||
syncSensorCmd.Flags().BoolVarP(&force, "force", "f", false, "Include disabled remote links")
|
||||
}
|
Reference in New Issue
Block a user