scorpionmit01 / homebridge-jewish-calendar

Homebridge Plugin that provides contact sensors related to the Jewish Calendar.
MIT License
3 stars 3 forks source link

“Kodesh” sensor turning off and on unexpectedly #5

Open shayweiss opened 3 years ago

shayweiss commented 3 years ago

I’ve built 2 automations based on this plugin:

  1. Once the “Kodesh” sensor triggers On -> operate a scene that turns on all the lights needed
  2. Trigger: On 00:30 daily, Condition: if Kodesh contact is Open, Action: operate a scene that turns off all the lights needed.

In practice, light turned on as needed on Knissat Shabbat, but didn’t turn off at 00:30…

When I’ve looked at HB logs, I’ve noticed few weird things:

  1. At 00:30 there was nothing happening
  2. At 00:40 the scene of “Turn On” was triggered…

This led me to think that somewhere during evening (maybe at 00:00??) the “Kodesh” sensor was getting Off (hence on 00:30 the automation wasn’t done eventually…) but then around 00:40 “Kodesh” sensor triggered On again, which in turn activated the ”Turn On” scene…

Is that the expected behavior of the sensor? I couldn’t see any related logs of the plug-in in HB logs - is there any option to activate it?

shayweiss commented 3 years ago

When trying to figure out what's happening, I've added a notification on my iPhone for every time a status is changed in the Contact Sensor, and it looks like indeed this is what happening - on Friday 19:27 (Candle Light Time) sensor status changed to "Open", then, on midnight exactly, sensor status changed to "Close" (why??), then on Saturday 00:42 sensor status changed to "Open" again (why??), and finally on Saturday 20:40 contact status changed back to "Close" (this is Havdalah time):

WhatsApp Image 2021-06-20 at 13 39 07

When trying to look on Homebridge logs - they show the following around midnight:

[07/06/2021, 00:00:06] [JewishCalendar] Shifting the time by -2880 minutes. [07/06/2021, 00:00:06] [JewishCalendar] Test date is 2021-06-04T21:00:06.778Z [07/06/2021, 00:00:06] [JewishCalendar] Sunset Tonight: 04/06/2021, 19:42:07 [07/06/2021, 00:00:06] [JewishCalendar] This Year's Hebrew Months: [07/06/2021, 00:00:06] [JewishCalendar] { Tishri: 0, Heshvan: 1, Kislev: 2, Tevet: 3, Shevat: 4, Adar1: 5, Adar2: 5, Nisan: 6, Iyar: 7, Sivan: 8, Tamuz: 9, Av: 10, Elul: 11 }

... ...

[07/06/2021, 00:00:36] [JewishCalendar] Shifting the time by -2880 minutes. [07/06/2021, 00:00:36] [JewishCalendar] Test date is 2021-06-04T21:00:36.784Z [07/06/2021, 00:00:36] [JewishCalendar] Sunset Tonight: 04/06/2021, 19:42:07 [07/06/2021, 00:00:36] [JewishCalendar] This Year's Hebrew Months: [07/06/2021, 00:00:36] [JewishCalendar] { Tishri: 0, Heshvan: 1, Kislev: 2, Tevet: 3, Shevat: 4, Adar1: 5, Adar2: 5, Nisan: 6, Iyar: 7, Sivan: 8, Tamuz: 9, Av: 10, Elul: 11 }

... ...

[07/06/2021, 00:01:06] [JewishCalendar] Shifting the time by -2880 minutes. [07/06/2021, 00:01:06] [JewishCalendar] Test date is 2021-06-04T21:01:06.790Z [07/06/2021, 00:01:06] [JewishCalendar] Sunset Tonight: 04/06/2021, 19:42:07 [07/06/2021, 00:01:06] [JewishCalendar] This Year's Hebrew Months: [07/06/2021, 00:01:06] [JewishCalendar] { Tishri: 0, Heshvan: 1, Kislev: 2, Tevet: 3, Shevat: 4, Adar1: 5, Adar2: 5, Nisan: 6, Iyar: 7, Sivan: 8, Tamuz: 9, Av: 10, Elul: 11 }

and then around 00:42, the logs are: [07/06/2021, 00:41:37] [JewishCalendar] Shifting the time by -2880 minutes. [07/06/2021, 00:41:37] [JewishCalendar] Test date is 2021-06-04T21:41:37.169Z [07/06/2021, 00:41:37] [JewishCalendar] Sunset Tonight: 04/06/2021, 19:42:07 [07/06/2021, 00:41:37] [JewishCalendar] This Year's Hebrew Months: [07/06/2021, 00:41:37] [JewishCalendar] { Tishri: 0, Heshvan: 1, Kislev: 2, Tevet: 3, Shevat: 4, Adar1: 5, Adar2: 5, Nisan: 6, Iyar: 7, Sivan: 8, Tamuz: 9, Av: 10, Elul: 11 }

... ...

[07/06/2021, 00:42:07] [JewishCalendar] Shifting the time by -2880 minutes. [07/06/2021, 00:42:07] [JewishCalendar] Test date is 2021-06-04T21:42:07.173Z [07/06/2021, 00:42:07] [JewishCalendar] Sunset Tonight: 05/06/2021, 19:42:38 [07/06/2021, 00:42:07] [JewishCalendar] This Year's Hebrew Months: [07/06/2021, 00:42:07] [JewishCalendar] { Tishri: 0, Heshvan: 1, Kislev: 2, Tevet: 3, Shevat: 4, Adar1: 5, Adar2: 5, Nisan: 6, Iyar: 7, Sivan: 8, Tamuz: 9, Av: 10, Elul: 11 }

I do see that the check at [07/06/2021, 00:42:07] (in the "Sunset Tonight" line) only identifies for the 1st time that a day has changed (i.e. Sunset Tonight: 05/06/2021, 19:42:38), whereas all previous checks showed [07/06/2021, 00:41:37] [JewishCalendar] Sunset Tonight: 04/06/2021, 19:42:07

Hope this gives any clue...

shayweiss commented 3 years ago

Well, after playing a bit with some debug logs, it seems like we hit the same problem as described in https://github.com/mourner/suncalc/issues/11. I see some workaround suggestions there - maybe something similar can be implemented here as well? (BTW - is the latest version of SunCalc used here?)

Thanks!