6
6
from pathlib import Path
7
7
import urllib .parse
8
8
9
+ from saic_ismart_client_ng .model import DEFAULT_TENANT_ID , DEFAULT_REGION , DEFAULT_USER_AGENT , DEFAULT_BASE_URI
10
+
9
11
from configuration import Configuration , TransportProtocol
10
12
from configuration .argparse_extensions import (
11
13
EnvDefault ,
@@ -60,9 +62,9 @@ def process_arguments() -> Configuration:
60
62
"-m" ,
61
63
"--mqtt-uri" ,
62
64
help = "The URI to the MQTT Server. Environment Variable: MQTT_URI,"
63
- "TCP: tcp://mqtt.eclipseprojects.io:1883 "
64
- "WebSocket: ws://mqtt.eclipseprojects.io:9001"
65
- "TLS: tls://mqtt.eclipseprojects.io:8883" ,
65
+ "TCP: tcp://mqtt.eclipseprojects.io:1883 "
66
+ "WebSocket: ws://mqtt.eclipseprojects.io:9001"
67
+ "TLS: tls://mqtt.eclipseprojects.io:8883" ,
66
68
dest = "mqtt_uri" ,
67
69
required = False ,
68
70
action = EnvDefault ,
@@ -95,8 +97,8 @@ def process_arguments() -> Configuration:
95
97
parser .add_argument (
96
98
"--mqtt-client-id" ,
97
99
help = "The MQTT Client Identifier. Environment Variable: "
98
- "MQTT_CLIENT_ID "
99
- "Default is saic-python-mqtt-gateway" ,
100
+ "MQTT_CLIENT_ID "
101
+ "Default is saic-python-mqtt-gateway" ,
100
102
default = "saic-python-mqtt-gateway" ,
101
103
dest = "mqtt_client_id" ,
102
104
required = False ,
@@ -126,8 +128,8 @@ def process_arguments() -> Configuration:
126
128
"-s" ,
127
129
"--saic-rest-uri" ,
128
130
help = "The SAIC uri. Environment Variable: SAIC_REST_URI Default is the European "
129
- "Production Endpoint: https://tap-eu.soimt.com " ,
130
- default = "https://gateway-mg-eu.soimt.com/api.app/v1/" ,
131
+ f "Production Endpoint: { DEFAULT_BASE_URI } " ,
132
+ default = DEFAULT_BASE_URI ,
131
133
dest = "saic_rest_uri" ,
132
134
required = False ,
133
135
action = EnvDefault ,
@@ -162,28 +164,37 @@ def process_arguments() -> Configuration:
162
164
parser .add_argument (
163
165
"--saic-region" ,
164
166
"--saic-region" ,
165
- help = "The SAIC API region. Environment Variable: SAIC_REGION" ,
166
- default = "eu" ,
167
+ help = f "The SAIC API region. Default is { DEFAULT_REGION } . Environment Variable: SAIC_REGION" ,
168
+ default = DEFAULT_REGION ,
167
169
dest = "saic_region" ,
168
170
required = False ,
169
171
action = EnvDefault ,
170
172
envvar = "SAIC_REGION" ,
171
173
)
172
174
parser .add_argument (
173
175
"--saic-tenant-id" ,
174
- help = "The SAIC API tenant id. Environment Variable: SAIC_TENANT_ID" ,
175
- default = "459771" ,
176
+ help = f "The SAIC API tenant id. Default is { DEFAULT_TENANT_ID } . Environment Variable: SAIC_TENANT_ID" ,
177
+ default = DEFAULT_TENANT_ID ,
176
178
dest = "saic_tenant_id" ,
177
179
required = False ,
178
180
action = EnvDefault ,
179
181
envvar = "SAIC_TENANT_ID" ,
180
182
)
183
+ parser .add_argument (
184
+ "--saic-user-agent" ,
185
+ help = "The SAIC API User Agent. Defaults to the latest iOS app. Environment Variable: SAIC_USER_AGENT" ,
186
+ default = DEFAULT_USER_AGENT ,
187
+ dest = "saic_user_agent" ,
188
+ required = False ,
189
+ action = EnvDefault ,
190
+ envvar = "SAIC_USER_AGENT" ,
191
+ )
181
192
parser .add_argument (
182
193
"--battery-capacity-mapping" ,
183
194
help = "The mapping of VIN to full batteryc"
184
- " apacity. Multiple mappings can be provided separated"
185
- " by , Example: LSJXXXX=54.0,LSJYYYY=64.0,"
186
- " Environment Variable: BATTERY_CAPACITY_MAPPING" ,
195
+ " apacity. Multiple mappings can be provided separated"
196
+ " by , Example: LSJXXXX=54.0,LSJYYYY=64.0,"
197
+ " Environment Variable: BATTERY_CAPACITY_MAPPING" ,
187
198
dest = "battery_capacity_mapping" ,
188
199
required = False ,
189
200
action = EnvDefault ,
@@ -200,7 +211,7 @@ def process_arguments() -> Configuration:
200
211
parser .add_argument (
201
212
"--saic-relogin-delay" ,
202
213
help = "How long to wait before attempting another login to the SAIC API. Environment "
203
- "Variable: SAIC_RELOGIN_DELAY" ,
214
+ "Variable: SAIC_RELOGIN_DELAY" ,
204
215
dest = "saic_relogin_delay" ,
205
216
required = False ,
206
217
action = EnvDefault ,
@@ -210,7 +221,7 @@ def process_arguments() -> Configuration:
210
221
parser .add_argument (
211
222
"--saic-read-timeout" ,
212
223
help = "HTTP Read timeout for the SAIC API. Environment "
213
- "Variable: SAIC_READ_TIMEOUT" ,
224
+ "Variable: SAIC_READ_TIMEOUT" ,
214
225
dest = "saic_read_timeout" ,
215
226
required = False ,
216
227
action = EnvDefault ,
@@ -239,7 +250,7 @@ def process_arguments() -> Configuration:
239
250
parser .add_argument (
240
251
"--ha-show-unavailable" ,
241
252
help = "Show entities as Unavailable in Home Assistant when car polling fails. "
242
- "Environment Variable: HA_SHOW_UNAVAILABLE" ,
253
+ "Environment Variable: HA_SHOW_UNAVAILABLE" ,
243
254
dest = "ha_show_unavailable" ,
244
255
required = False ,
245
256
action = EnvDefault ,
@@ -250,7 +261,7 @@ def process_arguments() -> Configuration:
250
261
parser .add_argument (
251
262
"--messages-request-interval" ,
252
263
help = "The interval for retrieving messages in seconds. Environment Variable: "
253
- "MESSAGES_REQUEST_INTERVAL" ,
264
+ "MESSAGES_REQUEST_INTERVAL" ,
254
265
dest = "messages_request_interval" ,
255
266
required = False ,
256
267
action = EnvDefault ,
@@ -260,7 +271,7 @@ def process_arguments() -> Configuration:
260
271
parser .add_argument (
261
272
"--charge-min-percentage" ,
262
273
help = "How many % points we should try to refresh the charge state. Environment Variable: "
263
- "CHARGE_MIN_PERCENTAGE" ,
274
+ "CHARGE_MIN_PERCENTAGE" ,
264
275
dest = "charge_dynamic_polling_min_percentage" ,
265
276
required = False ,
266
277
action = EnvDefault ,
@@ -271,7 +282,7 @@ def process_arguments() -> Configuration:
271
282
parser .add_argument (
272
283
"--publish-raw-api-data" ,
273
284
help = "Publish raw SAIC API request/response to MQTT. Environment Variable: "
274
- "PUBLISH_RAW_API_DATA_ENABLED" ,
285
+ "PUBLISH_RAW_API_DATA_ENABLED" ,
275
286
dest = "publish_raw_api_data" ,
276
287
required = False ,
277
288
action = EnvDefault ,
@@ -284,9 +295,9 @@ def process_arguments() -> Configuration:
284
295
parser .add_argument (
285
296
"--abrp-api-key" ,
286
297
help = "The API key for the A Better Route Planer telemetry API."
287
- " Default is the open source telemetry"
288
- " API key 8cfc314b-03cd-4efe-ab7d-4431cd8f2e2d."
289
- " Environment Variable: ABRP_API_KEY" ,
298
+ " Default is the open source telemetry"
299
+ " API key 8cfc314b-03cd-4efe-ab7d-4431cd8f2e2d."
300
+ " Environment Variable: ABRP_API_KEY" ,
290
301
default = "8cfc314b-03cd-4efe-ab7d-4431cd8f2e2d" ,
291
302
dest = "abrp_api_key" ,
292
303
required = False ,
@@ -296,9 +307,9 @@ def process_arguments() -> Configuration:
296
307
parser .add_argument (
297
308
"--abrp-user-token" ,
298
309
help = "The mapping of VIN to ABRP User Token."
299
- " Multiple mappings can be provided seperated by ,"
300
- " Example: LSJXXXX=12345-abcdef,LSJYYYY=67890-ghijkl,"
301
- " Environment Variable: ABRP_USER_TOKEN" ,
310
+ " Multiple mappings can be provided seperated by ,"
311
+ " Example: LSJXXXX=12345-abcdef,LSJYYYY=67890-ghijkl,"
312
+ " Environment Variable: ABRP_USER_TOKEN" ,
302
313
dest = "abrp_user_token" ,
303
314
required = False ,
304
315
action = EnvDefault ,
@@ -307,7 +318,7 @@ def process_arguments() -> Configuration:
307
318
parser .add_argument (
308
319
"--publish-raw-abrp-data" ,
309
320
help = "Publish raw ABRP API request/response to MQTT. Environment Variable: "
310
- "PUBLISH_RAW_ABRP_DATA_ENABLED" ,
321
+ "PUBLISH_RAW_ABRP_DATA_ENABLED" ,
311
322
dest = "publish_raw_abrp_data" ,
312
323
required = False ,
313
324
action = EnvDefault ,
@@ -319,8 +330,8 @@ def process_arguments() -> Configuration:
319
330
parser .add_argument (
320
331
"--osmand-server-uri" ,
321
332
help = "The URL of your OsmAnd Server."
322
- " Default unset"
323
- " Environment Variable: OSMAND_SERVER_URI" ,
333
+ " Default unset"
334
+ " Environment Variable: OSMAND_SERVER_URI" ,
324
335
default = None ,
325
336
dest = "osmand_server_uri" ,
326
337
required = False ,
@@ -330,10 +341,10 @@ def process_arguments() -> Configuration:
330
341
parser .add_argument (
331
342
"--osmand-device-id" ,
332
343
help = "The mapping of VIN to OsmAnd Device ID."
333
- " Multiple mappings can be provided seperated by ,"
334
- " Example: LSJXXXX=12345-abcdef,LSJYYYY=67890-ghijkl,"
335
- " Default is to use the car VIN as Device ID, "
336
- " Environment Variable: OSMAND_DEVICE_ID" ,
344
+ " Multiple mappings can be provided seperated by ,"
345
+ " Example: LSJXXXX=12345-abcdef,LSJYYYY=67890-ghijkl,"
346
+ " Default is to use the car VIN as Device ID, "
347
+ " Environment Variable: OSMAND_DEVICE_ID" ,
337
348
dest = "osmand_device_id" ,
338
349
required = False ,
339
350
action = EnvDefault ,
@@ -342,7 +353,7 @@ def process_arguments() -> Configuration:
342
353
parser .add_argument (
343
354
"--publish-raw-osmand-data" ,
344
355
help = "Publish raw ABRP OsmAnd request/response to MQTT. Environment Variable: "
345
- "PUBLISH_RAW_OSMAND_DATA_ENABLED" ,
356
+ "PUBLISH_RAW_OSMAND_DATA_ENABLED" ,
346
357
dest = "publish_raw_osmand_data" ,
347
358
required = False ,
348
359
action = EnvDefault ,
@@ -370,6 +381,7 @@ def process_arguments() -> Configuration:
370
381
config .saic_rest_uri = args .saic_rest_uri
371
382
config .saic_region = args .saic_region
372
383
config .saic_tenant_id = str (args .saic_tenant_id )
384
+ config .saic_user_agent = args .saic_user_agent
373
385
config .saic_user = args .saic_user
374
386
config .saic_password = args .saic_password
375
387
config .saic_phone_country_code = args .saic_phone_country_code
0 commit comments