Thank you for the reply!
As an attempted workaround I watched the network traffic to the google public calendar, and got a URL which uses a valid API key to the JSON object.
When I load that URL in a browser, I get the calendar JSON object as it passes the same arguments used by the google.calendar API.
e.g.:
https://clients6.google.com/calendar/v3/calendars/<google calendar ID redacted>/events?calendarId=<google calendar ID redacted>&singleEvents=true&timeZone=America%2FNew_York&key=<API key>&orderBy=startTime&timeMin=2023-11-10T00%3A00%3A00-05%3A00
So I tried modifying your code to fetch the JSON directly via the URL. I added jquery to the package.json dependencies
"jquery": "^3.7.1"
added it to the prerequisites in index.js
const jQuery = require("jquery");
Defined the calendarURL and modified the fetch routine to call the jquery library (instead of the google.calendar call)
jQuery.getJSON(calendarURL,
function (err, res) {
if (err) {
console.log("There was an error loading the gcal data: " + err);
return;
}
...
But when the add-on tries to execute it, it doesnāt find getJSON for some reason.
Events posted to sensor(s) at: Sat Nov 11 2023 13:28:00 GMT-0500 (Eastern Standard Time)
/index.js:434
jQuery.getJSON(calendarURL,
^
TypeError: jQuery.getJSON is not a function
at /index.js:434:11
at Array.forEach (<anonymous>)
at getEvents (/index.js:58:24)
at Task._execution (/index.js:564:11)
at Task.execute (/node_modules/node-cron/src/task.js:17:25)
at ScheduledTask.now (/node_modules/node-cron/src/scheduled-task.js:38:33)
at Scheduler.<anonymous> (/node_modules/node-cron/src/scheduled-task.js:25:18)
at Scheduler.emit (node:events:513:28)
at Timeout.matchTime [as _onTimeout] (/node_modules/node-cron/src/scheduler.js:30:26)
at listOnTimeout (node:internal/timers:559:17)
Not sure why that isnāt found in jquery, but Iām a novice at home assistant, so maybe Iām missing something.
In any case, Iāll add the request to the Github repository and if you get around to it I can provide the google public URL and the direct URL to the calendar JSON it returns.
Thank you!