greghesp / assistant-relay

A Node.js server that allows for sending commands to Google Home/Assistant from endpoints
GNU General Public License v2.0
781 stars 225 forks source link

Not all messages are broadcasted. #176

Open jokerigno opened 4 years ago

jokerigno commented 4 years ago

Describe the bug Hi,

as shared on Discord I noticed that some messages are not broacasted. Looking in home page or in sandbox I clicked on the play button and noticed that sometimes the response from google is something like "sorry, I can't help you" (in my native language-italian) and sometimes are broadcasted.

To Reproduce Steps to reproduce the behavior:

Using this template it doesn't work:

{
    "user": "Home-Assistant",
    "command": "La lavatrice è terminata.",
    "broadcast": true
}

Using this it works:

{
    "user": "Home-Assistant",
    "command": "La lavastoviglie è terminata.",
    "broadcast": true
}

(lavatrice means washer, lavastoviglie means dishwasher)

The VERY strange thing is that if I typo the word lavatrice to laatrice it works! So I don't know what to think.

Moreover I noticed that if there's a greeting at the beginning it always fail.

Expected behavior

To reproduce broadcast in all situations.

Desktop (please complete the following information):

ryancasler commented 4 years ago

Have you tried adding any extra words to see if the broadcast works? Like, instead of saying "the waster is finished" try saying "The washer is complete" or "The washer is now finished" (And just to check Google Translate, i think those would be "La lavatrice è completa" and "La lavatrice è ora terminata" 😄 ) It might just be something with the Italian translation that is getting screwed up because all of those phrases work fine for me in English. I would think that none of it would matter in a broadcast.

At first I thought it might be the accent marks, but it appears that both phrases only have one accent. But have you tried it without the accented e? (I don't event know if that's possible in Italien...just giving you some things to try out.)

Have you tried issuing the broadcast from your phone by text? If you launch the Google Assistant on your phone and then tap the keyboard, you can type in Broadcast followed by the phrase you want to broadcast to your speakers. That is the definitive way to know if the problem is assistant or assistant relay. I would have tried that myself but I'd have to reset everything to Italian! 😉

greghesp commented 4 years ago

I've reported this one to Google and they're already aware of the issue. Guess we'll have to play the waiting game

jokerigno commented 4 years ago

I was afraid of that.

am80l commented 3 years ago

No idea if this is related, but I ran into a similar scenario inside a blueprint where some messages were being broadcast and others weren't. I ended up with this odd syntax after trial and error:

      - service: rest_command.assistant_broadcast
        data:
          command: "message: {{ resolved_message }}"

In this case, prefixing anything other than message: (e.g. "foobar:") fixed the issue, but also caused the "foobar:" string to be broadcast. By using the term "message:" Google ignored that part of the pattern and only broadcast the {{ resolved_message }} and also fixed the instances where it wasn't broadcasting anything at all.

I'm not sure what the exact issue is here, but it seems that approach works okay as a work-around, it might be worth a try to see if it resolves this use case also.

jokerigno commented 3 years ago

Uhm I would love to test it on my system but I don't know how.

In my setup I use AR as notify service that is called by many automations. So I have this:

rest_command:
  assistant_broadcast:
    url: http://192.168.2.101:3000/assistant
    method: POST
    content_type: 'application/json'
    payload: '{"command":"{{ command }}", "user":"Home-Assistant", "broadcast":true}'
  assistant_converse:
    url: http://192.168.2.101:3000/assistant
    method: POST
    content_type: 'application/json'
    payload: '{"command":"{{ command }}", "user":"Home-Assistant", "converse":true}'
  assistant_relay:
    url: http://192.168.2.101:3000/assistant
    method: POST
    content_type: 'application/json'
    payload: '{"command":"{{ command }}", "user":"Home-Assistant"}'

notify:
  - name: Google Assistant
    platform: rest
    resource: http://192.168.2.101:3000/assistant
    headers:
      Content-Type: application/json
    method: POST_JSON
    message_param_name: command
    data:
      user: Home-Assistant
      broadcast: true

Where in your opinion I have to modify? TY!

am80l commented 3 years ago

I guess you could try something like this:

payload: '{"command":"message: {{ command }}", "user":"Home-Assistant", "broadcast":true}'

Seems silly but something very similar worked for me 🤷

jokerigno commented 3 years ago

Uhm maybe it depends also by native language.

I tested this:

{ "user": "Home-Assistant", "broadcast": true, "command": "message: {{ buongiorno, questo è un messaggio di prova }}" }

but it's not broadcasted.

If I remove buongiorno (that means good morning in my native language) it is broadcasted without problem

{ "user": "Home-Assistant", "broadcast": true, "command": "message: {{ questo è un messaggio di prova }}" }