Add optimistic updates for Indevolt (#173091)

This commit is contained in:
A. Gideonse
2026-06-13 20:20:37 +02:00
committed by GitHub
parent 483f7072dd
commit d3d883358c
9 changed files with 68 additions and 24 deletions
+3 -6
View File
@@ -62,12 +62,8 @@ async def test_select_option(
# Reset mock call count for this iteration
mock_indevolt.set_data.reset_mock()
# Update mock data to reflect the new value
mock_indevolt.fetch_data.return_value[IndevoltConfig.READ_ENERGY_MODE] = (
expected_value
)
# Attempt to change option
fetch_count_before = mock_indevolt.fetch_data.call_count
await hass.services.async_call(
SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
@@ -80,7 +76,8 @@ async def test_select_option(
IndevoltConfig.WRITE_ENERGY_MODE, expected_value
)
# Verify updated state
# Verify state updated optimistically without a new fetch
assert mock_indevolt.fetch_data.call_count == fetch_count_before
assert (state := hass.states.get("select.cms_sf2000_energy_mode")) is not None
assert state.state == option