-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add write support for charging-limit, discharge-limit, output-power
- Loading branch information
1 parent
2a8b11b
commit e876b64
Showing
11 changed files
with
382 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,10 @@ | ||
github.com/eclipse/paho.mqtt.golang v1.4.3 h1:2kwcUGn8seMUfWndX0hGbvH8r7crgcJguQNCyp70xik= | ||
github.com/eclipse/paho.mqtt.golang v1.4.3/go.mod h1:CSYvoAlsMkhYOXh/oKyxa8EcBci6dVkLCbo5tTC1RIE= | ||
github.com/eclipse/paho.mqtt.golang v1.5.0 h1:EH+bUVJNgttidWFkLLVKaQPGmkTUfQQqjOsyvMGvD6o= | ||
github.com/eclipse/paho.mqtt.golang v1.5.0/go.mod h1:du/2qNQVqJf/Sqs4MEL77kR8QTqANF7XU7Fk0aOTAgk= | ||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= | ||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= | ||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= | ||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= | ||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= | ||
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= | ||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= | ||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= | ||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= | ||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= | ||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= | ||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package growatt | ||
|
||
import ( | ||
"crypto/md5" | ||
"encoding/binary" | ||
"encoding/hex" | ||
"fmt" | ||
"github.com/google/uuid" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
func hashPassword(password string) string { | ||
hash := md5.Sum([]byte(password)) | ||
digest := hex.EncodeToString(hash[:]) | ||
|
||
for i := 0; i < len(digest); i = i + 2 { | ||
if digest[i] == '0' { | ||
digest = digest[:i] + "c" + digest[i+1:] | ||
} | ||
} | ||
|
||
return digest | ||
} | ||
|
||
func timestamp() string { | ||
// Get the current time in milliseconds and convert it to a string | ||
valueOf := strconv.FormatInt(time.Now().UnixMilli(), 10) | ||
|
||
// Extract characters at positions 1, 3, 5, and 7 | ||
extracted := string(valueOf[1]) + string(valueOf[3]) + string(valueOf[5]) + string(valueOf[7]) | ||
|
||
// Parse the extracted string to an integer and take modulo 98 | ||
parsedInt, _ := strconv.Atoi(extracted) | ||
parsedInt %= 98 | ||
|
||
// Start building the final string | ||
result := valueOf[:11] | ||
|
||
// Conditionally format the parsed integer | ||
if parsedInt < 10 { | ||
result += "0" + strconv.Itoa(parsedInt) | ||
} else { | ||
result += strconv.Itoa(parsedInt) | ||
} | ||
|
||
return result | ||
} | ||
|
||
func ipvcpc(username string) string { | ||
hash := []byte(hashPassword(username + "★☆i₰₭" + fmt.Sprintf("%d", time.Now().UnixMilli()))) | ||
hashCode := int64(binary.LittleEndian.Uint64(hash[:8])) | ||
|
||
// Create a UUID using the hash code as the most significant bits and a fixed number for the least significant bits. | ||
u := uuid.New() | ||
u[0] = byte(hashCode >> 56) | ||
u[1] = byte(hashCode >> 48) | ||
u[2] = byte(hashCode >> 40) | ||
u[3] = byte(hashCode >> 32) | ||
u[4] = byte(hashCode >> 24) | ||
u[5] = byte(hashCode >> 16) | ||
u[6] = byte(hashCode >> 8) | ||
u[7] = byte(hashCode) | ||
|
||
// Convert to string and return. | ||
return u.String() | ||
} |
Oops, something went wrong.