1
1
# == debug.py Author: Zuinige Rijder =========================================
2
- """ Simple Python3 script to debug hyundai_kia_connect_api values """
2
+ """Simple Python3 script to debug hyundai_kia_connect_api values"""
3
+ import sys
3
4
import configparser
4
5
from datetime import datetime
5
6
import logging
6
7
import logging .config
7
8
from hyundai_kia_connect_api import VehicleManager , Vehicle
8
- from monitor_utils import get_filepath
9
+ from monitor_utils import get_filepath , get , get_bool , to_int
9
10
10
11
logging .basicConfig (level = logging .DEBUG )
11
12
19
20
USERNAME = monitor_settings ["username" ]
20
21
PASSWORD = monitor_settings ["password" ]
21
22
PIN = monitor_settings ["pin" ]
23
+ USE_GEOCODE = get_bool (monitor_settings , "use_geocode" , False )
24
+ USE_GEOCODE_EMAIL = get_bool (monitor_settings , "use_geocode_email" , False )
25
+ GEOCODE_PROVIDER = to_int (
26
+ get (monitor_settings , "geocode_provider" , "1" )
27
+ ) # 1=OPENSTREETMAP 2=GOOGLE
28
+ if GEOCODE_PROVIDER < 1 or GEOCODE_PROVIDER > 2 :
29
+ logging .error ("Invalid GEOCODE_PROVIDER in monitor.cfg, expected 1 or 2" )
30
+ sys .exit (- 1 )
31
+
32
+ GOOGLE_API_KEY = get (monitor_settings , "google_api_key" , "" )
33
+ if len (GOOGLE_API_KEY ) == 0 :
34
+ GOOGLE_API_KEY = None # default no API key needed for OPENSTREETMAP
35
+
36
+ if GEOCODE_PROVIDER == 2 and GOOGLE_API_KEY is None :
37
+ logging .error ("Missing GOOGLE_API_KEY in monitor.cfg" )
38
+ sys .exit (- 1 )
39
+
40
+ LANGUAGE = monitor_settings ["language" ]
22
41
23
42
24
43
# == get_child_value =========================================================
@@ -111,7 +130,13 @@ def print_info(vehicles: dict) -> None:
111
130
username = USERNAME ,
112
131
password = PASSWORD ,
113
132
pin = PIN ,
133
+ geocode_api_enable = USE_GEOCODE ,
134
+ geocode_api_use_email = USE_GEOCODE_EMAIL ,
135
+ geocode_provider = GEOCODE_PROVIDER ,
136
+ geocode_api_key = GOOGLE_API_KEY ,
137
+ language = LANGUAGE ,
114
138
)
139
+
115
140
for KEY in vm .vehicles :
116
141
VEHICLE = vm .vehicles [KEY ]
117
142
print (f"timezone: { VEHICLE .timezone } " )
@@ -120,6 +145,7 @@ def print_info(vehicles: dict) -> None:
120
145
vm .check_and_refresh_token ()
121
146
# vm.force_refresh_all_vehicles_states()
122
147
vm .update_all_vehicles_with_cached_state () # needed >= 2.0.0
148
+ vm .update_all_vehicles_with_cached_state () # do twice to check geocode cache
123
149
124
150
for KEY in vm .vehicles :
125
151
VEHICLE = vm .vehicles [KEY ]
0 commit comments