Skip to content

Commit

Permalink
fix(sentence): Fix to handle sentence trigger signature change
Browse files Browse the repository at this point in the history
Fixes #260
  • Loading branch information
zachowj committed Apr 4, 2024
1 parent 16b40cd commit 03d34da
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions custom_components/nodered/websocket.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Websocket API for Node-RED."""

import json
import logging
from typing import Any
Expand Down Expand Up @@ -308,14 +309,28 @@ async def websocket_sentence(
response = msg["response"]

@callback
async def handle_trigger(sentence: str, result: RecognizeResult = None) -> str:
"""Handle Sentence trigger."""
"""RecognizeResult was added in 2023.8.0"""
async def handle_trigger(
sentence: str,
result: RecognizeResult | None = None,
device_id: str | None = None,
) -> str:
"""
Handle Sentence trigger.
RecognizeResult was added in 2023.8.0
device_id was added in 2024.4.0
"""

_LOGGER.debug(f"Sentence trigger: {sentence}")
connection.send_message(
event_message(
msg[CONF_ID], {"data": {"sentence": sentence, "result": result}}
msg[CONF_ID],
{
"data": {
"sentence": sentence,
"result": result,
"deviceId": device_id,
}
},
)
)

Expand Down

0 comments on commit 03d34da

Please sign in to comment.