Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in jewish_calendar integration - Python Math ValueError thrown? #51641

Closed
NickInManchester opened this issue Jun 8, 2021 · 6 comments · Fixed by #119887
Closed

Error in jewish_calendar integration - Python Math ValueError thrown? #51641

NickInManchester opened this issue Jun 8, 2021 · 6 comments · Fixed by #119887

Comments

@NickInManchester
Copy link

The problem

For the integration author: Tsvi Mostovicz @tsvi
Also see: https://community.home-assistant.io/t/error-in-jewish-calendar-integration-python-math-valueerror-thrown/314289

At startup the "jewish_calendar" integration throws a Python Math ValueError exception many times but always in the same bit of code.

I'm running HA 2021.6.3 on a 4GB Raspberry PI4 using the standard integrated Home Assistant Operating System variant.

Version core-2021.6.3
Installation Type Home Assistant OS
Development false
Supervisor true
Docker true
Virtual Environment false
Python Version 3.8.9
Operating System Family Linux
Operating System Version 5.4.83-v8
CPU Architecture aarch64
Timezone Europe/London

The error is logged as follows:

What is version of Home Assistant Core has the issue?

core-2021.6.3

What was the last working version of Home Assistant Core?

core-2021.6.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

jewish_calendar

Link to integration documentation on our website

https://www.home-assistant.io/integrations/jewish_calendar/

Example YAML snippet

From configuration.yaml

jewish_calendar:
   language: english
   diaspora: true
   candle_lighting_minutes_before_sunset: 18
   havdalah_minutes_after_sunset: 0
#   latitude: 53.480759
#   longitude: -2.242631

Anything in the logs that might be useful for us?

Update for sensor.jewish_calendar_upcoming_havdalah_3 fails
8:54:14 PM – (ERROR) components/jewish_calendar/sensor.py - message first occurred at 5:05:14 PM and shows up 459 times
Update for sensor.jewish_calendar_upcoming_candle_lighting_3 fails
8:54:14 PM – (ERROR) components/jewish_calendar/sensor.py - message first occurred at 5:05:14 PM and shows up 459 times
Update for sensor.jewish_calendar_upcoming_shabbat_havdalah_3 fails
8:54:14 PM – (ERROR) components/jewish_calendar/sensor.py - message first occurred at 5:05:14 PM and shows up 459 times
Update for sensor.jewish_calendar_upcoming_shabbat_candle_lighting_3 fails
8:54:14 PM – (ERROR) components/jewish_calendar/sensor.py - message first occurred at 5:05:14 PM and shows up 459 times
Update for sensor.jewish_calendar_mincha_gedola_3 fails
8:54:14 PM – (ERROR) components/jewish_calendar/sensor.py - message first occurred at 5:05:14 PM and shows up 5049 times
=======================================================================
Just 1 of these many examples:

Logger: homeassistant.helpers.entity
Source: components/jewish_calendar/sensor.py:184
First occurred: 5:05:14 PM (459 occurrences)
Last logged: 8:54:14 PM

Update for sensor.jewish_calendar_upcoming_havdalah_3 fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 350, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 558, in async_device_update
    raise exc
  File "/usr/src/homeassistant/homeassistant/components/jewish_calendar/sensor.py", line 100, in async_update
    self._state = self.get_state(daytime_date, after_shkia_date, after_tzais_date)
  File "/usr/src/homeassistant/homeassistant/components/jewish_calendar/sensor.py", line 184, in get_state
    return times.havdalah
  File "/usr/local/lib/python3.8/site-packages/hdate/zmanim.py", line 186, in havdalah
    return self._havdalah_datetime
  File "/usr/local/lib/python3.8/site-packages/hdate/zmanim.py", line 162, in _havdalah_datetime
    return self.zmanim["sunset"] + dt.timedelta(minutes=self.havdalah_offset)
  File "/usr/local/lib/python3.8/site-packages/hdate/zmanim.py", line 130, in zmanim
    for key, value in self.utc_zmanim.items()
  File "/usr/local/lib/python3.8/site-packages/hdate/zmanim.py", line 122, in utc_zmanim
    for key, value in self.get_utc_sun_time_full().items()
  File "/usr/local/lib/python3.8/site-packages/hdate/zmanim.py", line 313, in get_utc_sun_time_full
    first_light = self._get_utc_time_of_transit(106.1, True)
  File "/usr/local/lib/python3.8/site-packages/hdate/zmanim.py", line 295, in _get_utc_time_of_transit
    return self._datetime_to_minutes_offest(astral.sun.time_of_transit(
  File "/usr/local/lib/python3.8/site-packages/astral/sun.py", line 343, in time_of_transit
    hourangle = hour_angle(
  File "/usr/local/lib/python3.8/site-packages/astral/sun.py", line 243, in hour_angle
    HA = acos(h)
ValueError: math domain error

Additional information

No response

@probot-home-assistant
Copy link

jewish_calendar documentation
jewish_calendar source
(message by IssueLinks)

@tsvi
Copy link
Contributor

tsvi commented Jun 9, 2021

@yuvalabou it's unrelated to the offset.
It has to do with certain latitudes (too much north or south) that will cause the calculations to reach extremities. We need to guard before sending the calculations to astral.

@NickInManchester
Copy link
Author

NickInManchester commented Jun 9, 2021 via email

@NickInManchester
Copy link
Author

NickInManchester commented Jun 9, 2021 via email

@github-actions
Copy link

github-actions bot commented Sep 7, 2021

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Sep 7, 2021
@NickInManchester
Copy link
Author

Seems thave been resolved. Please close.

Thanks

@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants