async def async_update(self): """Update the state of the sensor.""" import hdate today = dt_util.now().date() date = hdate.HDate(today, diaspora=self.diaspora, hebrew=self._hebrew) if self.type == 'date': self._state = hdate.date.get_hebrew_date(date.h_day, date.h_month, date.h_year, hebrew=self._hebrew) elif self.type == 'weekly_portion': self._state = hdate.date.get_parashe(date.get_reading( self.diaspora), hebrew=self._hebrew) elif self.type == 'holiday_name': try: self._state = next(x.description[self._hebrew].long for x in hdate.htables.HOLIDAYS if x.index == date.get_holyday()) except StopIteration: self._state = None elif self.type == 'holyness': self._state = hdate.date.get_holyday_type(date.get_holyday()) else: times = hdate.Zmanim(date=today, latitude=self.latitude, longitude=self.longitude, hebrew=self._hebrew).zmanim self._state = times[self.type].time() _LOGGER.debug("New value: %s", self._state)
async def async_update(self): """Update the state of the sensor.""" import hdate now = dt_util.as_local(dt_util.now()) _LOGGER.debug("Now: %s Timezone = %s", now, now.tzinfo) today = now.date() sunset = dt_util.as_local( get_astral_event_date(self.hass, SUN_EVENT_SUNSET, today)) _LOGGER.debug("Now: %s Sunset: %s", now, sunset) if now > sunset: today += timedelta(1) date = hdate.HDate(today, diaspora=self.diaspora, hebrew=self._hebrew) if self.type == 'date': self._state = date.hebrew_date elif self.type == 'weekly_portion': self._state = date.parasha elif self.type == 'holiday_name': self._state = date.holiday_description elif self.type == 'holyness': self._state = date.holiday_type else: times = hdate.Zmanim(date=today, latitude=self.latitude, longitude=self.longitude, timezone=self.timezone, hebrew=self._hebrew).zmanim self._state = times[self.type].time() _LOGGER.debug("New value: %s", self._state)
def make_zmanim(date): """Create a Zmanim object.""" return hdate.Zmanim( date=date, location=location, candle_lighting_offset=self.candle_lighting_offset, havdalah_offset=self.havdalah_offset, hebrew=self._hebrew)
def _get_zmanim(self): """Return the Zmanim object for now().""" return hdate.Zmanim( date=dt_util.now(), location=self._location, candle_lighting_offset=self._candle_lighting_offset, havdalah_offset=self._havdalah_offset, hebrew=self._hebrew, )
async def async_update(self): """Update the state of the sensor.""" zmanim = hdate.Zmanim( date=dt_util.now(), location=self._location, candle_lighting_offset=self._candle_lighting_offset, havdalah_offset=self._havdalah_offset, hebrew=self._hebrew, ) self._state = zmanim.issur_melacha_in_effect
async def async_update(self): """Update the state of the sensor.""" import hdate now = dt_util.as_local(dt_util.now()) _LOGGER.debug("Now: %s Timezone = %s", now, now.tzinfo) today = now.date() upcoming_saturday = today + timedelta((12 - today.weekday()) % 7) sunset = dt_util.as_local(get_astral_event_date( self.hass, SUN_EVENT_SUNSET, today)) _LOGGER.debug("Now: %s Sunset: %s", now, sunset) if now > sunset: today += timedelta(1) date = hdate.HDate( today, diaspora=self.diaspora, hebrew=self._hebrew) upcoming_shabbat = hdate.HDate( upcoming_saturday, diaspora=self.diaspora, hebrew=self._hebrew) if self.type == 'date': self._state = hdate.date.get_hebrew_date( date.h_day, date.h_month, date.h_year, hebrew=self._hebrew) elif self.type == 'weekly_portion': self._state = hdate.date.get_parashe( upcoming_shabbat.get_reading(self.diaspora), hebrew=self._hebrew) elif self.type == 'holiday_name': try: description = next( x.description[self._hebrew] for x in hdate.htables.HOLIDAYS if x.index == date.get_holyday()) if not self._hebrew: self._state = description else: self._state = description.long except StopIteration: self._state = None elif self.type == 'holyness': self._state = hdate.date.get_holyday_type(date.get_holyday()) else: times = hdate.Zmanim( date=today, latitude=self.latitude, longitude=self.longitude, timezone=self.timezone, hebrew=self._hebrew).zmanim self._state = times[self.type].time() _LOGGER.debug("New value: %s", self._state)
async def getZmanim(self, ctx): db = await aiosqlite.connect("haGaon.db") cursor = await db.cursor() await cursor.execute( f"SELECT * FROM main WHERE user_id = {ctx.message.author.id}") result = await cursor.fetchone() if result is None: await create_embed(ctx, "Run setLocation first!!") elif result is not None: dias = result[4] == "True" location = hdate.Location( longitude=float(result[2]), latitude=float(result[1]), timezone=result[3], diaspora=dias, ) await create_embed( ctx, str(hdate.Zmanim(location=location, hebrew=False))) await cursor.close() await db.close()