home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.06k stars 31.09k forks source link

google assistant integration / unable to add test app #31054

Closed Stefan300381 closed 3 years ago

Stefan300381 commented 4 years ago

Hi,

my environment is quite complex:

Synology NAS with hass 0.104.0 running in docker container, host network, port 8123 ipv4 Synology Reverse Proxy, dns name ha.hauptsache.myds.me, port 443, using let's encrypt cert

Internet access via cable DSLite, ipv6 only incoming :-( This means if you try to reach the dns name via ipv4 it won't work. only ipv6

Anyway, so far the reverse proxy works fine and I can access my hass installation via the android companion app remotely (via cell network, German Vodafone) and locally via WiFi.

The problem is the google assistant integration. I read the documentation and setup the whole environment to connect to ha.hauptsache.myds.me.

This works: In Google Home app I click on the "+" to add new devices and I select my test app. The home assistant webpage appears. I enter my credentials and the app shows a popup which tells me in German "sie werden angemeldet" (translated: logging in).

This doesn't work: After a few seconds the popup disappears and I'm back in the "Konten verwalten" (manage accounts) screen. my test app is still not listed under the assigned services section.

Now I wonder, what am I missing? How can I debug this? Things I found in the logfile:

2020-01-17 15:11:28 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/report_state.py", line 45, in async_entity_state_listener
    if entity_data == old_entity.query_serialize():
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/helpers.py", line 442, in query_serialize
    deep_update(attrs, trt.query_attributes())
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/trait.py", line 1288, in query_attributes
    ERR_NOT_SUPPORTED, "Querying state is not supported"
homeassistant.components.google_assistant.error.SmartHomeError: Querying state is not supported
2020-01-17 17:35:10 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/report_state.py", line 45, in async_entity_state_listener
    if entity_data == old_entity.query_serialize():
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/helpers.py", line 442, in query_serialize
    deep_update(attrs, trt.query_attributes())
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/trait.py", line 1288, in query_attributes
    ERR_NOT_SUPPORTED, "Querying state is not supported"
homeassistant.components.google_assistant.error.SmartHomeError: Querying state is not supported
2020-01-21 13:19:20 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/report_state.py", line 45, in async_entity_state_listener
    if entity_data == old_entity.query_serialize():
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/helpers.py", line 442, in query_serialize
    deep_update(attrs, trt.query_attributes())
  File "/usr/src/homeassistant/homeassistant/components/google_assistant/trait.py", line 1288, in query_attributes
    ERR_NOT_SUPPORTED, "Querying state is not supported"
homeassistant.components.google_assistant.error.SmartHomeError: Querying state is not supported

Screenshot_2020-01-21-16-02-01-836_com google android googlequicksearchbox Screenshot_2020-01-21-16-02-17-165_com android chrome Screenshot_2020-01-21-16-02-32-757_com google android googlequicksearchbox

codecvlt commented 4 years ago

^ This totally fixed it for me. Thanks for the tip!

kancelott commented 4 years ago

Changing the App Engine Service Account permissions to Owner unfortunately did not work for me.

I'm having the same issue as well; running Home Assistant Core in a Docker with nginx+letsencrypt reverse proxying (also in a Docker). I also see no helpful log entries.

I've had Google Assistant integration running in the past, but after I unlinked it a couple weeks ago, I've been unable to link it back since even after deleting and re-creating a fresh Google Cloud project.

AdrinkBeer commented 4 years ago

Same for me (using it in Docker on Synology with the Synology RP), tried all described solutions...

Dirckvdb commented 4 years ago

I also tried te solution mentioned above. Unfortunately without success.

On 8 Jun 2020, at 14:59, AdrinkBeer notifications@github.com wrote:

Same for me (using it in Docker on Synology with the Synology RP), tried all described solutions...

ā€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/31054#issuecomment-640587276, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEE4G4NIGDY3H6ALPW2R6DDRVTOEHANCNFSM4KJU3RQA.

CodeInDreams commented 4 years ago

I stuck on this for months. Still have no idea what's wrong.

I have tried serveral os like Ubuntu server 16/18/20.04 (core/supervisor), HassOS (stable/test), also tried with hass version 0.106~0.110. Nothing happend.

I can make sure ssl, nginx and test app things is working fine. Maybe IP banned by google assistant??

AdrinkBeer commented 4 years ago

Tried to do it with DuckDNS/Let's Encrypt (and port forwarding) instead of the Synology RP with my domain, the behavior is a bit different : with the Syno RP, when I click on my test app, it loads ("Connecting...") then goes back to the list. with the DuckDNS solution, it also loads but then displays another popup ("Linking test app...") and then goes back to the previous screen (where I clicked on "Works with Google") but still no entities are available. In my config, only one entity is exposed.

I tested with the cloud NabuCasa solution and it works..

attaras commented 4 years ago

Similiar problem here.

I am using HA 0.113.2 on a Raspberry Pi with the NGINX Proxy Manager (port forwarding from 443 to duckdns:8123).

I successfully created the Test App for the second time.

Trying to add it to Google Home, I was asked to enter my credentials in Google Home for connecting.

After the screen showed "you are being logged in..." I was moved back to the Google Home services list with the test app still unconnected.

My guess is that is has something to do with the proxy manager.

Do you have any suggestions what I could else try to get it working?

Thank you guys!

agittins commented 4 years ago

It finally worked for me!

Some key things...

a) When you get to the google home app part, if you get to choose your test app, log in to HA ok, then says "signing in..", but then it just drops you back to the list of apps, then the problem is probably that google can't contact your server from outside (my issue was port blocking from my ISP, other possibilities are your firewall setup, or your dns entry is new and needs a few minutes/hours/a day to propogate).

b) If when doing the above, it drops you back to the "set up" page with "New devices" and "Works with Google", then I think you have an issue with the configuration in HA - perhaps the project name is wrong (it should be "adjectivenoun-number" if using the default, or "name-number" if you customised it), or maybe you're exposing too many services or something that's freaking google out. Maybe pare it back to just "switches" or something.

It's helpful to look at the logs for your proxy container when diagnosing this. If you run docker ps, and find the name for your proxy container, then run docker logs -f containername (in my case, containername is 'public_proxy_1' because I use docker-compose to run it). This will show you the log file, and keep waiting for new entries to show up (press Ctl-C to break out of it). Leave this running while you attempt the linking process, and compare it to my results below...

Here's what my successful addition looked like from the logs (Italics are my comments, bold is my emphasis, corrupted are my tokens, hostnames, etc):


172.27.0.1 - - [02/Aug/2020:21:12:45 +0000] "GET /auth/authorize?redirect_uri=https%3A%2F%2Foauth-redirect.googleusercontent.com%2Fr%2Fpensive-beaver-555555&client_id=https%3A%2F%2Foauth-redirect.googleusercontent.com%2Fr%2Fpensive-beaver-555555&response_type=code&state=ArEallyLongStringOfCharsForState&scope=email%20profile&user_locale=en-GB HTTP/1.1" 200 2355 "-" "Mozilla/5.0 (Linux; Android 5.0; SM-N9005) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.111 Mobile Safari/537.36" "-"

^ this is you loading the HA sign-in page, 
so it probably came from inside your network 
rather than via the internet. Note that I set
scopes to "email" and "profile", since "name"
doesn't seem to be a current scope, I don't
know if that's important.

172.27.0.1 - - [02/Aug/2020:21:12:45 +0000] "POST /auth/login_flow HTTP/1.1" 200 263 "https://home.example.com/auth/authorize?redirect_uri=https%3A%2F%2Foauth-redirect.googleusercontent.com%2Fr%2Fpensive-beaver-555555&client_id=https%3A%2F%2Foauth-redirect.googleusercontent.com%2Fr%2Fpensive-beaver-555555&response_type=code&state=ArEallyLongStringOfCharsForState&scope=email%20profile&user_locale=en-GB" "Mozilla/5.0 (Linux; Android 5.0; SM-N9005) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.111 Mobile Safari/537.36" "-"

^ This is your phone again, loading the
content "inside" the HA login page.

172.27.0.1 - - [02/Aug/2020:21:13:02 +0000] "POST /auth/login_flow/488e39853a37bb883 HTTP/1.1" 200 255 "https://home.example.com/auth/authorize?redirect_uri=https%3A%2F%2Foauth-redirect.googleusercontent.com%2Fr%2Fpensive-beaver-555555&client_id=https%3A%2F%2Foauth-redirect.googleusercontent.com%2Fr%2Fpensive-beaver-555555&response_type=code&state=ArEallyLongStringOfCharsForState&scope=email%20profile&user_locale=en-GB" "Mozilla/5.0 (Linux; Android 5.0; SM-N9005) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.111 Mobile Safari/537.36" "-"'

^ This is you successfully logging in to HA. 
Note the "200" response which means login
was successful. A 400 or 403 or something
here indicates you got your login details wrong :-)
Also note the project name "pensivebeaver-555555",
you should see exactly this project name in the
url when setting up your project in the google
actions console thingie.

172.27.0.1 - - [02/Aug/2020:21:13:05 +0000] "POST /auth/token HTTP/1.1" 200 396 "-" "OpenAuth" "-"

^ Hurrah! This means google's server is contacting
your server, and the 200 says that they're getting
along well. This is the key line, really. If you don't see this (access to /auth/token) then it means google's servers are not reaching you - which might be because of your dns, your firewall, or the paths you put into the OAuth2 settings in google action console.

Entries like the below are the general "google
talking to HA stuff" that will happen as statuses
are updated, lights are switched etc.

172.27.0.1 - - [02/Aug/2020:21:13:09 +0000] "POST /api/google_assistant HTTP/1.1" 200 5785 "-" "Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)" "-"
172.27.0.1 - - [02/Aug/2020:21:13:12 +0000] "POST /api/google_assistant HTTP/1.1" 200 5785 "-" "Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)" "-"

Hopefully that will give you what a good session looks like, compare it with your own, and help you work out where things are going awry.

attaras commented 4 years ago

How can I trace those connections on a standard hassio installation on a Raspberry Pi 4?

CodeInDreams commented 4 years ago

Finally got it work! I stuck for several months! I tried everything I saw until I realized that "I can login" NOT means google can. Even I opened the login page and "logged in", google wasn't. Yea that's the problem. I believe many people ignored it. Note that I have public IP and properly deployed https website but still has this issue. Some ISP like China blocks Google's traffic.

I solved this by forwarding 8123 to another server using Frp.

igloo15 commented 4 years ago

I also just starting running into this issue. I tried to relink my home assistant account and got a message saying Google Home "Couldn't update the setting. Check your connection.". This is after I logged in and was forwarded back to my google home from homeassistant.

I tried setting the service account as project owner. I tried disconnecting phone from wifi. I tried changing my project linking. I tried different setups but none of them worked.

One thing I noted was that this occurred around the same time as I relinked my samsung smartthings connection to google. I also updated to 0.114.3 around that time and even added another google device to my setup as well. I am not sure if any of that is related or not.

I am also getting this error in my homeassistant which I never got before https://homegraph.googleapis.com/v1/devices:reportStateAndNotification failed: 404

elupus commented 4 years ago

404 on report means a device is reported that wasn't synced

jaburges commented 4 years ago

same issue here - trying to add [test] my test app.

I see app linked successfully but i'm dumped back on the Google Home App home screen. Going back to the list of apps an I see `[test] my test app' is in fact not linked.

I'm using Docker and synology Reverse Proxy - no issues with external connectivity (Alexa has no issues) and i'm using a SSL wild card certificate.

jes1417 commented 4 years ago

Try changing expose_by_default: false to true That's the only way I was actually able to get the integration to work

jes1417 commented 4 years ago

Here is my config:

google_assistant:
  project_id: hass-assistant-f1209
  service_account:  !include assistant_service_account.json
  secure_devices_pin: '0000'
  report_state: true
  expose_by_default: true
  exposed_domains:
    - light
    - camera
    - cover
    - switch
  entity_config:
    light.downstairs_lights:
      name: Downstairs Lights
      room: Downstairs
    light.upstairs_lights:
      name: Upstairs Lights
      room: Upstairs
    light.dining_lights:
      name: Dining Lights
      room: Dining
    light.downstairs_bath:
      name: Downstairs Bath
    light.porch:
      name: Porch
    light.back_porch:
      name: Back Porch
    light.kitchen_lights:
      name: Kitchen
      room: Kitchen
    light.hallway_lights:
      name: Hallway
      room: Hallway
    light.master_closet_2:
      name: Master Closet
    light.master_lights:
      name: Master Lights
      room: Master
    light.dining_1:
      expose: false
    light.dining_2:
      expose: false
    light.dining_3:
      expose: false
    light.mommy_s_light:
      expose: false
    light.daddy_s_light:
      expose: false
    light.kitchen_1:
      expose: false
    light.kitchen_2:
      expose: false
    light.laundry_light:
      expose: false
    light.kids_room_light:
      expose: false
    light.master_bath_1:
      expose: false
    light.master_bath_2:
      expose: false
    light.living_room:
      expose: false
    light.bar_light:
      expose: false
    light.kids_bath_1:
      expose: false
    light.kids_bath_2:
      expose: false
    light.entry_light_1:
      expose: false
    light.entry_light_2:
      expose: false
    light.entry_lights:
      expose: false
    light.bar:
      expose: false
    light.all_lights:
      expose: false
    light.entry:
      expose: false
    light.kids_bathroom_lights:
      expose: false
    light.kids_room:
      expose: false
    light.laundry_room:
      expose: false
    light.hallway_1:
      expose: false
    light.hallway_2:
      expose: false
    light.master_bath_lights:
      expose: false
    light.master_bedroom:
      expose: false
    light.master_zone:
      expose: false
    light.wled:
      expose: false
    light.hyperion:
      expose: false

This was the only way I could get the test app to actually add and get my entities to show up, if I left exposed by default to false I would get the loop back when trying to add my test app

jaburges commented 4 years ago

That seemed to do it, thanks.

Appreciate the help.

However this is not how it 'should' work - so wonder if the code owner will take a look?

If the entities are set to expose:true by default, it seems superfluous to set expose_by_default: true as well.

Anything listed in the entity_config should be exposed.

Anyway, thanks for the tip šŸ˜€

elupus commented 4 years ago

I think what you ran into was solved recently actually. You probably had assumed state entities , that failed on sync.

jes1417 commented 4 years ago

I tried to update my config a week ago by removing the true statement and when I went to re-link the app it still failed so I'm not sure which version it's fixed in but it still doesn't seem to work

elupus commented 4 years ago

Well the fix mentioned was not released yet :)

jaburges commented 4 years ago

ah, any idea when the fix will be released? - browser_mod as an example adds a new light for the device you are viewing your lovelace dashboard on - so expose_by_default: true will just flood my GA devices list with random devices I dont need/want.

jes1417 commented 4 years ago

@jaburges if you look at my config You noticed I listed entities with the attribute expose: false which will remove that entity from Google That's why my config is so long I'm pretty sure it will be released in 0.115 which I think the beta is coming on Monday

jaburges commented 4 years ago

yeah, but i dont know what the name of the new lights that browser_mod will create it uses a browser deviceID. So if another light is added that i dont implicitly know (or declare as expose: false) and then reboot HA each time (ball ache) - i'll end up with the random lights I dont need in GA. That said, great timing the fix is just around the corner - good bit of luck i guess :)

jaburges commented 4 years ago

I cant see (but then equally cant tell) if the fix is for this issue. It looks like the main fix is for GA to be able to handle bad data from a device. Am i missing anything?

elupus commented 4 years ago

Yes that is what I meant. If you have issues pairing with expose all. The likely cause is that we failed to generate data for some entity. Previous the whole sync would then fail.

jaburges commented 4 years ago

ahhh - interesting. Ok. before i try the fix i'll see what device is causing all the fuss

jes1417 commented 4 years ago

Yeah I don't understand what device could be giving bad data because the devices I was trying to get into Google work just fine I've been exposing all filtering out the ones I don't want.

jaburges commented 4 years ago

also - hold on. Maybe i'm missing something. if i set expose_by_default: false and I add 2 lights and nothing more GA linking FAILS

if i set expose_by_default: true it automatically adds ALL lights GA linking succeeds

It cant just be bad data, as exposing all devices in that domain would make the problem worse (or the same) not better?

elupus commented 4 years ago

Okey that make no sense šŸ¤£

jaburges commented 4 years ago

i know right - so weird. I'm only exposing a single domain right now. Lets see what the fix brings

Right now my exclusion list is crazy long lol

glancek commented 4 years ago

I have a solution! For DS-lite , be sure to leave the ipv4 field empty in duckdns! Otherwise the GA will not work !!!

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment šŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

DiGiSoUL84 commented 3 years ago

Did anyone find a real solution other than typo's in the config or a port was closed? I am experiencing the same problems, been that way for the past 4 days!! I've tried every suggestion in damn near every post on Reddit, GitHub, HA Community. Please help!