Migrate solax away from using async_add_job (#113257)

The plan is to deprecate `async_add_job` to reduce the number of job APIs we have to maintain.

See #113179 for additional history.

`async_add_job` was not being used as expected here
This commit is contained in:
J. Nick Koston 2024-03-13 18:22:15 -10:00 committed by GitHub
parent 9ef0a8cb95
commit 7f37732e71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 2 deletions

View File

@ -103,8 +103,12 @@ async def async_setup_entry(
serial = resp.serial_number
version = resp.version
endpoint = RealTimeDataEndpoint(hass, api)
hass.async_add_job(endpoint.async_refresh)
async_track_time_interval(hass, endpoint.async_refresh, SCAN_INTERVAL)
entry.async_create_background_task(
hass, endpoint.async_refresh(), f"solax {entry.title} initial refresh"
)
entry.async_on_unload(
async_track_time_interval(hass, endpoint.async_refresh, SCAN_INTERVAL)
)
devices = []
for sensor, (idx, measurement) in api.inverter.sensor_map().items():
description = SENSOR_DESCRIPTIONS[(measurement.unit, measurement.is_monotonic)]