Skip to content

Commit

Permalink
Update import for get_agent_manager (#261)
Browse files Browse the repository at this point in the history
* Update import for get_agent_manager

* Catch import failure of get_agent_manager for previous versions
  • Loading branch information
koosc authored Apr 6, 2024
1 parent 674e49a commit f9d6ff3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions custom_components/nodered/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@
from homeassistant.components import device_automation
from homeassistant.components.conversation import (
HOME_ASSISTANT_AGENT,
_get_agent_manager,
)

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 DefaultAgent
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.components.device_automation.exceptions import (
Expand Down Expand Up @@ -342,7 +350,7 @@ def remove_trigger() -> None:
_LOGGER.info(f"Sentence trigger removed: {sentences}")

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

0 comments on commit f9d6ff3

Please sign in to comment.