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
73.69k stars 30.82k forks source link

Manual setup of Google assistant integration broken #74351

Closed Barsonax closed 1 year ago

Barsonax commented 2 years ago

The problem

After it was working for months Google assistant integration with homeassistant now seems to be broken. I also cannot re add homeassistant in google home because after logging in I get this message: photo_2022-07-03_15-05-46

Iam running homeassistant on docker in a pi behind a reverse proxy. Iam still able to reach my homeasisstant instance with https from a external network so there doesn't seem to be any connectivity issue.

What version of Home Assistant Core has the issue?

Home Assistant Core 2022.6.7

What was the last working version of Home Assistant Core?

Home Assistant Core 2022.6.7

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Google assistant

Link to integration documentation on our website

https://www.home-assistant.io/integrations/google_assistant/

Diagnostics information

No logs available

Example YAML snippet

google_assistant:
  project_id: foobar
  service_account: !include service_account.json
  report_state: true
  expose_by_default: false

Anything in the logs that might be useful for us?

No logs available

Additional information

No response

devoncrouse commented 2 years ago

Same here. I did get a response on my support request with a couple diagnostics to try - hopefully that turns into something.

Taomyn commented 2 years ago

Has anyone seen any change for this as my devices are still appearing as offline, even though sometimes Google Assistant is able to control them?

rouke-broersma commented 2 years ago

Google support in the support request by @devoncrouse asked to perform a test on their account link test page (https://gal-demo.withgoogle.com/). It returns an error of: Operation: Account Linking returned status 'Error' (Failed to complete the flow: Malformed response cannot be parsed from <projectid>_dev for CODE_EXCHANGE)

elupus commented 2 years ago

My best guess is the lack of "state" in the token response. Doesn't explain why it works for me though. Lets see if the google team gets back with.

Taomyn commented 2 years ago

Seems to have suddenly fixed itself the past 3 or 4 days, my Google Home app has no problems getting to any of my HA devices and reacts/triggers immediately to them.

No idea what changed as I have plenty of updates to both my phone and HA itself this past week.

Taomyn commented 2 years ago

Seems to have suddenly fixed itself the past 3 or 4 days, my Google Home app has no problems getting to any of my HA devices and reacts/triggers immediately to them.

No idea what changed as I have plenty of updates to both my phone and HA itself this past week.

So I think I've worked out what is going on, for me at least. GeoIP. My firewall has a GeoIP rule that sends all traffic not in the allowed list into a black hole, and for some reason the IPs for Google and probably other things I haven't noticed, were getting mis-located.

It reverted back to not working again and when I looked closer at the firewall logs I saw what was happening, but the question was why. It was because the IPs were designated as located in Europe+USA, and my rule GeoIP alias does not have an entry for just Europe, only the individual countries. Temporarily disabling the rule gets everything working again.

Hope this helps anyone else coming across this problem.

elupus commented 2 years ago

I will close this since it has been resolved for the involved parties.

rouke-broersma commented 2 years ago

It has not been solved for me though. However Taomyn's comment does make me think I should check my firewall..

rouke-broersma commented 2 years ago

@elupus wow that totally solved the problem.... I had completely not thought about the API calls possibly not coming from my phone but rather, of course, from google IPs... Sorry!

Tonguc-Endem commented 2 years ago

Google deprecated their OAuth2 identity authentication method. There is this document from google explaining that the old OAuth method will stop working entirely after October 3rd, 2022.

Anyways, I've relinked both Nest and Google Assistant/Home with the new method. Nest integration seems to be working fine. However Google assistant/home integration is not entirely working as it used to. When I turn on an exposed HA device from the google home app, it turns the device on but the button shows state as off until I click the button a second time. For it to work correctly I have to click 2 times. 2 times to turn on, 2 times to turn off. However, if I issue the command via voice, it seems like it is working without a problem with voice. Asking with voice gives the device state correctly even when the google home app shows state wrong.

This has to be an integration problem.

rouke-broersma commented 2 years ago

@Tonguc-Endem the current instructions for setting up Google assistant integration use a redirect flow for authorization. Were you using an even older setup before and are you saying you updated to the current documented setup?

noogs commented 2 years ago

For others having unexplained issues with the Google Assistant integration and are using firewalls with Geo-IP Blocking. Google has been heavily investing in Brazilian infrastructure lately and I've noticed the majority of my requests are now coming from Brazilian IP addresses. Allowing Brazil in my Geo-IP filter immediately resolved all my issues.

Delfairen commented 2 years ago

I've been fighting this when I was on DuckDNS and then on Cloudflare and I have found one issue and one manual solution. Anytime HA is rebooted I have to reauth the google assistant integeration and then I need to go into the Google home app and reconnect the Home Assistant linked service. The moment both are done it immediately works.

wifiuk commented 1 year ago

+1 for using cloudflare and also having no google assistant integration recently.

Barsonax commented 1 year ago

I have moved to Cloudflare and since then I have no more issues. Maybe it was a weird connection issue.

Also iam now using uptime kuma to monitor if home assistant is up or not, including checking if https is working. I get a message when it's down so I never miss it when something goes wrong.

wifiuk commented 1 year ago

i use cloudflare and all of a sudden its dead, so cloudflare is not the fix.

edgy-noodle commented 1 year ago

Apparently, Google is experiencing general issues with custom integrations for beta versions of the app for a few days now.

You can easily check if that's the case for you by trying to add any other integration than yours. If you're getting the same error when clicking on any of them the following recommended answers have solved the issue for me: https://www.googlenestcommunity.com/t5/Apps-Account/Google-Home-app-quot-Could-not-reach-service-quot-for-everything/td-p/305201

wifiuk commented 1 year ago

Removing the beta did help a bit but I still get the same error just further on after I have logged into home assistant now so still need to check further.

Def something funky happening

Delfairen commented 1 year ago

Reconnecting works everytime for me and needs doing weekly.

On Sun, Dec 11, 2022, 11:13 PM wifiuk @.***> wrote:

Removing the beta did help a bit but I still get the same error just further on after I have logged into home assistant now so still need to check further.

Def something funky happening

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/74351#issuecomment-1345999344, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADIDIF4QZIQ5BMTTTMSGCNTWM3GABANCNFSM52QV2SCA . You are receiving this because you commented.Message ID: @.***>

elupus commented 1 year ago

Odd. I have never needed to reconnect mine.

myRice87 commented 1 year ago

Just found this after several months of struggling with this same issue. I'm able to get to the login screen of my HA instance, but once I log in, loads for a couple of seconds then gives me the same message described in OP.

Looking at the Cloud Console logs, I see an error of 'BACKEND_FAILURE_URL_ERROR'. No idea what this means, but I'm able to get to the login screen of HA, so I'm assuming the URL is fine... I also tried what @edgy-noodle suggested above, but no success there either.

I'm on Cloudflare and using the Google Nest router, so no control over GeoIP filtering.

{
  "insertId": "17khb3wfhzg53p",
  "jsonPayload": {
    "syncLog": {
      "syncs": [
        {
          "requestId": "8285546036327690505",
          "status": "BACKEND_FAILURE_URL_ERROR",
          "httpLatencyMsec": "324"
        }
      ]
    }
  },
  "resource": {
    "type": "assistant_action_project",
    "labels": {
      "project_id": "xx-smarthome-server"
    }
  },
  "timestamp": "2023-02-05T23:24:58.792571474Z",
  "severity": "ERROR",
  "logName": "projects/xx-smarthome-server/logs/assistant_smarthome%2Fassistant_smarthome_logs",
  "receiveTimestamp": "2023-02-05T23:24:58.792571474Z"
}
rouke-broersma commented 1 year ago

Are you using cloudflare caching for your home assistant instance? That might be a problem.

myRice87 commented 1 year ago

@rouke-broersma - Just checked this. I'm on the free tier of Cloudflare, so I can't disable caching altogether. What I ended up doing was creating a cache rule that bypasses caching for all incoming requests where hostname = "*" (which should effectively disable caching). I also cleared the existing cache in Cloudflare for good measure.

Rebooted HA after this and tried connecting, but still got the same error...

myRice87 commented 1 year ago

Just to confirm, does the Home Assistant URL setting matter? I have it currently pointing to the correct URL for my instance (dummy inserted for the screenshot), but should this URL contain any parameters or other additional elements?

image

elupus commented 1 year ago

Local network should really be the ip of your instance. Not the "my" url. Doubt that matters here.

wifiuk commented 1 year ago

Local network should really be the ip of your instance. Not the "my" url. Doubt that matters here.

I have to have the external URL to make Google TTS work has worked this way for years. Won't work if internal IP is used.

elupus commented 1 year ago

Should not be needed. It should use the external url.

myRice87 commented 1 year ago

I found this thread from 2021 that suggests trying to go to the /api/google_assistant page. Is this still valid in 2023? If so, I get a 404 error when I visit that page. Is this a sign of something misconfigured in my instance?

myRice87 commented 1 year ago

Alright, so I finally figured out the root of my issues. Leaving my resolution here in case it helps someone else:

I'm not entirely sure if this first step is necessary, but the first thing I did was disable the Cloud integration by removing it from my config, then restarting HA.

Once I did this, I went into Devices & Services and enabled the filter to show Disabled integrations. Lo-and-behold, my Google Assistant integration was sitting there in a disabled state. Once I enabled it, all of my issues went away and Google Assistant was able to connect.

No idea how it ended up disabled, but I suspect it has something to do with Nabu Casa and how it handles the Google Assistant integration. Either way, hopefully this helps someone else if they ever run into this issue.

rouke-broersma commented 1 year ago

I found this thread from 2021 that suggests trying to go to the /api/google_assistant page. Is this still valid in 2023? If so, I get a 404 error when I visit that page. Is this a sign of something misconfigured in my instance?

That page gives me a 405: Method not allowed. Sounds like you haven't actually activated Google assistant. Did you set the project id in configuration.yaml?

elupus commented 1 year ago

That is really strange. I cant think of a reason it would end up disabled. One thought could be that you thought you deleted the integration, but you ended up selecting disable at some point. Still it is a strange situation (and hard to figure out). Will ponder if we can correct that somehow.

balloob commented 1 year ago

No idea how it ended up disabled, but I suspect it has something to do with Nabu Casa and how it handles the Google Assistant integration. Either way, hopefully this helps someone else if they ever run into this issue.

This is wrong. The cloud integration does not enable or disable Google Assistant config entries.

myRice87 commented 1 year ago

That page gives me a 405: Method not allowed. Sounds like you haven't actually activated Google assistant. Did you set the project id in configuration.yaml?

Yes, I followed the instructions in the Google Assistant integration guide exactly, so this was the first thing I did. It turns out that my Google Assistant integration was disabled for some reason and I didn't notice.

This is wrong. The cloud integration does not enable or disable Google Assistant config entries.

Upon further reflection, I agree this may have been user error on my part. I likely disabled it at some point for whatever reason during all the troubleshooting I was doing and simply forgot.

That is really strange. I cant think of a reason it would end up disabled. One thought could be that you thought you deleted the integration, but you ended up selecting disable at some point. Still it is a strange situation (and hard to figure out). Will ponder if we can correct that somehow.

It was likely user error on my part, but regardless of how it ended up in this state, I think my difficulty in troubleshooting this came down to a few main issues:

  1. It wasn't obvious to me whether I should have been able to see Google Assistant in the Integrations UI. At one point, I tried adding it via the Add Integration button, and got a message that (at the time) I felt implied that it only needs to exist in the config.yaml. Had I known that a working integration should indeed show up in the Integrations UI, I would have investigated that more initially.

image

  1. Removing the google_assistant entry from the config.yaml, restarting HA, adding it back in, and restarting again did not reset the integration back to an enabled state.

  2. Hitting /api/google_assistant gave a 404, but there's no documentation I could find that states what this implies. In my mind, the entry in config.yaml was correct so there shouldn't be any other reason why it's not working. Had this returned a more specific error such as "Integration Disabled", I would have had more of clue for where to look.

All in all, I'm glad this ended up being a simple problem and I didn't have to completely reinstall my HA instance to fix it.

danepowell commented 1 year ago

I suspect there are several root causes here. In my case, on careful review of my Google Actions configuration I found a typo in my HA URL. After fixing that, account linking went swimmingly.

issue-triage-workflows[bot] commented 1 year 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.