@@ -14,6 +14,7 @@ var reservePercentage = flag.Int64("backupPercentage", -1, "backup percentage to
1414var operationMode = flag .String ("operationMode" , "" , "operating mode: self_consumption, autonomous, backup" )
1515var gridExport = flag .String ("gridExport" , "" , "grid export rule: battery_ok, pv_only, never" )
1616var gridCharging = flag .String ("gridCharging" , "" , "grid charging enabled: true, false" )
17+ var stormMode = flag .String ("stormMode" , "" , "storm mode enabled: true, false" )
1718
1819// example that demos fetching of site information and optionally setting the battery reserve percentage for the site
1920func main () {
@@ -24,13 +25,13 @@ func main() {
2425 os .Exit (1 )
2526 }
2627
27- if err := run (context .Background (), * tokenPath , * reservePercentage , * operationMode , * gridExport , * gridCharging ); err != nil {
28+ if err := run (context .Background (), * tokenPath , * reservePercentage , * operationMode , * gridExport , * gridCharging , * stormMode ); err != nil {
2829 fmt .Println (err )
2930 os .Exit (1 )
3031 }
3132}
3233
33- func run (ctx context.Context , tokenPath string , reservePercentage int64 , operationMode , gridExport , gridCharging string ) error {
34+ func run (ctx context.Context , tokenPath string , reservePercentage int64 , operationMode , gridExport , gridCharging , stormMode string ) error {
3435 c , err := tesla .NewClient (ctx , tesla .WithTokenFile (tokenPath ))
3536 if err != nil {
3637 return err
@@ -89,6 +90,13 @@ func run(ctx context.Context, tokenPath string, reservePercentage int64, operati
8990 os .Exit (1 )
9091 }
9192 }
93+ if stormMode != "" {
94+ enabled := stormMode == "true"
95+ if err := es .SetStormMode (enabled ); err != nil {
96+ fmt .Printf ("error setting storm mode: %+v\n " , err )
97+ os .Exit (1 )
98+ }
99+ }
92100 }
93101 }
94102 return nil
0 commit comments