Skip to content

Commit

Permalink
Get updated Assist satellite config after setting it in ESPHome (#126552
Browse files Browse the repository at this point in the history
)

Get updated config after setting it
  • Loading branch information
synesthesiam authored Sep 24, 2024
1 parent fb45f4f commit 4869309
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions homeassistant/components/esphome/assist_satellite.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ async def async_set_configuration(
)
_LOGGER.debug("Set active wake words: %s", config.active_wake_words)

# Ensure configuration is updated
await self._update_satellite_config()

async def _update_satellite_config(self) -> None:
"""Get the latest satellite configuration from the device."""
config = await self.cli.get_voice_assistant_configuration(_CONFIG_TIMEOUT_SEC)
Expand Down
12 changes: 9 additions & 3 deletions tests/components/esphome/test_assist_satellite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import asyncio
from collections.abc import Awaitable, Callable
from dataclasses import replace
import io
import socket
from unittest.mock import ANY, Mock, patch
Expand Down Expand Up @@ -1457,11 +1458,16 @@ async def test_get_set_configuration(
actual_config = satellite.async_get_configuration()
assert actual_config == expected_config

updated_config = replace(actual_config, active_wake_words=["5678"])
mock_client.get_voice_assistant_configuration.return_value = updated_config

# Change active wake words
actual_config.active_wake_words = ["5678"]
await satellite.async_set_configuration(actual_config)
await satellite.async_set_configuration(updated_config)

# Device should have been updated
# Set config method should be called
mock_client.set_voice_assistant_configuration.assert_called_once_with(
active_wake_words=["5678"]
)

# Device should have been updated
assert satellite.async_get_configuration() == updated_config

0 comments on commit 4869309

Please sign in to comment.