Skip to content

Commit

Permalink
Update sensor.py
Browse files Browse the repository at this point in the history
Fix Rosh Hashana times cause Shabbat
  • Loading branch information
rt400 authored Sep 29, 2024
1 parent 129e84c commit aea6244
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions custom_components/hebcal/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

_LOGGER = logging.getLogger(__name__)

version = "2.4.0"
version = "2.5.0"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
Expand Down Expand Up @@ -184,6 +184,8 @@ def __init__(
self._state = None
self.parashat = None
self.yomtov_name = None
self.rosh_hashana = False
self.holiday_count = 0
self.omer = False
self.hanucka = False
self.zmanim = {}
Expand Down Expand Up @@ -313,6 +315,8 @@ async def filter_db(self, temp_db, state):
"""Filters the database"""
if state == "new":
for extract_data in temp_db:
if "major" in list(extract_data.values()):
self.rosh_hashana = (True if any("Rosh Hashana" in str(value) for value in extract_data.values()) else False)
if "date" in extract_data:
extract_data["date"] = (
extract_data["date"][:19]
Expand All @@ -326,6 +330,7 @@ async def filter_db(self, temp_db, state):
self.shabbat_in = is_in
self.temp_data.append(extract_data)
elif is_in.isoweekday() != 6 and is_in.isoweekday() != 5:
self.holiday_count += 1
self.yomtov_in = is_in
self.temp_data.append(extract_data)
elif is_in.isoweekday() == 6:
Expand Down Expand Up @@ -400,11 +405,18 @@ async def filter_db(self, temp_db, state):
}
)
if self.yomtov_in and not self.yomtov_out:
self.yomtov_out = (
self.yomtov_in
+ datetime.timedelta(days=1)
+ datetime.timedelta(minutes=60)
)
if self.rosh_hashana:
self.yomtov_out = (
self.yomtov_in
+ datetime.timedelta(days=2)
+ datetime.timedelta(minutes=60)
)
else:
self.yomtov_out = (
self.yomtov_in
+ datetime.timedelta(days=1)
+ datetime.timedelta(minutes=60)
)
self.temp_data.append(
{
"hebrew": "הבדלה - 42 דקות",
Expand Down

0 comments on commit aea6244

Please sign in to comment.