mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-12-22 16:48:04 +01:00
Change wake word id to string (#960)
This commit is contained in:
parent
709cb3fd15
commit
a6531d4a2e
@ -1590,7 +1590,7 @@ message VoiceAssistantAnnounceFinished {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message VoiceAssistantWakeWord {
|
message VoiceAssistantWakeWord {
|
||||||
uint32 id = 1;
|
string id = 1;
|
||||||
string wake_word = 2;
|
string wake_word = 2;
|
||||||
repeated string trained_languages = 3;
|
repeated string trained_languages = 3;
|
||||||
}
|
}
|
||||||
@ -1607,7 +1607,7 @@ message VoiceAssistantConfigurationResponse {
|
|||||||
option (ifdef) = "USE_VOICE_ASSISTANT";
|
option (ifdef) = "USE_VOICE_ASSISTANT";
|
||||||
|
|
||||||
repeated VoiceAssistantWakeWord available_wake_words = 1;
|
repeated VoiceAssistantWakeWord available_wake_words = 1;
|
||||||
repeated uint32 active_wake_words = 2;
|
repeated string active_wake_words = 2;
|
||||||
uint32 max_active_wake_words = 3;
|
uint32 max_active_wake_words = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1616,7 +1616,7 @@ message VoiceAssistantSetConfiguration {
|
|||||||
option (source) = SOURCE_CLIENT;
|
option (source) = SOURCE_CLIENT;
|
||||||
option (ifdef) = "USE_VOICE_ASSISTANT";
|
option (ifdef) = "USE_VOICE_ASSISTANT";
|
||||||
|
|
||||||
repeated uint32 active_wake_words = 1;
|
repeated string active_wake_words = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== ALARM CONTROL PANEL ====================
|
// ==================== ALARM CONTROL PANEL ====================
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1474,7 +1474,7 @@ class APIClient:
|
|||||||
return VoiceAssistantConfigurationResponseModel.from_pb(resp)
|
return VoiceAssistantConfigurationResponseModel.from_pb(resp)
|
||||||
|
|
||||||
async def set_voice_assistant_configuration(
|
async def set_voice_assistant_configuration(
|
||||||
self, active_wake_words: list[int]
|
self, active_wake_words: list[str]
|
||||||
) -> None:
|
) -> None:
|
||||||
req = VoiceAssistantSetConfiguration(active_wake_words=active_wake_words)
|
req = VoiceAssistantSetConfiguration(active_wake_words=active_wake_words)
|
||||||
self._get_connection().send_message(req)
|
self._get_connection().send_message(req)
|
||||||
|
@ -1300,7 +1300,7 @@ class VoiceAssistantAnnounceFinished(APIModelBase):
|
|||||||
|
|
||||||
@_frozen_dataclass_decorator
|
@_frozen_dataclass_decorator
|
||||||
class VoiceAssistantWakeWord(APIModelBase):
|
class VoiceAssistantWakeWord(APIModelBase):
|
||||||
id: int
|
id: str
|
||||||
wake_word: str
|
wake_word: str
|
||||||
trained_languages: list[str]
|
trained_languages: list[str]
|
||||||
|
|
||||||
@ -1320,7 +1320,7 @@ class VoiceAssistantConfigurationResponse(APIModelBase):
|
|||||||
available_wake_words: list[VoiceAssistantWakeWord] = converter_field(
|
available_wake_words: list[VoiceAssistantWakeWord] = converter_field(
|
||||||
default_factory=list, converter=VoiceAssistantWakeWord.convert_list
|
default_factory=list, converter=VoiceAssistantWakeWord.convert_list
|
||||||
)
|
)
|
||||||
active_wake_words: list[int] = converter_field(default_factory=list, converter=list)
|
active_wake_words: list[str] = converter_field(default_factory=list, converter=list)
|
||||||
max_active_wake_words: int = 0
|
max_active_wake_words: int = 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -2686,12 +2686,12 @@ async def test_get_voice_assistant_configuration(
|
|||||||
response: message.Message = VoiceAssistantConfigurationResponse(
|
response: message.Message = VoiceAssistantConfigurationResponse(
|
||||||
available_wake_words=[
|
available_wake_words=[
|
||||||
VoiceAssistantWakeWord(
|
VoiceAssistantWakeWord(
|
||||||
id=1,
|
id="1234",
|
||||||
wake_word="okay nabu",
|
wake_word="okay nabu",
|
||||||
trained_languages=["en"],
|
trained_languages=["en"],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
active_wake_words=[1],
|
active_wake_words=["1234"],
|
||||||
max_active_wake_words=1,
|
max_active_wake_words=1,
|
||||||
)
|
)
|
||||||
mock_data_received(protocol, generate_plaintext_packet(response))
|
mock_data_received(protocol, generate_plaintext_packet(response))
|
||||||
@ -2709,11 +2709,11 @@ async def test_set_voice_assistant_configuration(
|
|||||||
original_send_message = connection.send_message
|
original_send_message = connection.send_message
|
||||||
|
|
||||||
def send_message(msg):
|
def send_message(msg):
|
||||||
assert msg == VoiceAssistantSetConfiguration(active_wake_words=[1])
|
assert msg == VoiceAssistantSetConfiguration(active_wake_words=["1234"])
|
||||||
original_send_message(msg)
|
original_send_message(msg)
|
||||||
|
|
||||||
with patch.object(connection, "send_message", new=send_message):
|
with patch.object(connection, "send_message", new=send_message):
|
||||||
await client.set_voice_assistant_configuration([1])
|
await client.set_voice_assistant_configuration(["1234"])
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
@ -696,7 +696,7 @@ def test_voice_assistant_wake_word_convert_list() -> None:
|
|||||||
"trained_languages": ["en"],
|
"trained_languages": ["en"],
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"active_wake_words": [1],
|
"active_wake_words": ["1234"],
|
||||||
"max_active_wake_words": 1,
|
"max_active_wake_words": 1,
|
||||||
}
|
}
|
||||||
) == VoiceAssistantConfigurationResponse(
|
) == VoiceAssistantConfigurationResponse(
|
||||||
@ -707,6 +707,6 @@ def test_voice_assistant_wake_word_convert_list() -> None:
|
|||||||
trained_languages=["en"],
|
trained_languages=["en"],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
active_wake_words=[1],
|
active_wake_words=["1234"],
|
||||||
max_active_wake_words=1,
|
max_active_wake_words=1,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user