Skip to content

Commit

Permalink
Change wake word id to string
Browse files Browse the repository at this point in the history
  • Loading branch information
synesthesiam committed Sep 16, 2024
1 parent 709cb3f commit 775ecdc
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions aioesphomeapi/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ message VoiceAssistantAnnounceFinished {
}

message VoiceAssistantWakeWord {
uint32 id = 1;
string id = 1;
string wake_word = 2;
repeated string trained_languages = 3;
}
Expand All @@ -1607,7 +1607,7 @@ message VoiceAssistantConfigurationResponse {
option (ifdef) = "USE_VOICE_ASSISTANT";

repeated VoiceAssistantWakeWord available_wake_words = 1;
repeated uint32 active_wake_words = 2;
repeated string active_wake_words = 2;
uint32 max_active_wake_words = 3;
}

Expand All @@ -1616,7 +1616,7 @@ message VoiceAssistantSetConfiguration {
option (source) = SOURCE_CLIENT;
option (ifdef) = "USE_VOICE_ASSISTANT";

repeated uint32 active_wake_words = 1;
repeated string active_wake_words = 1;
}

// ==================== ALARM CONTROL PANEL ====================
Expand Down
2 changes: 1 addition & 1 deletion aioesphomeapi/api_pb2.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion aioesphomeapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ async def get_voice_assistant_configuration(
return VoiceAssistantConfigurationResponseModel.from_pb(resp)

async def set_voice_assistant_configuration(
self, active_wake_words: list[int]
self, active_wake_words: list[str]
) -> None:
req = VoiceAssistantSetConfiguration(active_wake_words=active_wake_words)
self._get_connection().send_message(req)
Expand Down
4 changes: 2 additions & 2 deletions aioesphomeapi/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ class VoiceAssistantAnnounceFinished(APIModelBase):

@_frozen_dataclass_decorator
class VoiceAssistantWakeWord(APIModelBase):
id: int
id: str
wake_word: str
trained_languages: list[str]

Expand All @@ -1320,7 +1320,7 @@ class VoiceAssistantConfigurationResponse(APIModelBase):
available_wake_words: list[VoiceAssistantWakeWord] = converter_field(
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


Expand Down
8 changes: 4 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2686,12 +2686,12 @@ def send_message(msg):
response: message.Message = VoiceAssistantConfigurationResponse(
available_wake_words=[
VoiceAssistantWakeWord(
id=1,
id="1234",
wake_word="okay nabu",
trained_languages=["en"],
)
],
active_wake_words=[1],
active_wake_words=["1234"],
max_active_wake_words=1,
)
mock_data_received(protocol, generate_plaintext_packet(response))
Expand All @@ -2709,11 +2709,11 @@ async def test_set_voice_assistant_configuration(
original_send_message = connection.send_message

def send_message(msg):
assert msg == VoiceAssistantSetConfiguration(active_wake_words=[1])
assert msg == VoiceAssistantSetConfiguration(active_wake_words=["1234"])
original_send_message(msg)

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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ def test_voice_assistant_wake_word_convert_list() -> None:
"trained_languages": ["en"],
}
],
"active_wake_words": [1],
"active_wake_words": ["1234"],
"max_active_wake_words": 1,
}
) == VoiceAssistantConfigurationResponse(
Expand All @@ -707,6 +707,6 @@ def test_voice_assistant_wake_word_convert_list() -> None:
trained_languages=["en"],
)
],
active_wake_words=[1],
active_wake_words=["1234"],
max_active_wake_words=1,
)

0 comments on commit 775ecdc

Please sign in to comment.