@@ -161,17 +161,30 @@ def __setup_osmand(args: Namespace, config: Configuration) -> None:
161161
162162def setup_parser () -> argparse .ArgumentParser :
163163 parser = argparse .ArgumentParser (
164- prog = "MQTT Gateway" , formatter_class = ArgumentHelpFormatter
164+ prog = "SAIC MQTT Gateway" , formatter_class = ArgumentHelpFormatter
165165 )
166166
167+ __add_mqtt_argument_group (parser )
168+ __add_saic_api_argument_group (parser )
169+ __add_openwb_argument_group (parser )
170+ __add_homeassistant_argument_group (parser )
171+ __add_abrp_argument_group (parser )
172+ add_osmand_argument_group (parser )
173+
174+ return parser
175+
176+
177+ def __add_mqtt_argument_group (
178+ parser : argparse .ArgumentParser ,
179+ ) -> argparse ._ArgumentGroup :
167180 mqtt = parser .add_argument_group ("MQTT Broker Configuration" )
168181 mqtt .add_argument (
169182 "-m" ,
170183 "--mqtt-uri" ,
171184 help = """The URI to the MQTT Server.
172- TCP: tcp://mqtt.eclipseprojects.io:1883
173- WebSocket: ws://mqtt.eclipseprojects.io:9001
174- TLS: tls://mqtt.eclipseprojects.io:8883""" ,
185+ TCP: tcp://mqtt.eclipseprojects.io:1883
186+ WebSocket: ws://mqtt.eclipseprojects.io:9001
187+ TLS: tls://mqtt.eclipseprojects.io:8883""" ,
175188 dest = "mqtt_uri" ,
176189 required = False ,
177190 action = EnvDefault ,
@@ -180,7 +193,7 @@ def setup_parser() -> argparse.ArgumentParser:
180193 )
181194 mqtt .add_argument (
182195 "--mqtt-server-cert" ,
183- help = "Path to the server certificate authority file in PEM format for TLS." ,
196+ help = """ Path to the server certificate authority file in PEM format for TLS."" " ,
184197 dest = "tls_server_cert_path" ,
185198 required = False ,
186199 action = EnvDefault ,
@@ -189,7 +202,7 @@ def setup_parser() -> argparse.ArgumentParser:
189202 )
190203 mqtt .add_argument (
191204 "--mqtt-user" ,
192- help = "The MQTT user name." ,
205+ help = """ The MQTT user name."" " ,
193206 dest = "mqtt_user" ,
194207 required = False ,
195208 action = EnvDefault ,
@@ -198,7 +211,7 @@ def setup_parser() -> argparse.ArgumentParser:
198211 )
199212 mqtt .add_argument (
200213 "--mqtt-password" ,
201- help = "The MQTT password." ,
214+ help = """ The MQTT password."" " ,
202215 dest = "mqtt_password" ,
203216 required = False ,
204217 action = EnvDefault ,
@@ -207,7 +220,7 @@ def setup_parser() -> argparse.ArgumentParser:
207220 )
208221 mqtt .add_argument (
209222 "--mqtt-client-id" ,
210- help = "The MQTT Client Identifier." ,
223+ help = """ The MQTT Client Identifier."" " ,
211224 default = "saic-python-mqtt-gateway" ,
212225 dest = "mqtt_client_id" ,
213226 required = False ,
@@ -217,7 +230,7 @@ def setup_parser() -> argparse.ArgumentParser:
217230 )
218231 mqtt .add_argument (
219232 "--mqtt-topic-prefix" ,
220- help = "MQTT topic prefix." ,
233+ help = """ MQTT topic prefix."" " ,
221234 default = "saic" ,
222235 dest = "mqtt_topic" ,
223236 required = False ,
@@ -227,7 +240,7 @@ def setup_parser() -> argparse.ArgumentParser:
227240 )
228241 mqtt .add_argument (
229242 "--mqtt-allow-dots-in-topic" ,
230- help = "Allow dots in MQTT topics." ,
243+ help = """ Allow dots in MQTT topics."" " ,
231244 dest = "mqtt_allow_dots_in_topic" ,
232245 required = False ,
233246 action = EnvDefault ,
@@ -237,26 +250,30 @@ def setup_parser() -> argparse.ArgumentParser:
237250 )
238251 mqtt .add_argument (
239252 "--mqtt-server-cert-check-hostname" ,
240- help = """\
241- Check TLS certificate hostname when using custom certificate.
242- Set to (False) when using self-signed certificate without a matching hostname.
243- This option might be insecure.""" ,
253+ help = """Check TLS certificate hostname when using custom certificate.
254+ Set to (False) when using self-signed certificate without a matching hostname.
255+ This option might be insecure.""" ,
244256 dest = "tls_server_cert_check_hostname" ,
245257 required = False ,
246258 action = EnvDefault ,
247259 envvar = "MQTT_SERVER_CERT_CHECK_HOSTNAME" ,
248260 default = True ,
249261 type = check_bool ,
250262 )
263+ return mqtt
251264
265+
266+ def __add_saic_api_argument_group (
267+ parser : argparse .ArgumentParser ,
268+ ) -> argparse ._ArgumentGroup :
252269 saic_api = parser .add_argument_group (
253270 "SAIC API Configuration" ,
254271 "Configuration for the SAIC API connection." ,
255272 )
256273 saic_api .add_argument (
257274 "-s" ,
258275 "--saic-rest-uri" ,
259- help = "The SAIC uri. Default is European Production Endpoint" ,
276+ help = """ The SAIC uri. Default is European Production Endpoint"" " ,
260277 default = "https://gateway-mg-eu.soimt.com/api.app/v1/" ,
261278 dest = "saic_rest_uri" ,
262279 required = False ,
@@ -267,7 +284,7 @@ def setup_parser() -> argparse.ArgumentParser:
267284 saic_api .add_argument (
268285 "-u" ,
269286 "--saic-user" ,
270- help = "The SAIC user name." ,
287+ help = """ The SAIC user name."" " ,
271288 dest = "saic_user" ,
272289 required = True ,
273290 action = EnvDefault ,
@@ -277,7 +294,7 @@ def setup_parser() -> argparse.ArgumentParser:
277294 saic_api .add_argument (
278295 "-p" ,
279296 "--saic-password" ,
280- help = "The SAIC password." ,
297+ help = """ The SAIC password."" " ,
281298 dest = "saic_password" ,
282299 required = True ,
283300 action = EnvDefault ,
@@ -286,7 +303,7 @@ def setup_parser() -> argparse.ArgumentParser:
286303 )
287304 saic_api .add_argument (
288305 "--saic-phone-country-code" ,
289- help = "The SAIC phone country code." ,
306+ help = """ The SAIC phone country code."" " ,
290307 dest = "saic_phone_country_code" ,
291308 required = False ,
292309 action = EnvDefault ,
@@ -295,8 +312,7 @@ def setup_parser() -> argparse.ArgumentParser:
295312 )
296313 saic_api .add_argument (
297314 "--saic-region" ,
298- "--saic-region" ,
299- help = "The SAIC API region." ,
315+ help = """The SAIC API region.""" ,
300316 default = "eu" ,
301317 dest = "saic_region" ,
302318 required = False ,
@@ -306,7 +322,7 @@ def setup_parser() -> argparse.ArgumentParser:
306322 )
307323 saic_api .add_argument (
308324 "--saic-tenant-id" ,
309- help = "The SAIC API tenant id." ,
325+ help = """ The SAIC API tenant id."" " ,
310326 default = "459771" ,
311327 dest = "saic_tenant_id" ,
312328 required = False ,
@@ -316,10 +332,9 @@ def setup_parser() -> argparse.ArgumentParser:
316332 )
317333 saic_api .add_argument (
318334 "--battery-capacity-mapping" ,
319- help = """\
320- The mapping of VIN to full battery capacity.
321- Multiple mappings can be provided separated by comma.
322- Example: LSJXXXX=54.0,LSJYYYY=64.0,""" ,
335+ help = """The mapping of VIN to full battery capacity.
336+ Multiple mappings can be provided separated by comma.
337+ Example: LSJXXXX=54.0,LSJYYYY=64.0,""" ,
323338 dest = "battery_capacity_mapping" ,
324339 required = False ,
325340 action = EnvDefault ,
@@ -328,7 +343,7 @@ def setup_parser() -> argparse.ArgumentParser:
328343 )
329344 saic_api .add_argument (
330345 "--saic-relogin-delay" ,
331- help = "How long to wait before attempting another login to the SAIC API." ,
346+ help = """ How long to wait before attempting another login to the SAIC API."" " ,
332347 dest = "saic_relogin_delay" ,
333348 required = False ,
334349 action = EnvDefault ,
@@ -337,7 +352,7 @@ def setup_parser() -> argparse.ArgumentParser:
337352 )
338353 saic_api .add_argument (
339354 "--saic-read-timeout" ,
340- help = "HTTP Read timeout for the SAIC API." ,
355+ help = """ HTTP Read timeout for the SAIC API."" " ,
341356 dest = "saic_read_timeout" ,
342357 required = False ,
343358 action = EnvDefault ,
@@ -346,7 +361,7 @@ def setup_parser() -> argparse.ArgumentParser:
346361 )
347362 saic_api .add_argument (
348363 "--messages-request-interval" ,
349- help = "The interval for retrieving messages in seconds." ,
364+ help = """ The interval for retrieving messages in seconds."" " ,
350365 dest = "messages_request_interval" ,
351366 required = False ,
352367 action = EnvDefault ,
@@ -356,7 +371,7 @@ def setup_parser() -> argparse.ArgumentParser:
356371 )
357372 saic_api .add_argument (
358373 "--charge-min-percentage" ,
359- help = "How many percentage points we should try to refresh the charge state." ,
374+ help = """ How many percentage points we should try to refresh the charge state."" " ,
360375 dest = "charge_dynamic_polling_min_percentage" ,
361376 required = False ,
362377 action = EnvDefault ,
@@ -366,35 +381,45 @@ def setup_parser() -> argparse.ArgumentParser:
366381 )
367382 saic_api .add_argument (
368383 "--publish-raw-api-data" ,
369- help = "Publish raw SAIC API request/response to MQTT." ,
384+ help = """ Publish raw SAIC API request/response to MQTT."" " ,
370385 dest = "publish_raw_api_data" ,
371386 required = False ,
372387 action = EnvDefault ,
373388 envvar = "PUBLISH_RAW_API_DATA_ENABLED" ,
374389 default = False ,
375390 type = check_bool ,
376391 )
392+ return saic_api
393+
377394
395+ def __add_openwb_argument_group (
396+ parser : argparse .ArgumentParser ,
397+ ) -> argparse ._ArgumentGroup :
378398 openwb_integration = parser .add_argument_group (
379399 "OpenWB Integration" , "Configuration for the OpenWB integration."
380400 )
381401 openwb_integration .add_argument (
382402 "--charging-stations-json" ,
383- help = "Custom charging stations configuration file name" ,
403+ help = """ Custom charging stations configuration file name"" " ,
384404 dest = "charging_stations_file" ,
385405 required = False ,
386406 action = EnvDefault ,
387407 envvar = "CHARGING_STATIONS_JSON" ,
388408 type = str ,
389409 )
410+ return openwb_integration
390411
412+
413+ def __add_homeassistant_argument_group (
414+ parser : argparse .ArgumentParser ,
415+ ) -> argparse ._ArgumentGroup :
391416 homeassistant_integration = parser .add_argument_group (
392417 "Home Assistant Integration" ,
393418 "Configuration for the Home Assistant integration." ,
394419 )
395420 homeassistant_integration .add_argument (
396421 "--ha-discovery" ,
397- help = "Enable Home Assistant Discovery." ,
422+ help = """ Enable Home Assistant Discovery."" " ,
398423 dest = "ha_discovery_enabled" ,
399424 required = False ,
400425 action = EnvDefault ,
@@ -404,7 +429,7 @@ def setup_parser() -> argparse.ArgumentParser:
404429 )
405430 homeassistant_integration .add_argument (
406431 "--ha-discovery-prefix" ,
407- help = "Home Assistant Discovery Prefix." ,
432+ help = """ Home Assistant Discovery Prefix."" " ,
408433 dest = "ha_discovery_prefix" ,
409434 required = False ,
410435 action = EnvDefault ,
@@ -413,23 +438,27 @@ def setup_parser() -> argparse.ArgumentParser:
413438 )
414439 homeassistant_integration .add_argument (
415440 "--ha-show-unavailable" ,
416- help = "Show entities as Unavailable in Home Assistant when car polling fails." ,
441+ help = """ Show entities as Unavailable in Home Assistant when car polling fails."" " ,
417442 dest = "ha_show_unavailable" ,
418443 required = False ,
419444 action = EnvDefault ,
420445 envvar = "HA_SHOW_UNAVAILABLE" ,
421446 default = True ,
422447 type = check_bool ,
423448 )
449+ return homeassistant_integration
450+
424451
452+ def __add_abrp_argument_group (
453+ parser : argparse .ArgumentParser ,
454+ ) -> argparse ._ArgumentGroup :
425455 abrp_integration = parser .add_argument_group (
426456 "A Better Route Planner (ABRP) Integration" ,
427457 "Configuration for the A Better Route Planner integration." ,
428458 )
429- # ABRP Integration
430459 abrp_integration .add_argument (
431460 "--abrp-api-key" ,
432- help = "The API key for the A Better Route Planer telemetry API." ,
461+ help = """ The API key for the A Better Route Planer telemetry API."" " ,
433462 default = "8cfc314b-03cd-4efe-ab7d-4431cd8f2e2d" ,
434463 dest = "abrp_api_key" ,
435464 required = False ,
@@ -440,8 +469,8 @@ def setup_parser() -> argparse.ArgumentParser:
440469 abrp_integration .add_argument (
441470 "--abrp-user-token" ,
442471 help = """The mapping of VIN to ABRP User Token.
443- Multiple mappings can be provided seperated by ,
444- Example: LSJXXXX=12345-abcdef,LSJYYYY=67890-ghijkl,""" ,
472+ Multiple mappings can be provided seperated by ,
473+ Example: LSJXXXX=12345-abcdef,LSJYYYY=67890-ghijkl,""" ,
445474 dest = "abrp_user_token" ,
446475 required = False ,
447476 action = EnvDefault ,
@@ -450,23 +479,27 @@ def setup_parser() -> argparse.ArgumentParser:
450479 )
451480 abrp_integration .add_argument (
452481 "--publish-raw-abrp-data" ,
453- help = "Publish raw ABRP API request/response to MQTT." ,
482+ help = """ Publish raw ABRP API request/response to MQTT."" " ,
454483 dest = "publish_raw_abrp_data" ,
455484 required = False ,
456485 action = EnvDefault ,
457486 envvar = "PUBLISH_RAW_ABRP_DATA_ENABLED" ,
458487 default = False ,
459488 type = check_bool ,
460489 )
490+ return abrp_integration
461491
462- # OsmAnd Integration
492+
493+ def add_osmand_argument_group (
494+ parser : argparse .ArgumentParser ,
495+ ) -> argparse ._ArgumentGroup :
463496 osmand_integration = parser .add_argument_group (
464497 "OsmAnd Integration" ,
465498 "Configuration for the OsmAnd integration." ,
466499 )
467500 osmand_integration .add_argument (
468501 "--osmand-server-uri" ,
469- help = "The URL of your OsmAnd Server." ,
502+ help = """ The URL of your OsmAnd Server."" " ,
470503 default = None ,
471504 dest = "osmand_server_uri" ,
472505 required = False ,
@@ -477,9 +510,9 @@ def setup_parser() -> argparse.ArgumentParser:
477510 osmand_integration .add_argument (
478511 "--osmand-device-id" ,
479512 help = """The mapping of VIN to OsmAnd Device ID.
480- Multiple mappings can be provided seperated by ,
481- Example: LSJXXXX=12345-abcdef,LSJYYYY=67890-ghijkl,
482- Uses the car VIN as Device ID if not set""" ,
513+ Multiple mappings can be provided seperated by ,
514+ Example: LSJXXXX=12345-abcdef,LSJYYYY=67890-ghijkl,
515+ Uses the car VIN as Device ID if not set""" ,
483516 dest = "osmand_device_id" ,
484517 required = False ,
485518 action = EnvDefault ,
@@ -488,7 +521,7 @@ def setup_parser() -> argparse.ArgumentParser:
488521 )
489522 osmand_integration .add_argument (
490523 "--osmand-use-knots" ,
491- help = "Whether to use knots of kph as a speed unit in OsmAnd messages to ensure compatibilty with Traccar." ,
524+ help = """ Whether to use knots of kph as a speed unit in OsmAnd messages to ensure compatibilty with Traccar."" " ,
492525 dest = "osmand_use_knots" ,
493526 required = False ,
494527 action = EnvDefault ,
@@ -498,16 +531,15 @@ def setup_parser() -> argparse.ArgumentParser:
498531 )
499532 osmand_integration .add_argument (
500533 "--publish-raw-osmand-data" ,
501- help = "Publish raw ABRP OsmAnd request/response to MQTT." ,
534+ help = """ Publish raw ABRP OsmAnd request/response to MQTT."" " ,
502535 dest = "publish_raw_osmand_data" ,
503536 required = False ,
504537 action = EnvDefault ,
505538 envvar = "PUBLISH_RAW_OSMAND_DATA_ENABLED" ,
506539 default = False ,
507540 type = check_bool ,
508541 )
509-
510- return parser
542+ return osmand_integration
511543
512544
513545def __process_charging_stations_file (config : Configuration , json_file : str ) -> None :
0 commit comments