mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 04:50:05 +00:00
Handle single state requests from ESPHome (#124660)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
@@ -205,6 +205,7 @@ class MockESPHomeDevice:
|
||||
self.home_assistant_state_subscription_callback: Callable[
|
||||
[str, str | None], None
|
||||
]
|
||||
self.home_assistant_state_request_callback: Callable[[str, str | None], None]
|
||||
self.voice_assistant_handle_start_callback: Callable[
|
||||
[str, int, VoiceAssistantAudioSettings, str | None],
|
||||
Coroutine[Any, Any, int | None],
|
||||
@@ -268,9 +269,11 @@ class MockESPHomeDevice:
|
||||
def set_home_assistant_state_subscription_callback(
|
||||
self,
|
||||
on_state_sub: Callable[[str, str | None], None],
|
||||
on_state_request: Callable[[str, str | None], None],
|
||||
) -> None:
|
||||
"""Set the state call callback."""
|
||||
self.home_assistant_state_subscription_callback = on_state_sub
|
||||
self.home_assistant_state_request_callback = on_state_request
|
||||
|
||||
def mock_home_assistant_state_subscription(
|
||||
self, entity_id: str, attribute: str | None
|
||||
@@ -278,6 +281,12 @@ class MockESPHomeDevice:
|
||||
"""Mock a state subscription."""
|
||||
self.home_assistant_state_subscription_callback(entity_id, attribute)
|
||||
|
||||
def mock_home_assistant_state_request(
|
||||
self, entity_id: str, attribute: str | None
|
||||
) -> None:
|
||||
"""Mock a state request."""
|
||||
self.home_assistant_state_request_callback(entity_id, attribute)
|
||||
|
||||
def set_subscribe_voice_assistant_callbacks(
|
||||
self,
|
||||
handle_start: Callable[
|
||||
@@ -378,9 +387,12 @@ async def _mock_generic_device_entry(
|
||||
|
||||
def _subscribe_home_assistant_states(
|
||||
on_state_sub: Callable[[str, str | None], None],
|
||||
on_state_request: Callable[[str, str | None], None],
|
||||
) -> None:
|
||||
"""Subscribe to home assistant states."""
|
||||
mock_device.set_home_assistant_state_subscription_callback(on_state_sub)
|
||||
mock_device.set_home_assistant_state_subscription_callback(
|
||||
on_state_sub, on_state_request
|
||||
)
|
||||
|
||||
def _subscribe_voice_assistant(
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user