Skip to content

Commit

Permalink
fix(version)
Browse files Browse the repository at this point in the history
  • Loading branch information
atbore-phx committed Mar 2, 2024
1 parent aeceb77 commit 7b8b24b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=$(shell git describe --tags --abbrev=0 --always)
VERSION=$(shell git describe --tags --always)
COMMIT=$(shell git rev-parse --short HEAD)
DATE=$(shell date)

Expand All @@ -8,4 +8,4 @@ test:
go test ./...

build: test
CGO_ENABLED=0 go build -ldflags="-X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'" -o bin/ha-fronius-bm
CGO_ENABLED=0 go build -ldflags="-X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'" -o bin/ha-fronius-bm
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ import (
"ha-fronius-bm/pkg/cmd"
)

func main() {
var (
version = "dev"
commit = "HEAD"
date = "today"
)

func main() {
cmd.SetVersionInfo(version, commit, date)
cmd.Execute()

}
17 changes: 7 additions & 10 deletions pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,10 @@ import (
"github.com/spf13/viper"
)

var (
version = "dev"
commit = "HEAD"
date = "today"
)

var rootCmd = &cobra.Command{
Use: "ha-fronius-bm",
Short: "ha-fronius-bm handles battery charge using weather forecast",
Long: `initiate parameters from command line, env variables or config.yaml file.`,
Version: fmt.Sprintf("Version: %s\nCommit: %s\nDate: %s\n", version, commit, date),
Use: "ha-fronius-bm",
Short: "ha-fronius-bm handles battery charge using weather forecast",
Long: `initiate parameters from command line, env variables or config.yaml file.`,
}

func Execute() {
Expand Down Expand Up @@ -47,3 +40,7 @@ func init() {
fmt.Printf("Error reading config, %s", err)
}
}

func SetVersionInfo(version, commit, date string) {
rootCmd.Version = fmt.Sprintf("%s (Built on %s from Git SHA %s)", version, date, commit)
}
6 changes: 3 additions & 3 deletions pkg/fronius/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ func Setdefaults(modbus_ip string) error {
regList := mdsc
OpenModbusClient(modbus_ip)

WriteFroniusModbusRegisters(regList)
ReadFroniusModbusRegisters(regList)
WriteFroniusModbusRegisters(regList)

ClosemodbusClient()
u.Log.Info("Setting Fronius Modbus Defaults done.")
return nil
}

func ForceCharge(modbus_ip string, power_prc int16) error {
u.Log.Infof("Setting Fronius Storage Force Charge at %d% start...", power_prc)
u.Log.Infof("Setting Fronius Storage Force Charge at %d%", power_prc)
if power_prc > 0 {
regList := mdsc

Expand All @@ -86,8 +86,8 @@ func ForceCharge(modbus_ip string, power_prc int16) error {

OpenModbusClient(modbus_ip)

WriteFroniusModbusRegisters(regList)
ReadFroniusModbusRegisters(regList)
WriteFroniusModbusRegisters(regList)

ClosemodbusClient()
} else if power_prc == 0 {
Expand Down

0 comments on commit 7b8b24b

Please sign in to comment.