22
33# ---- Imports ----
44import sys
5- from typing import Any , Dict , List , Optional
5+ from typing import Any , Dict , List
66
77from jsonargparse import ArgumentParser , DefaultHelpFormatter
88from pydantic import SecretStr
@@ -86,7 +86,7 @@ def parse_config(prog: str, version: str, copy_right: str, author: str, arg_list
8686 arg_parser .add_argument (
8787 "-o" ,
8888 "--output" ,
89- type = Optional [ str ] ,
89+ type = str | None ,
9090 help = "Path of JSON output file. If not set JSON output is written to console / stdout" ,
9191 )
9292
@@ -103,7 +103,7 @@ def parse_config(prog: str, version: str, copy_right: str, author: str, arg_list
103103 )
104104 arg_parser .add_argument (
105105 "--connection.address" ,
106- type = Optional [ str ] ,
106+ type = str | None ,
107107 help = """IP or DNS address of the E3/DC system.
108108Only relevant for connection type 'local'.
109109""" ,
@@ -120,14 +120,14 @@ def parse_config(prog: str, version: str, copy_right: str, author: str, arg_list
120120 )
121121 arg_parser .add_argument (
122122 "--connection.rscp_password" ,
123- type = Optional [ SecretStr ] ,
123+ type = SecretStr | None ,
124124 help = """RSCP password. Set on the device via Main Page -> Personalize -> User profile -> RSCP password.
125125Only relevant for connection type 'local',
126126""" ,
127127 )
128128 arg_parser .add_argument (
129129 "--connection.serial_number" ,
130- type = Optional [ SecretStr ] ,
130+ type = SecretStr | None ,
131131 help = """Serial number of the system (see 'SN' in E3/DC portal).
132132Only relevant for connection type 'web'.
133133""" ,
@@ -168,7 +168,7 @@ def parse_config(prog: str, version: str, copy_right: str, author: str, arg_list
168168 # ---- Setter ----
169169 arg_parser .add_argument (
170170 "--set.power_limits.enable" ,
171- type = Optional [ bool ] ,
171+ type = bool | None ,
172172 metavar = "{true,false}" ,
173173 help = """true: enable manual SmartPower limits. false: Use automatic mode.
174174Automatically set to 'true' if not explicitly set and any other manual limit
@@ -177,23 +177,23 @@ def parse_config(prog: str, version: str, copy_right: str, author: str, arg_list
177177 )
178178 arg_parser .add_argument (
179179 "--set.power_limits.max_charge" ,
180- type = Optional [ int ] ,
180+ type = int | None ,
181181 help = """SmartPower maximum charging power. Unit: Watt.
182182Automatically set to the systems max. battery charge power limit if not explicitly set.
183183Only relevant if set.power_limits.enable is 'true' or not explicitly configured.
184184""" ,
185185 )
186186 arg_parser .add_argument (
187187 "--set.power_limits.max_discharge" ,
188- type = Optional [ int ] ,
188+ type = int | None ,
189189 help = """SmartPower maximum discharging power. Unit: Watt.
190190Automatically set to the systems max. battery discharge power limit if not explicitly set.
191191Only relevant if set.power_limits.enable is 'true' or not explicitly configured.
192192""" ,
193193 )
194194 arg_parser .add_argument (
195195 "--set.power_limits.discharge_start" ,
196- type = Optional [ int ] ,
196+ type = int | None ,
197197 help = """SmartPower lower charge / discharge threshold. Unit: Watt.
198198Automatically set to the systems discharge default threshold if not explicitly set.
199199Only relevant if set.power_limits.enable is 'true' or not explicitly configured.
@@ -202,13 +202,13 @@ def parse_config(prog: str, version: str, copy_right: str, author: str, arg_list
202202
203203 arg_parser .add_argument (
204204 "--set.powersave" ,
205- type = Optional [ bool ] ,
205+ type = bool | None ,
206206 metavar = "{true,false}" ,
207207 help = "Enable / Disable PowerSave of the inverter (inverter switches to standby mode when not in use)." ,
208208 )
209209 arg_parser .add_argument (
210210 "--set.weather_regulated_charge" ,
211- type = Optional [ bool ] ,
211+ type = bool | None ,
212212 metavar = "{true,false}" ,
213213 help = "Enabled / Disable optimized charging based on the weather forecast." ,
214214 )
0 commit comments