Skip to content

Commit

Permalink
fix(sentence)!: Fix getting default conversation agent
Browse files Browse the repository at this point in the history
Fixes #270

BREAKING CHANGE: Changes made to conversation agent now require Home Assistant 2024.5+ for sentence node to work
  • Loading branch information
zachowj committed May 2, 2024
1 parent ee60d8b commit 60e81ce
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ _Companion Component to [node-red-contrib-home-assistant-websocket](https://gith
## Minimum Requirements

- [node-red-contrib-home-assistant-websocket](https://github.com/zachowj/node-red-contrib-home-assistant-websocket) v0.57+
- [Home Assistant](https://github.com/home-assistant/core) 2023.7.0+
- [Home Assistant](https://github.com/home-assistant/core) 2024.5+

## Installation

Expand Down
1 change: 1 addition & 0 deletions custom_components/nodered/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"domain": "nodered",
"name": "Node-RED Companion",
"after_dependencies": [
"conversation",
"mqtt"
],
"codeowners": [
Expand Down
16 changes: 2 additions & 14 deletions custom_components/nodered/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,7 @@

from hassil.recognize import RecognizeResult
from homeassistant.components import device_automation
from homeassistant.components.conversation import (
HOME_ASSISTANT_AGENT,
)

try:
from homeassistant.components.conversation import get_agent_manager
except ImportError:
# _get_agent_manager was renamed to get_agent_manager in 2024.4.0
from homeassistant.components.conversation import (
_get_agent_manager as get_agent_manager,
)
from homeassistant.components.conversation.default_agent import async_get_default_agent

from homeassistant.components.conversation.default_agent import DefaultAgent
from homeassistant.components.device_automation import DeviceAutomationType
Expand Down Expand Up @@ -355,9 +345,7 @@ def remove_trigger() -> None:
_LOGGER.info(f"Sentence trigger removed: {sentences}")

try:
default_agent = await get_agent_manager(hass).async_get_agent(
HOME_ASSISTANT_AGENT
)
default_agent = async_get_default_agent(hass)
assert isinstance(default_agent, DefaultAgent)

_remove_trigger = default_agent.register_trigger(sentences, handle_trigger)
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"filename": "nodered.zip",
"homeassistant": "2023.7.0",
"homeassistant": "2024.5.0",
"name": "Node-RED Companion",
"zip_release": true
}

0 comments on commit 60e81ce

Please sign in to comment.