Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
[fix] #12 Workaround for strange "Not any" response (#18)
Browse files Browse the repository at this point in the history
* [fix] #12 Workaround for strange "Not any" response

* Fix issues caused by me writing it like Go

* Lowercase + if agent_names[agent_id] is not found, use unknown

* Have it say 1.0.4
  • Loading branch information
m50 authored Jun 30, 2024
1 parent cb43ddc commit 0fe28a9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
19 changes: 10 additions & 9 deletions custom_components/fallback_conversation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
DEBUG_LEVEL_LOW_DEBUG,
DEBUG_LEVEL_VERBOSE_DEBUG,
DOMAIN,
STRANGE_ERROR_RESPONSES,
)


Expand Down Expand Up @@ -85,14 +86,14 @@ async def async_process(
result = None
for agent_id in agents:
result = await self._async_process_agent(
agent_manager,
agent_id,
agent_names[agent_id],
user_input,
agent_manager,
agent_id,
agent_names[agent_id] or "[unknown]",
user_input,
debug_level,
result,
)
if result.response.response_type != intent.IntentResponseType.ERROR:
if result.response.response_type != intent.IntentResponseType.ERROR and result.response.speech['plain']['original_speech'].lower() not in STRANGE_ERROR_RESPONSES:
return result
all_results.append(result)

Expand All @@ -113,15 +114,15 @@ async def async_process(
conversation_id=result.conversation_id,
response=intent_response
)

return result

async def _async_process_agent(
self,
agent_manager: conversation.AgentManager,
self,
agent_manager: conversation.AgentManager,
agent_id: str,
agent_name: str,
user_input: conversation.ConversationInput,
user_input: conversation.ConversationInput,
debug_level: int,
previous_result,
) -> conversation.ConversationResult:
Expand Down
7 changes: 6 additions & 1 deletion custom_components/fallback_conversation/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@
DEBUG_LEVEL_VERBOSE_DEBUG = "verbose"

DEFAULT_NAME = "Fallback Conversation Agent"
DEFAULT_DEBUG_LEVEL = DEBUG_LEVEL_NO_DEBUG
DEFAULT_DEBUG_LEVEL = DEBUG_LEVEL_NO_DEBUG

STRANGE_ERROR_RESPONSES = [
"not any",
"geen",
]
2 changes: 1 addition & 1 deletion custom_components/fallback_conversation/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/m50/ha-fallback-conversation/issues",
"requirements": [],
"version": "1.0.0"
"version": "1.0.4"
}

0 comments on commit 0fe28a9

Please sign in to comment.