Calendar sync is not working

I’ve had issues with the calendar not syncing properly over the last few versions, but now I’m on v4.18.0 and it’s not working at all.

The following error appears in the log:

2023-04-03T08:00:00+0000 <info> scene.checkCalendarTriggers.js:24 (SceneManager.checkCalendarTriggers) Checking calendar triggers at Mon, 03 Apr 2023 08:00:00 GMT
2023-04-03T08:00:00+0000 <warn> scene.actions.js:73 () TypeError: Cannot read properties of null (reading 'service')
    at DeviceManager.setValue (/src/server/lib/device/device.setValue.js:14:57)
    at /src/server/lib/scene/scene.actions.js:71:27
    at tryCatcher (/src/server/node_modules/bluebird/js/release/util.js:16:23)
    at MappingPromiseArray._promiseFulfilled (/src/server/node_modules/bluebird/js/release/map.js:68:38)
    at MappingPromiseArray.PromiseArray._iterate (/src/server/node_modules/bluebird/js/release/promise_array.js:115:31)
    at MappingPromiseArray.init (/src/server/node_modules/bluebird/js/release/promise_array.js:79:10)
    at MappingPromiseArray._asyncInit (/src/server/node_modules/bluebird/js/release/map.js:37:10)
    at _drainQueueStep (/src/server/node_modules/bluebird/js/release/async.js:97:12)
    at _drainQueue (/src/server/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/src/server/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues (/src/server/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (node:internal/timers:476:21)

When I click Sync now the following shows:

2023-04-03T08:19:22+0000 <info> calendar.requests.js:53 () CalDAV : Found calendar ******@*********
2023-04-03T08:19:22+0000 <info> calendar.requests.js:53 () CalDAV : Found calendar gladys
2023-04-03T08:19:22+0000 <info> calendar.syncUserCalendars.js:38 (CalDAVHandler.syncUserCalendars) CalDAV : Found 2 calendars.
2023-04-03T08:19:22+0000 <info> calendar.syncUserWebcals.js:16 (CalDAVHandler.syncUserWebcals) Webcal : Found 0 calendars.

On the Synchronization page the calender called “gladys” is set to sync.

I don’t think this error is related to Calendars issues, it’s a scene execution warning :slight_smile:

What kind of calendar is it ? When you say that the sync is not working, you don’t see new events in the calendar tab in Gladys ?

It’s a Google calendar.

I have a recurring event in the calendar at 9am every week day that runs a scene. I sometimes delete a single event from google, but that doesn’t get reflected on /dashboard/calendar.

Basically the calendar sync functionality just doesn’t work. The workaround I use is to remove the calendar integration entirely and then add it back.

Ok, there might be a specificity with your events that make the sync fail

Can you try to open Gladys logs, and at the same time run a sync manually so we can see the error ?

I clicked Sync Now and got the following in the logs:

2023-05-17T11:44:37+0000 <info> calendar.requests.js:53 () CalDAV : Found calendar ***@***
2023-05-17T11:44:37+0000 <info> calendar.requests.js:53 () CalDAV : Found calendar ***
2023-05-17T11:44:37+0000 <info> calendar.syncUserCalendars.js:38 (CalDAVHandler.syncUserCalendars) CalDAV : Found 2 calendars.
2023-05-17T11:44:37+0000 <info> calendar.syncUserWebcals.js:16 (CalDAVHandler.syncUserWebcals) Webcal : Found 0 calendars.

Then I added a new event to the Google Calendar and did the Sync Now again:

2023-05-17T11:50:29+0000 <info> calendar.requests.js:53 () CalDAV : Found calendar ***@***
2023-05-17T11:50:29+0000 <info> calendar.requests.js:53 () CalDAV : Found calendar ***
2023-05-17T11:50:29+0000 <info> calendar.syncUserCalendars.js:38 (CalDAVHandler.syncUserCalendars) CalDAV : Found 2 calendars.
2023-05-17T11:50:29+0000 <error> calendar.syncUserCalendars.js:73 (Promise.map.concurrency) Error: Bad status: 403
    at exports.XMLHttpRequest.request.onreadystatechange (/src/server/services/caldav/node_modules/dav-request/dav.js:3424:27)
    at exports.XMLHttpRequest.dispatchEvent (/src/server/services/caldav/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
    at setState (/src/server/services/caldav/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
    at IncomingMessage.<anonymous> (/src/server/services/caldav/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13)
    at IncomingMessage.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

But then I just hit the Sync Now button again and it worked:

2023-05-17T11:50:49+0000 <info> calendar.requests.js:53 () CalDAV : Found calendar ***@***
2023-05-17T11:50:49+0000 <info> calendar.requests.js:53 () CalDAV : Found calendar ***
2023-05-17T11:50:49+0000 <info> calendar.syncUserCalendars.js:38 (CalDAVHandler.syncUserCalendars) CalDAV : Found 2 calendars.
2023-05-17T11:50:49+0000 <info> calendar.syncUserWebcals.js:16 (CalDAVHandler.syncUserWebcals) Webcal : Found 0 calendars.

However, the new event does not show up on the /dashboard/calendar page.

Thanks for the logs !

@bertrandda Any idea what’s wrong here ?

just so you know, I never got this to work. Any change to the calendar required I reconfigured the integration from scratch. I gave up and switched to an iCloud calendar and it just works. I recommend removing the Google Calendar functionality as it’s just broken.

Thanks for your feedback!

Weird because it works fine on my side! You may have some events with some formatting that Gladys fails to parse.