Skip to content

Commit 7629294

Browse files
committed
add async to refresh status service
1 parent 731e0cc commit 7629294

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

custom_components/fordpass/__init__.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ async def async_refresh_status_service(service_call):
9797

9898
if target_vin:
9999
# Refresh specific vehicle
100-
await hass.async_add_executor_job(
101-
refresh_status, hass, service_call, coordinator
102-
)
100+
await refresh_status(hass, service_call, coordinator)
103101
else:
104102
# Refresh all vehicles for this account
105103
all_entries = hass.config_entries.async_entries(DOMAIN)
@@ -108,9 +106,7 @@ async def async_refresh_status_service(service_call):
108106
for config_entry in all_entries:
109107
if config_entry.data.get(CONF_USERNAME) == current_username:
110108
entry_coordinator = hass.data[DOMAIN][config_entry.entry_id][COORDINATOR]
111-
await hass.async_add_executor_job(
112-
refresh_status, hass, service_call, entry_coordinator
113-
)
109+
await refresh_status(hass, service_call, entry_coordinator)
114110

115111
async def async_clear_tokens_service(service_call):
116112
"""Clear tokens for this user account"""
@@ -177,11 +173,11 @@ async def options_update_listener(hass: HomeAssistant, entry: ConfigEntry):
177173
await hass.config_entries.async_reload(entry.entry_id)
178174

179175

180-
def refresh_status(hass, service, coordinator):
176+
async def refresh_status(hass, service, coordinator):
181177
"""Get latest vehicle status from vehicle, actively polls the car"""
182178
_LOGGER.debug("Running Service")
183179
vin = service.data.get("vin", "")
184-
status = coordinator.vehicle.request_update(vin)
180+
status = await coordinator.vehicle.request_update(vin)
185181
if status == 401:
186182
_LOGGER.debug("Invalid VIN")
187183
elif status == 200:

0 commit comments

Comments
 (0)