Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for full-day events? #29

Open
maisun opened this issue Feb 21, 2021 · 7 comments
Open

Support for full-day events? #29

maisun opened this issue Feb 21, 2021 · 7 comments

Comments

@maisun
Copy link

maisun commented Feb 21, 2021

Hi,
I'm trying to setup some automation based on holiday calendar which contains only full day events (to mark the public holidays). When I start HomeBridge I got the error message. I suspect it is because the plugin doesn't support full day event?
[2/21/2021, 8:47:10 PM] TypeError: Cannot read property 'toJSDate' of null
at getTimes (/homebridge/node_modules/homebridge-calendar/node_modules/ical-expander/index.js:40:53)
at /homebridge/node_modules/homebridge-calendar/node_modules/ical-expander/index.js:110:38
at Array.forEach ()
at IcalExpander.between (/homebridge/node_modules/homebridge-calendar/node_modules/ical-expander/index.js:63:57)
at CalendarPoller._refreshCalendar (/homebridge/node_modules/homebridge-calendar/src/CalendarPoller.js:78:30)
at IncomingMessage. (/homebridge/node_modules/homebridge-calendar/src/CalendarPoller.js:54:14)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)

@maisun maisun changed the title Possible to connect to outlook.com calendar? Support for full-day events? Feb 21, 2021
@dkahia
Copy link

dkahia commented Feb 21, 2021

I think you need to confirm your calendar is accessible without authentication. It needs to be made public.

@maisun
Copy link
Author

maisun commented Feb 22, 2021

I think you need to confirm your calendar is accessible without authentication. It needs to be made public.

Hi, thanks for your reply! I think it is public as I can subscribe in my calendar without provide username/pwd. The link to the calendar is: webcal://ugenr.dk/ics/helligdage/dk.ics
I have no idea how to check if the ics is in valid format though..

@dkahia
Copy link

dkahia commented Feb 27, 2021

I added your url and it seems to connect fine. There are no holidays to test against until April.

{
"name": "Danish Holidays",
"url": "webcal://ugenr.dk/ics/helligdage/dk.ics",
"pollingInterval": 15,
"sensors": []
}

@maisun
Copy link
Author

maisun commented Feb 27, 2021

"sensors": []

Hi, thanks a lot for looking into it!
I have the same configuration, but strangely I got the error below which causes HomeBridge to reboot:
[2/27/2021, 9:26:32 PM] TypeError: Cannot read property 'toJSDate' of null
at getTimes (/homebridge/node_modules/homebridge-calendar/node_modules/ical-expander/index.js:40:53)
at /homebridge/node_modules/homebridge-calendar/node_modules/ical-expander/index.js:110:38
at Array.forEach ()
at IcalExpander.between (/homebridge/node_modules/homebridge-calendar/node_modules/ical-expander/index.js:63:57)
at CalendarPoller._refreshCalendar (/homebridge/node_modules/homebridge-calendar/src/CalendarPoller.js:78:30)
at IncomingMessage. (/homebridge/node_modules/homebridge-calendar/src/CalendarPoller.js:54:14)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)

My configuration:
{
"platform": "Calendar",
"calendars": [
{
"name": "Holidays",
"url": "webcal://ugenr.dk/ics/helligdage/dk.ics",
"pollingInterval": 15,
"sensors": []
}
]
}

I'm running HB 1.3.1 and plugin version 0.4.0

@dkahia
Copy link

dkahia commented Feb 27, 2021

OS | Ubuntu Focal Fossa (20.04.2 LTS)
Node.js v14.16.0
Npm v6.14.11

HB 1.3.1

@maisun
Copy link
Author

maisun commented Feb 27, 2021

OS | Ubuntu Focal Fossa (20.04.2 LTS)
Node.js v14.16.0
Npm v6.14.11

HB 1.3.1

Hi,
Ok so looks like nothing to do with HB 1.3.X.
I have Node.js in a lower version: v14.15.1, and running as docker container with Homebridge-UI.
Will try to upgrade Node and see if it solves. Thanks a lot for testing!

@maisun
Copy link
Author

maisun commented Feb 28, 2021

OS | Ubuntu Focal Fossa (20.04.2 LTS)
Node.js v14.16.0
Npm v6.14.11

HB 1.3.1

Hi,
Just want to report if I created a separate sub-bridge for Calendar plugin it now works fine, strange if I leave it in the main bridge it doesn't seem to parse the calendar correctly, maybe due to conflict with some HomeBridge dependencies. Anyways, I found that you can skip the invalid dates by:
const icalExpander = new IcalExpander({
ics: data,
maxIterations: 1000,
skipInvalidDates: true
});
Which I'd recommend to ensure in case of bad calendar format it doesn't crash homebridge.
Anyways, will see how it works out in April :-) Thanks a lot for your help!

Edit: I tried to print out the events after parsing and it looks like following:
{ "component": [ "vevent", [ [ "uid", {}, "text", "dk-nytå[email protected]" ], [ "summary", {}, "text", "Nytårsaften" ], [ "dtstamp", {}, "date-time", "2012-03-06T23:00:00Z" ], [ "dtstart", {}, "date", "2026-12-31" ], [ "duration", {}, "duration", "P1D" ], [ "url", {}, "uri", "https://ugenr.dk/nyt%C3%A5rsaften" ], [ "status", {}, "text", "CONFIRMED" ], [ "transp", {}, "text", "TRANSPARENT" ] ], [] ]

Does it look right? Basically I'd like to have a contact sensor that is open on 2026-12-31 at 0 o'clock local time, and off on 2026-12-31 at 23.59.59 local time. I notice "dtstamp" uses GMT time and not sure why "2012-03-06".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants