grover / homebridge-calendar

A calendar plugin for homebridge (https://github.com/nfarina/homebridge), which allows flexible scheduling of triggers using any iCal calendar.
MIT License
73 stars 13 forks source link

plugin stops working if polling calendar returns an error #58

Open jfmach opened 9 months ago

jfmach commented 9 months ago

It seems the plugin stops working if polling the calendar returns an error. For instance mine is setup to poll every 15 minutes. It works like clockwork, but the moment it fails it doesn't try anymore. Only way to get it unstuck seems to be restarting homebridge:

[20/09/2023, 06:09:30] [homebridge-calendar] Pushing calendar sensor 'LCPS' state 1 - value 1
[20/09/2023, 06:09:31] [homebridge-calendar] Updating calendar Contractors
[20/09/2023, 06:09:32] [homebridge-calendar] Pushing calendar sensor 'Contractors' state 0 - value 0
[20/09/2023, 06:24:30] [homebridge-calendar] Updating calendar LCPS
[20/09/2023, 06:24:31] [homebridge-calendar] Setting LCPS to true
[20/09/2023, 06:24:31] [homebridge-calendar] Pushing calendar sensor 'LCPS' state 1 - value 1
[20/09/2023, 06:24:32] [homebridge-calendar] Updating calendar Contractors
[20/09/2023, 06:24:32] [homebridge-calendar] Pushing calendar sensor 'Contractors' state 0 - value 0
[20/09/2023, 06:39:31] [homebridge-calendar] Updating calendar LCPS
[20/09/2023, 06:39:31] [homebridge-calendar] Setting LCPS to true
[20/09/2023, 06:39:31] [homebridge-calendar] Pushing calendar sensor 'LCPS' state 1 - value 1
[20/09/2023, 06:39:32] [homebridge-calendar] Updating calendar Contractors
[20/09/2023, 06:39:32] [homebridge-calendar] Pushing calendar sensor 'Contractors' state 0 - value 0
[20/09/2023, 06:54:31] [homebridge-calendar] Updating calendar LCPS
[20/09/2023, 06:54:32] [homebridge-calendar] Setting LCPS to true
[20/09/2023, 06:54:32] [homebridge-calendar] Pushing calendar sensor 'LCPS' state 1 - value 1
[20/09/2023, 06:54:32] [homebridge-calendar] Updating calendar Contractors
[20/09/2023, 06:54:33] [homebridge-calendar] Pushing calendar sensor 'Contractors' state 0 - value 0
[20/09/2023, 07:09:32] [homebridge-calendar] Updating calendar LCPS
[20/09/2023, 07:09:33] [homebridge-calendar] Updating calendar Contractors
[20/09/2023, 07:09:42] [homebridge-calendar] Failed to load iCal calender: undefined with error Error: getaddrinfo ENOTFOUND p33-caldav.icloud.com
[20/09/2023, 07:09:42] [homebridge-calendar] Polling calendar LCPS has raised error: Error: getaddrinfo ENOTFOUND p33-caldav.icloud.com
[20/09/2023, 07:09:43] [homebridge-calendar] Failed to load iCal calender: undefined with error Error: getaddrinfo ENOTFOUND p106-caldav.icloud.com
[20/09/2023, 07:09:43] [homebridge-calendar] Polling calendar Contractors has raised error: Error: getaddrinfo ENOTFOUND p106-caldav.icloud.com

And then nothing (that was 2 hours ago)

jfmach commented 9 months ago

Quick and dirty workaround, added a cron job to check if this plugin reports an error and restart homebridge if it does:

*/5 * * * * if [ -n "$(grep homebridge-calendar /var/lib/homebridge/homebridge.log | tail -1 | grep -i error)" ]; then sudo hb-service restart && echo "homebridge-calendar error detected, homebridge service restarted" | logger; fi