Skip to content

Commit 0eafa27

Browse files
committed
Hold a single variable for the runtime data in the entity
1 parent 97e012a commit 0eafa27

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

homeassistant/components/jewish_calendar/entity.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,14 @@ def __init__(
4343
entry_type=DeviceEntryType.SERVICE,
4444
identifiers={(DOMAIN, config_entry.entry_id)},
4545
)
46-
data = config_entry.runtime_data
47-
self._location = data.location
48-
self._candle_lighting_offset = data.candle_lighting_offset
49-
self._havdalah_offset = data.havdalah_offset
50-
self._diaspora = data.diaspora
51-
set_language(data.language)
46+
self.data = config_entry.runtime_data
47+
set_language(self.data.language)
5248

5349
def make_zmanim(self, date: dt.date) -> Zmanim:
5450
"""Create a Zmanim object."""
5551
return Zmanim(
5652
date=date,
57-
location=self._location,
58-
candle_lighting_offset=self._candle_lighting_offset,
59-
havdalah_offset=self._havdalah_offset,
53+
location=self.data.location,
54+
candle_lighting_offset=self.data.candle_lighting_offset,
55+
havdalah_offset=self.data.havdalah_offset,
6056
)

homeassistant/components/jewish_calendar/sensor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def __init__(
207207
if description.key == "weekly_portion":
208208
self._attr_options = list(Parasha)
209209
elif description.key == "holiday":
210-
self._attr_options = HolidayDatabase(self._diaspora).get_all_names()
210+
self._attr_options = HolidayDatabase(self.data.diaspora).get_all_names()
211211

212212
async def async_added_to_hass(self) -> None:
213213
"""Call when entity is added to hass."""
@@ -217,7 +217,7 @@ async def async_added_to_hass(self) -> None:
217217
async def async_update(self) -> None:
218218
"""Update the state of the sensor."""
219219
now = dt_util.now()
220-
_LOGGER.debug("Now: %s Location: %r", now, self._location)
220+
_LOGGER.debug("Now: %s Location: %r", now, self.data.location)
221221

222222
today = now.date()
223223
event_date = get_astral_event_date(self.hass, SUN_EVENT_SUNSET, today)
@@ -230,7 +230,7 @@ async def async_update(self) -> None:
230230

231231
_LOGGER.debug("Now: %s Sunset: %s", now, sunset)
232232

233-
daytime_date = HDateInfo(today, diaspora=self._diaspora)
233+
daytime_date = HDateInfo(today, diaspora=self.data.diaspora)
234234

235235
# The Jewish day starts after darkness (called "tzais") and finishes at
236236
# sunset ("shkia"). The time in between is a gray area

0 commit comments

Comments
 (0)