Repository: wimaha/TeslaBleHttpProxy (language: go)

Issue:
setting charge limit?
any chance to add support for set_charge_limit? I have made a request to EVCC to allow viewing current charge limit via MQTT and setting max SOC. 

https://github.com/evcc-io/evcc/issues/14440#issue-2357698189


Discussion / hints:
This will be added in the next version. But I think evcc won't support it.

Fix patch:
diff --git a/main.go b/main.go
index 023554c..286dce8 100644
--- a/main.go
+++ b/main.go
@@ -39,7 +39,7 @@ type Command struct {
 
 var privateKeyFile = "key/private.pem"
 
-var exceptedCommands = []string{"flash_lights", "wake_up", "set_charging_amps", "charge_start", "charge_stop", "session_info"}
+var exceptedCommands = []string{"flash_lights", "wake_up", "set_charging_amps", "set_charge_limit", "charge_start", "charge_stop", "session_info"}
 
 type Stack []Command
 
@@ -296,6 +296,18 @@ func executeCommand(body map[string]interface{}, command string, vin string, pri
 		} else {
 			return false, fmt.Errorf("charing Amps missing in body")
 		}
+	case "set_charge_limit":
+		if chargeLimitString, ok := body["percent"].(string); ok {
+			if chargeLimit, err := strconv.ParseInt(chargeLimitString, 10, 32); err == nil {
+				if err := car.ChangeChargeLimit(ctx, int32(chargeLimit)); err != nil {
+					return true, fmt.Errorf("failed to set charge limit to %d %%: %s", chargeLimit, err)
+				}
+			} else {
+				return false, fmt.Errorf("charge limit parsing error: %s", err)
+			}
+		} else {
+			return false, fmt.Errorf("charge limit missing in body")
+		}
 	case "session_info":
 		publicKey, err := protocol.LoadPublicKey("key/public.pem")
 		if err != nil {


Test patch: