Core: Google Calendar integration stopped working

Created on 4 Oct 2019  路  21Comments  路  Source: home-assistant/core

Home Assistant release with the issue:

0.99.3

Last working Home Assistant release (if known):
0.98.x

Operating environment (Hass.io/Docker/Windows/etc.):

Docker

Integration:

https://www.home-assistant.io/integrations/calendar.google/

Description of problem:
My Google calendars are no longer appearing. Logs show the following 2 errors:

Error executing service <ServiceCall google.scan_for_calendars (c:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)>

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1242, in _safe_execute
    await self._execute_service(handler, service_call)
  File "/usr/src/homeassistant/homeassistant/core.py", line 1261, in _execute_service
    await self._hass.async_add_executor_job(handler.func, service_call)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/google/__init__.py", line 255, in _scan_for_calendars
    service = calendar_service.get()
  File "/usr/src/homeassistant/homeassistant/components/google/__init__.py", line 349, in get
    http = credentials.authorize(httplib2.Http())
AttributeError: 'NoneType' object has no attribute 'authorize'
google: Error on device update!

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 441, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/google/calendar.py", line 104, in update
    self.data.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/google/calendar.py", line 170, in update
    service, params = self._prepare_query()
  File "/usr/src/homeassistant/homeassistant/components/google/calendar.py", line 133, in _prepare_query
    service = self.calendar_service.get()
  File "/usr/src/homeassistant/homeassistant/components/google/__init__.py", line 349, in get
    http = credentials.authorize(httplib2.Http())
AttributeError: 'NoneType' object has no attribute 'authorize'
google stale

Most helpful comment

Ok, I sorted it. Here are the instructions:
1) Rename or delete the file .google.token that is in the config directory.
2) Restart HA
3) You will find a new 'Notification' message. Follow its instructions.
Job done

All 21 comments

I had the same issue - know it isn't an ideal solution but, disabling the config entry and deleting the token and calendar files from the config directory, then re-enabling / re-authorising got it back working for me.

Could I try to take this on?

@danieledwardgeorgehitchcock I can confirm deleting the token and calender files worked. I'll leave the issue open because that was obviously just a workaround, even though reauthing wasn't very painful.

@tegumba I'd say just go ahead and try. Not part of the Home Assistant team but feel free to @ me if you want someone to help review a pull request.

As I see it, you could fix this by simply restarting the original authentication flow if credentials ends up being None for some reason.

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 now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Don't know if this help anyone else looking into the issue in the future. After reauthing mine did work. Point of this post, I was working with 103.4 and the calendar was working. Upgraded to 103.6 had to reauth to get to work. If I read the release notes right, there was some work done in the oauth area.
Again, just passing on info.

As @TheLastProject mention, maybe could be fixed by reauthing automatically. That would be better.

How do you reauth? I set up a brand new project in the developer console with new keys, and I got a 400 response error

Anyone worked out how to make it prompt to auth again.
I get asked by google from time to time to re-enter my password to get into my gmail. I guess this is the same situation.

Ok, I sorted it. Here are the instructions:
1) Rename or delete the file .google.token that is in the config directory.
2) Restart HA
3) You will find a new 'Notification' message. Follow its instructions.
Job done

I was having this issue a week ago, and reauthorized my calendars. Last night they started failing again with the same error reported by @TheLastProject in my logs. I am currently on 0.106.1

We need the integration to take this on and prompt us or we need an automation to trigger on this state to do the same. I get it fairly often as I use a lot of different devices to access my google calendar and gmail and this makes google nervous and ask me for password. This seems to trigger HA too. Maybe also the change of wan IP on my router due to ISP.

I've had to reauthorize my google calendars at least 3 times in the past 4 - 6 weeks. Token seems to be invalid after a certain amount of time passes. At least for me...
image

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 now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

After this fix, here is what's going on with my calendar. What use to happen was that the state of my calendar would go ON for the length of start_time to end_time. Now the state of the calendar intermittently goes ON - hasn't been consistent. Also I have multiple schedules in google scheduled 2 minutes apart - sometimes the first schedule trigger HA calendar state to ON but the following 2 schedules do not trigger ON. Anyone else experiencing these issues? I think I'm missing something but can't figure it out.

Since 116 i've been getting the same issues. Deleting token to force authen. is a temporary fix, and i mean a few hours to a day maximum. Tried generating a new secret and deleting token and still the same issue. Upgraded to 117 and still same behavior. Any ideas?

Same here. A few minutes, hours or days after starting HA, the google calendar integration stops working and I have to delete the token file to start over again. But it's just a temporary fix for some time.

First seen in 116, after adding another calendar to google calendar. I'm not sure if it's related to 116 or the newly added calendar.

No added calendar, or changes to events, or new events here.

Changed secret and that seemed to buy me 3 full days before failing again. Anyone else seeing this behavior?

How many calendars does your google calendar contain? This is my google_calendars.yaml file:

- cal_id: [email protected]
  entities:
  - device_id: mail_XxXxX_de
    ignore_availability: true
    name: XxXxX
    track: true
    max_results: 100
  - device_id: urlaub
    name: Urlaub
    track: true
    search: "Urlaub"
    offset: "!!"
  - device_id: krank
    name: Krank
    track: true
    search: "Krank"
    offset: "!!"

- cal_id: [email protected]
  entities:
  - device_id: XxXxX
    ignore_availability: true
    name: XxXxX
    track: true
    max_results: 100

- cal_id: [email protected]
  entities:
  - device_id: ferien_bremen
    ignore_availability: true
    name: Ferien - Bremen
    track: false

- cal_id: [email protected]
  entities:
  - device_id: XxXxX
    ignore_availability: true
    name: XxXxX
    track: true
    max_results: 100

- cal_id: de.german#[email protected]
  entities:
  - device_id: feiertage_in_deutschland
    ignore_availability: true
    name: Feiertage in Deutschland
    track: false

- cal_id: addressbook#[email protected]
  entities:
  - device_id: contacts
    ignore_availability: true
    name: Contacts
    track: true

- cal_id: p#[email protected]
  entities:
  - device_id: weather
    ignore_availability: true
    name: Weather
    track: false

- cal_id: e_2_de#[email protected]
  entities:
  - device_id: week_numbers
    ignore_availability: true
    name: Week Numbers
    track: false

- cal_id: [email protected]
  entities:
  - device_id: abfuhrdaten_bremer_stadtreinigung
    ignore_availability: true
    name: Abfuhrdaten Bremer Stadtreinigung
    track: false
  - device_id: papier
    name: "Papier / Gelber Sack"
    track: true
    search: "Papier"
    offset: "!!"

The last one is the calendar added recently, after that the trouble began.

Definitely not as many as yours. Haven't made any changes at all. The only thing remotely related to google calendars, is I setup an automatic 15min notification for all events in the family calendar.

- cal_id: family#######@group.calendar.google.com
  entities:
  - device_id: family
    ignore_availability: true
    name: Family
    track: true

- cal_id: [email protected]
  entities:
  - device_id: abcdefg_gmail_com
    ignore_availability: true
    name: [email protected]
    track: false

- cal_id: [email protected]
  entities:
  - device_id: contacts
    ignore_availability: true
    name: Contacts
    track: false

- cal_id: [email protected]
  entities:
  - device_id: holidays
    ignore_availability: true
    name: Holidays
    track: true

- cal_id: [email protected]
  entities:
  - device_id: holidays_in_united_states
    ignore_availability: true
    name: Holidays in United States
    track: true

The new calendar card doesn't pull up any of my calendar entities. I had been running the old calendar card by ljmerza but since I updated HomeAssistant, the card had been throwing a 400 error. I deleted the Google token but no luck. I also tried the Google integration all over: deleted token file and google_calendar.yaml, and then created a new client ID and secret... HomeAssistant did generate a new token and google_calendars.yaml file but again, the calendar card still doesn't show any entities.

This is the only error I can see in the log. Can anyone please provide some guidance?

2020-11-13 12:40:03 WARNING (MainThread) [homeassistant.components.calendar] Setup of calendar platform google is taking over 10 seconds.

Was this page helpful?
0 / 5 - 0 ratings