@@ -125,17 +125,26 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
125125 # SERVICES from here...
126126 # simple service implementations (might be moved to separate service.py)
127127 async def async_refresh_status_service (call : ServiceCall ):
128- await hass .async_add_executor_job (service_refresh_status , hass , call , coordinator )
129- await asyncio .sleep (15 )
130- await coordinator .async_refresh ()
128+ _LOGGER .debug (f"Running Service 'refresh_status'" )
129+ status = await coordinator .bridge .request_update ()
130+ if status == 401 :
131+ _LOGGER .debug (f"[@{ coordinator .vli } ] refresh_status: Invalid VIN?! (status 401)" )
132+ elif status in [200 , 201 , 202 ]:
133+ _LOGGER .debug (f"[@{ coordinator .vli } ] refresh_status: Refresh sent" )
134+
135+ await asyncio .sleep (10 )
136+ await coordinator .async_request_refresh_force_classic_requests ()
131137
132138 async def async_clear_tokens_service (call : ServiceCall ):
133- await hass .async_add_executor_job (service_clear_tokens , hass , call , coordinator )
139+ #await hass.async_add_executor_job(service_clear_tokens, hass, call, coordinator)
140+ """Clear the token file in config directory, only use in emergency"""
141+ _LOGGER .debug (f"Running Service 'clear_tokens'" )
142+ await coordinator .bridge .clear_token ()
134143 await asyncio .sleep (5 )
135- await coordinator .async_request_refresh ()
144+ await coordinator .async_request_refresh_force_classic_requests ()
136145
137146 async def poll_api_service (call : ServiceCall ):
138- await coordinator .async_request_refresh ()
147+ await coordinator .async_request_refresh_force_classic_requests ()
139148
140149 async def handle_reload_service (call : ServiceCall ):
141150 """Handle reload service call."""
@@ -172,22 +181,6 @@ async def async_update_options(hass, config_entry):
172181 hass .config_entries .async_update_entry (config_entry , options = options )
173182
174183
175- def service_refresh_status (hass , service , coordinator ):
176- """Get the latest vehicle status from vehicle, actively polls the car"""
177- _LOGGER .debug (f"Running Service 'refresh_status'" )
178- status = coordinator .bridge .request_update ()
179- if status == 401 :
180- _LOGGER .debug (f"[@{ coordinator .vli } ] refresh_status: Invalid VIN?! (status 401)" )
181- elif status == 200 :
182- _LOGGER .debug (f"[@{ coordinator .vli } ] refresh_status: Refresh sent" )
183-
184-
185- def service_clear_tokens (hass , service , coordinator ):
186- """Clear the token file in config directory, only use in emergency"""
187- _LOGGER .debug (f"Running Service 'clear_tokens'" )
188- coordinator .bridge .clear_token ()
189-
190-
191184async def async_unload_entry (hass : HomeAssistant , config_entry : ConfigEntry ) -> bool :
192185 """Unload a config entry."""
193186 _LOGGER .debug (f"async_unload_entry() called for entry: { config_entry .entry_id } " )
0 commit comments