[arch-commits] Commit in home-assistant/repos/community-any (6 files)

Maxime Gauduin alucryd at archlinux.org
Sat Dec 5 17:47:49 UTC 2020


    Date: Saturday, December 5, 2020 @ 17:47:49
  Author: alucryd
Revision: 770917

archrelease: copy trunk to community-any

Added:
  home-assistant/repos/community-any/PKGBUILD
    (from rev 770916, home-assistant/trunk/PKGBUILD)
  home-assistant/repos/community-any/home-assistant-astral2.2.patch
    (from rev 770916, home-assistant/trunk/home-assistant-astral2.2.patch)
  home-assistant/repos/community-any/home-assistant.service
    (from rev 770916, home-assistant/trunk/home-assistant.service)
Deleted:
  home-assistant/repos/community-any/PKGBUILD
  home-assistant/repos/community-any/home-assistant-astral2.2.patch
  home-assistant/repos/community-any/home-assistant.service

--------------------------------+
 PKGBUILD                       |  180 ++++++------
 home-assistant-astral2.2.patch |  564 +++++++++++++++++++--------------------
 home-assistant.service         |   56 +--
 3 files changed, 402 insertions(+), 398 deletions(-)

Deleted: PKGBUILD
===================================================================
--- PKGBUILD	2020-12-05 17:47:41 UTC (rev 770916)
+++ PKGBUILD	2020-12-05 17:47:49 UTC (rev 770917)
@@ -1,88 +0,0 @@
-# Maintainer: Maxime Gauduin <alucryd at archlinux.org>
-# Contributor: Ethan Skinner <aur at etskinner.com>
-# Contributor: Grégoire Seux <grego_aur at familleseux.net>
-# Contributor: Dean Galvin <deangalvin3 at gmail.com>
-# Contributor: NicoHood <archlinux at nicohood.de>
-
-pkgname=home-assistant
-pkgdesc='Open source home automation that puts local control and privacy first'
-pkgver=0.117.6
-pkgrel=1
-arch=(any)
-url=https://home-assistant.io/
-license=(APACHE)
-depends=(
-  gcc
-  python-aiohttp
-  python-aiohttp-cors
-  python-astral
-  python-async-timeout
-  python-attrs
-  python-bcrypt
-  python-certifi
-  python-ciso8601
-  python-cryptography
-  python-jinja
-  python-pillow
-  python-pip
-  python-pyjwt
-  python-pytz
-  python-requests
-  python-ruamel-yaml
-  python-slugify
-  python-sqlalchemy
-  python-voluptuous
-  python-voluptuous-serialize
-  python-yaml
-  python-yarl
-)
-makedepends=(
-  git
-  python-setuptools
-)
-optdepends=(
-  'net-tools: Nmap host discovery'
-  'openzwave: Z-Wave integration'
-  'python-dtlssocket: Ikea Tradfri integration'
-  'python-lxml: Meteo France integration'
-)
-_tag=7c783dc1b45ca63f071da9d3fc97d85b1b7039b7
-source=(
-  git+https://github.com/home-assistant/home-assistant.git#tag=${_tag}
-  home-assistant.service
-  home-assistant-astral2.2.patch
-)
-b2sums=('SKIP'
-        '0df7bbfdac09e37294ac27567e677855c72d13be3aefbd23e0a8f101cf2148302affbe9b6b586b893f77fc990f665d7b95f4916583680c06abd8f74b5cdf3da9'
-        'b8b13879e6db3f512aa3e2f86b485fe2ed55a2940b7f62d8cbcc706f05768585836f7c6496e5db30b0a6782e5842629f92d310872114795e4aa446d2da300eec')
-
-pkgver() {
-  cd home-assistant
-
-  git describe --tags
-}
-
-prepare() {
-  cd home-assistant
-
-  patch -Np1 -i ../home-assistant-astral2.2.patch
-
-  # lift hard dep constraints, we'll deal with breaking changes ourselves
-  sed 's/==/>=/g' -i setup.py homeassistant/package_constraints.txt
-}
-
-build() {
-  cd home-assistant
-
-  python setup.py build
-}
-
-package() {
-  cd home-assistant
-
-  python setup.py install --root="${pkgdir}" --prefix=/usr --optimize=1 --skip-build
-
-  install -Dm 644 ../home-assistant.service -t "${pkgdir}"/usr/lib/systemd/system/
-}
-
-# vim: ts=2 sw=2 et:

Copied: home-assistant/repos/community-any/PKGBUILD (from rev 770916, home-assistant/trunk/PKGBUILD)
===================================================================
--- PKGBUILD	                        (rev 0)
+++ PKGBUILD	2020-12-05 17:47:49 UTC (rev 770917)
@@ -0,0 +1,92 @@
+# Maintainer: Maxime Gauduin <alucryd at archlinux.org>
+# Contributor: Ethan Skinner <aur at etskinner.com>
+# Contributor: Grégoire Seux <grego_aur at familleseux.net>
+# Contributor: Dean Galvin <deangalvin3 at gmail.com>
+# Contributor: NicoHood <archlinux at nicohood.de>
+
+pkgname=home-assistant
+pkgdesc='Open source home automation that puts local control and privacy first'
+pkgver=0.118.5
+pkgrel=1
+arch=(any)
+url=https://home-assistant.io/
+license=(APACHE)
+depends=(
+  gcc
+  python-aiohttp
+  python-aiohttp-cors
+  python-astral
+  python-async-timeout
+  python-attrs
+  python-bcrypt
+  python-certifi
+  python-ciso8601
+  python-cryptography
+  python-defusedxml
+  python-httpx
+  python-jinja
+  python-mutagen
+  python-pillow
+  python-pip
+  python-pyjwt
+  python-pytz
+  python-requests
+  python-ruamel-yaml
+  python-slugify
+  python-sqlalchemy
+  python-voluptuous
+  python-voluptuous-serialize
+  python-yaml
+  python-yarl
+  python-zeroconf
+)
+makedepends=(
+  git
+  python-setuptools
+)
+optdepends=(
+  'net-tools: Nmap host discovery'
+  'openzwave: Z-Wave integration'
+  'python-dtlssocket: Ikea Tradfri integration'
+  'python-lxml: Meteo France integration'
+)
+_tag=7130b7a4b7d876151d2edc55e83486b84f017ebf
+source=(
+  git+https://github.com/home-assistant/home-assistant.git#tag=${_tag}
+  home-assistant.service
+  home-assistant-astral2.2.patch
+)
+b2sums=('SKIP'
+        '0df7bbfdac09e37294ac27567e677855c72d13be3aefbd23e0a8f101cf2148302affbe9b6b586b893f77fc990f665d7b95f4916583680c06abd8f74b5cdf3da9'
+        'e2e4c8f4c20932d6f10812ed06a30234de8c6c9b364c8ea98976d1b7546256d7917a2d4649da3c9880f7e542ec161f91295f11cd15f77f21100822aacb9b0753')
+
+pkgver() {
+  cd home-assistant
+
+  git describe --tags
+}
+
+prepare() {
+  cd home-assistant
+
+  patch -Np1 -i ../home-assistant-astral2.2.patch
+
+  # lift hard dep constraints, we'll deal with breaking changes ourselves
+  sed 's/==/>=/g' -i setup.py homeassistant/package_constraints.txt
+}
+
+build() {
+  cd home-assistant
+
+  python setup.py build
+}
+
+package() {
+  cd home-assistant
+
+  python setup.py install --root="${pkgdir}" --prefix=/usr --optimize=1 --skip-build
+
+  install -Dm 644 ../home-assistant.service -t "${pkgdir}"/usr/lib/systemd/system/
+}
+
+# vim: ts=2 sw=2 et:

Deleted: home-assistant-astral2.2.patch
===================================================================
--- home-assistant-astral2.2.patch	2020-12-05 17:47:41 UTC (rev 770916)
+++ home-assistant-astral2.2.patch	2020-12-05 17:47:49 UTC (rev 770917)
@@ -1,282 +0,0 @@
-From d32f28bd1737212b571dab204208cf34e6e58df2 Mon Sep 17 00:00:00 2001
-From: Maxime Gauduin <alucryd at archlinux.org>
-Date: Thu, 27 Feb 2020 17:27:37 +0100
-Subject: [PATCH] bump astral to 2.2
-
----
- homeassistant/components/moon/sensor.py  |  4 +-
- homeassistant/components/sun/__init__.py | 20 +++++-----
- homeassistant/helpers/sun.py             | 51 ++++++++++++++----------
- homeassistant/package_constraints.txt    |  2 +-
- requirements.txt                         |  2 +-
- setup.py                                 |  2 +-
- 6 files changed, 47 insertions(+), 34 deletions(-)
-
-diff --git a/homeassistant/components/moon/sensor.py b/homeassistant/components/moon/sensor.py
-index f7914177f8..9b29b071ee 100644
---- a/homeassistant/components/moon/sensor.py
-+++ b/homeassistant/components/moon/sensor.py
-@@ -1,5 +1,5 @@
- """Support for tracking the moon phases."""
--from astral import Astral
-+from astral import moon
- import voluptuous as vol
- 
- from homeassistant.components.sensor import PLATFORM_SCHEMA
-@@ -87,4 +87,4 @@ class MoonSensor(Entity):
-     async def async_update(self):
-         """Get the time and updates the states."""
-         today = dt_util.as_local(dt_util.utcnow()).date()
--        self._state = Astral().moon_phase(today)
-+        self._state = moon.phase(today)
-diff --git a/homeassistant/components/sun/__init__.py b/homeassistant/components/sun/__init__.py
-index 2d921da4a4..ec8f4b325a 100644
---- a/homeassistant/components/sun/__init__.py
-+++ b/homeassistant/components/sun/__init__.py
-@@ -92,6 +92,7 @@ class Sun(Entity):
-         """Initialize the sun."""
-         self.hass = hass
-         self.location = None
-+        self.elevation = 0.0
-         self._state = self.next_rising = self.next_setting = None
-         self.next_dawn = self.next_dusk = None
-         self.next_midnight = self.next_noon = None
-@@ -100,10 +101,11 @@ class Sun(Entity):
-         self._next_change = None
- 
-         def update_location(_event):
--            location = get_astral_location(self.hass)
-+            location, elevation = get_astral_location(self.hass)
-             if location == self.location:
-                 return
-             self.location = location
-+            self.elevation = elevation
-             self.update_events()
- 
-         update_location(None)
-@@ -140,7 +142,7 @@ class Sun(Entity):
- 
-     def _check_event(self, utc_point_in_time, sun_event, before):
-         next_utc = get_location_astral_event_next(
--            self.location, sun_event, utc_point_in_time
-+            self.location, self.elevation, sun_event, utc_point_in_time
-         )
-         if next_utc < self._next_change:
-             self._next_change = next_utc
-@@ -169,7 +171,7 @@ class Sun(Entity):
-         )
-         self.location.solar_depression = -10
-         self._check_event(utc_point_in_time, "dawn", PHASE_SMALL_DAY)
--        self.next_noon = self._check_event(utc_point_in_time, "solar_noon", None)
-+        self.next_noon = self._check_event(utc_point_in_time, "noon", None)
-         self._check_event(utc_point_in_time, "dusk", PHASE_DAY)
-         self.next_setting = self._check_event(
-             utc_point_in_time, SUN_EVENT_SUNSET, PHASE_SMALL_DAY
-@@ -180,9 +182,7 @@ class Sun(Entity):
-         self._check_event(utc_point_in_time, "dusk", PHASE_NAUTICAL_TWILIGHT)
-         self.location.solar_depression = "astronomical"
-         self._check_event(utc_point_in_time, "dusk", PHASE_ASTRONOMICAL_TWILIGHT)
--        self.next_midnight = self._check_event(
--            utc_point_in_time, "solar_midnight", None
--        )
-+        self.next_midnight = self._check_event(utc_point_in_time, "midnight", None)
-         self.location.solar_depression = "civil"
- 
-         # if the event was solar midday or midnight, phase will now
-@@ -190,7 +190,7 @@ class Sun(Entity):
-         # even in the day at the poles, so we can't rely on it.
-         # Need to calculate phase if next is noon or midnight
-         if self.phase is None:
--            elevation = self.location.solar_elevation(self._next_change)
-+            elevation = self.location.solar_elevation(self._next_change, self.elevation)
-             if elevation >= 10:
-                 self.phase = PHASE_DAY
-             elif elevation >= 0:
-@@ -222,9 +222,11 @@ class Sun(Entity):
-         """Calculate the position of the sun."""
-         # Grab current time in case system clock changed since last time we ran.
-         utc_point_in_time = dt_util.utcnow()
--        self.solar_azimuth = round(self.location.solar_azimuth(utc_point_in_time), 2)
-+        self.solar_azimuth = round(
-+            self.location.solar_azimuth(utc_point_in_time, self.elevation), 2
-+        )
-         self.solar_elevation = round(
--            self.location.solar_elevation(utc_point_in_time), 2
-+            self.location.solar_elevation(utc_point_in_time, self.elevation), 2
-         )
- 
-         _LOGGER.debug(
-diff --git a/homeassistant/helpers/sun.py b/homeassistant/helpers/sun.py
-index 818010c341..f1f7ee1f19 100644
---- a/homeassistant/helpers/sun.py
-+++ b/homeassistant/helpers/sun.py
-@@ -1,6 +1,6 @@
- """Helpers for sun events."""
- import datetime
--from typing import TYPE_CHECKING, Optional, Union
-+from typing import TYPE_CHECKING, Optional, Tuple, Union
- 
- from homeassistant.const import SUN_EVENT_SUNRISE, SUN_EVENT_SUNSET
- from homeassistant.core import callback
-@@ -14,28 +14,32 @@ if TYPE_CHECKING:
- 
- DATA_LOCATION_CACHE = "astral_location_cache"
- 
-+ELEVATION_AGNOSTIC_EVENTS = ("noon", "midnight")
-+
- 
- @callback
- @bind_hass
--def get_astral_location(hass: HomeAssistantType) -> "astral.Location":
-+def get_astral_location(
-+    hass: HomeAssistantType,
-+) -> Tuple["astral.location.Location", "astral.Elevation"]:
-     """Get an astral location for the current Home Assistant configuration."""
-+    from astral import LocationInfo # pylint: disable=import-outside-toplevel
-+    from astral.location import Location # pylint: disable=import-outside-toplevel
- 
--    from astral import Location  # pylint: disable=import-outside-toplevel
--
-+    timezone = str(hass.config.time_zone)
-     latitude = hass.config.latitude
-     longitude = hass.config.longitude
--    timezone = str(hass.config.time_zone)
-     elevation = hass.config.elevation
--    info = ("", "", latitude, longitude, timezone, elevation)
-+    info = ("", "", timezone, latitude, longitude)
- 
-     # Cache astral locations so they aren't recreated with the same args
-     if DATA_LOCATION_CACHE not in hass.data:
-         hass.data[DATA_LOCATION_CACHE] = {}
- 
-     if info not in hass.data[DATA_LOCATION_CACHE]:
--        hass.data[DATA_LOCATION_CACHE][info] = Location(info)
-+        hass.data[DATA_LOCATION_CACHE][info] = Location(LocationInfo(*info))
- 
--    return hass.data[DATA_LOCATION_CACHE][info]
-+    return hass.data[DATA_LOCATION_CACHE][info], elevation
- 
- 
- @callback
-@@ -47,26 +51,31 @@ def get_astral_event_next(
-     offset: Optional[datetime.timedelta] = None,
- ) -> datetime.datetime:
-     """Calculate the next specified solar event."""
--    location = get_astral_location(hass)
--    return get_location_astral_event_next(location, event, utc_point_in_time, offset)
-+    location, elevation = get_astral_location(hass)
-+    return get_location_astral_event_next(
-+        location, elevation, event, utc_point_in_time, offset
-+    )
- 
- 
- @callback
- def get_location_astral_event_next(
--    location: "astral.Location",
-+    location: "astral.location.Location",
-+    elevation: "astral.Elevation",
-     event: str,
-     utc_point_in_time: Optional[datetime.datetime] = None,
-     offset: Optional[datetime.timedelta] = None,
- ) -> datetime.datetime:
-     """Calculate the next specified solar event."""
--    from astral import AstralError  # pylint: disable=import-outside-toplevel
--
-     if offset is None:
-         offset = datetime.timedelta()
- 
-     if utc_point_in_time is None:
-         utc_point_in_time = dt_util.utcnow()
- 
-+    kwargs = {"local": False}
-+    if event not in ELEVATION_AGNOSTIC_EVENTS:
-+        kwargs["observer_elevation"] = elevation
-+
-     mod = -1
-     while True:
-         try:
-@@ -74,13 +83,13 @@ def get_location_astral_event_next(
-                 getattr(location, event)(
-                     dt_util.as_local(utc_point_in_time).date()
-                     + datetime.timedelta(days=mod),
--                    local=False,
-+                    **kwargs,
-                 )
-                 + offset
-             )
-             if next_dt > utc_point_in_time:
-                 return next_dt
--        except AstralError:
-+        except ValueError:
-             pass
-         mod += 1
- 
-@@ -93,9 +102,7 @@ def get_astral_event_date(
-     date: Union[datetime.date, datetime.datetime, None] = None,
- ) -> Optional[datetime.datetime]:
-     """Calculate the astral event time for the specified date."""
--    from astral import AstralError  # pylint: disable=import-outside-toplevel
--
--    location = get_astral_location(hass)
-+    location, elevation = get_astral_location(hass)
- 
-     if date is None:
-         date = dt_util.now().date()
-@@ -103,9 +110,13 @@ def get_astral_event_date(
-     if isinstance(date, datetime.datetime):
-         date = dt_util.as_local(date).date()
- 
-+    kwargs = {"local": False}
-+    if event not in ELEVATION_AGNOSTIC_EVENTS:
-+        kwargs["observer_elevation"] = elevation
-+
-     try:
--        return getattr(location, event)(date, local=False)  # type: ignore
--    except AstralError:
-+        return getattr(location, event)(date, **kwargs)  # type: ignore
-+    except ValueError:
-         # Event never occurs for specified date.
-         return None
- 
-diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt
-index 01c2a30d2d..4951b333dc 100644
---- a/homeassistant/package_constraints.txt
-+++ b/homeassistant/package_constraints.txt
-@@ -2,7 +2,7 @@ PyJWT==1.7.1
- PyNaCl==1.3.0
- aiohttp==3.6.2
- aiohttp_cors==0.7.0
--astral==1.10.1
-+astral==2.2
- async_timeout==3.0.1
- attrs==19.3.0
- bcrypt==3.1.7
-diff --git a/requirements.txt b/requirements.txt
-index 498b948e47..10b5b887e8 100644
---- a/requirements.txt
-+++ b/requirements.txt
-@@ -2,7 +2,7 @@
- 
- # Home Assistant Core
- aiohttp==3.6.2
--astral==1.10.1
-+astral==2.2
- async_timeout==3.0.1
- attrs==19.3.0
- bcrypt==3.1.7
-diff --git a/setup.py b/setup.py
-index a1794f7880..68d822a808 100755
---- a/setup.py
-+++ b/setup.py
-@@ -33,7 +33,7 @@ PACKAGES = find_packages(exclude=["tests", "tests.*"])
- 
- REQUIRES = [
-     "aiohttp==3.6.2",
--    "astral==1.10.1",
-+    "astral==2.2",
-     "async_timeout==3.0.1",
-     "attrs==19.3.0",
-     "bcrypt==3.1.7",
--- 
-2.29.2
-

Copied: home-assistant/repos/community-any/home-assistant-astral2.2.patch (from rev 770916, home-assistant/trunk/home-assistant-astral2.2.patch)
===================================================================
--- home-assistant-astral2.2.patch	                        (rev 0)
+++ home-assistant-astral2.2.patch	2020-12-05 17:47:49 UTC (rev 770917)
@@ -0,0 +1,282 @@
+From a675013a44de962bf63a6937d08a84789b897a80 Mon Sep 17 00:00:00 2001
+From: Maxime Gauduin <alucryd at archlinux.org>
+Date: Thu, 27 Feb 2020 17:27:37 +0100
+Subject: [PATCH] bump astral to 2.2
+
+---
+ homeassistant/components/moon/sensor.py  |  4 +-
+ homeassistant/components/sun/__init__.py | 20 +++++-----
+ homeassistant/helpers/sun.py             | 51 ++++++++++++++----------
+ homeassistant/package_constraints.txt    |  2 +-
+ requirements.txt                         |  2 +-
+ setup.py                                 |  2 +-
+ 6 files changed, 47 insertions(+), 34 deletions(-)
+
+diff --git a/homeassistant/components/moon/sensor.py b/homeassistant/components/moon/sensor.py
+index f7914177f8..9b29b071ee 100644
+--- a/homeassistant/components/moon/sensor.py
++++ b/homeassistant/components/moon/sensor.py
+@@ -1,5 +1,5 @@
+ """Support for tracking the moon phases."""
+-from astral import Astral
++from astral import moon
+ import voluptuous as vol
+ 
+ from homeassistant.components.sensor import PLATFORM_SCHEMA
+@@ -87,4 +87,4 @@ class MoonSensor(Entity):
+     async def async_update(self):
+         """Get the time and updates the states."""
+         today = dt_util.as_local(dt_util.utcnow()).date()
+-        self._state = Astral().moon_phase(today)
++        self._state = moon.phase(today)
+diff --git a/homeassistant/components/sun/__init__.py b/homeassistant/components/sun/__init__.py
+index 2d921da4a4..ec8f4b325a 100644
+--- a/homeassistant/components/sun/__init__.py
++++ b/homeassistant/components/sun/__init__.py
+@@ -92,6 +92,7 @@ class Sun(Entity):
+         """Initialize the sun."""
+         self.hass = hass
+         self.location = None
++        self.elevation = 0.0
+         self._state = self.next_rising = self.next_setting = None
+         self.next_dawn = self.next_dusk = None
+         self.next_midnight = self.next_noon = None
+@@ -100,10 +101,11 @@ class Sun(Entity):
+         self._next_change = None
+ 
+         def update_location(_event):
+-            location = get_astral_location(self.hass)
++            location, elevation = get_astral_location(self.hass)
+             if location == self.location:
+                 return
+             self.location = location
++            self.elevation = elevation
+             self.update_events()
+ 
+         update_location(None)
+@@ -140,7 +142,7 @@ class Sun(Entity):
+ 
+     def _check_event(self, utc_point_in_time, sun_event, before):
+         next_utc = get_location_astral_event_next(
+-            self.location, sun_event, utc_point_in_time
++            self.location, self.elevation, sun_event, utc_point_in_time
+         )
+         if next_utc < self._next_change:
+             self._next_change = next_utc
+@@ -169,7 +171,7 @@ class Sun(Entity):
+         )
+         self.location.solar_depression = -10
+         self._check_event(utc_point_in_time, "dawn", PHASE_SMALL_DAY)
+-        self.next_noon = self._check_event(utc_point_in_time, "solar_noon", None)
++        self.next_noon = self._check_event(utc_point_in_time, "noon", None)
+         self._check_event(utc_point_in_time, "dusk", PHASE_DAY)
+         self.next_setting = self._check_event(
+             utc_point_in_time, SUN_EVENT_SUNSET, PHASE_SMALL_DAY
+@@ -180,9 +182,7 @@ class Sun(Entity):
+         self._check_event(utc_point_in_time, "dusk", PHASE_NAUTICAL_TWILIGHT)
+         self.location.solar_depression = "astronomical"
+         self._check_event(utc_point_in_time, "dusk", PHASE_ASTRONOMICAL_TWILIGHT)
+-        self.next_midnight = self._check_event(
+-            utc_point_in_time, "solar_midnight", None
+-        )
++        self.next_midnight = self._check_event(utc_point_in_time, "midnight", None)
+         self.location.solar_depression = "civil"
+ 
+         # if the event was solar midday or midnight, phase will now
+@@ -190,7 +190,7 @@ class Sun(Entity):
+         # even in the day at the poles, so we can't rely on it.
+         # Need to calculate phase if next is noon or midnight
+         if self.phase is None:
+-            elevation = self.location.solar_elevation(self._next_change)
++            elevation = self.location.solar_elevation(self._next_change, self.elevation)
+             if elevation >= 10:
+                 self.phase = PHASE_DAY
+             elif elevation >= 0:
+@@ -222,9 +222,11 @@ class Sun(Entity):
+         """Calculate the position of the sun."""
+         # Grab current time in case system clock changed since last time we ran.
+         utc_point_in_time = dt_util.utcnow()
+-        self.solar_azimuth = round(self.location.solar_azimuth(utc_point_in_time), 2)
++        self.solar_azimuth = round(
++            self.location.solar_azimuth(utc_point_in_time, self.elevation), 2
++        )
+         self.solar_elevation = round(
+-            self.location.solar_elevation(utc_point_in_time), 2
++            self.location.solar_elevation(utc_point_in_time, self.elevation), 2
+         )
+ 
+         _LOGGER.debug(
+diff --git a/homeassistant/helpers/sun.py b/homeassistant/helpers/sun.py
+index 818010c341..f1f7ee1f19 100644
+--- a/homeassistant/helpers/sun.py
++++ b/homeassistant/helpers/sun.py
+@@ -1,6 +1,6 @@
+ """Helpers for sun events."""
+ import datetime
+-from typing import TYPE_CHECKING, Optional, Union
++from typing import TYPE_CHECKING, Optional, Tuple, Union
+ 
+ from homeassistant.const import SUN_EVENT_SUNRISE, SUN_EVENT_SUNSET
+ from homeassistant.core import callback
+@@ -14,28 +14,32 @@ if TYPE_CHECKING:
+ 
+ DATA_LOCATION_CACHE = "astral_location_cache"
+ 
++ELEVATION_AGNOSTIC_EVENTS = ("noon", "midnight")
++
+ 
+ @callback
+ @bind_hass
+-def get_astral_location(hass: HomeAssistantType) -> "astral.Location":
++def get_astral_location(
++    hass: HomeAssistantType,
++) -> Tuple["astral.location.Location", "astral.Elevation"]:
+     """Get an astral location for the current Home Assistant configuration."""
++    from astral import LocationInfo # pylint: disable=import-outside-toplevel
++    from astral.location import Location # pylint: disable=import-outside-toplevel
+ 
+-    from astral import Location  # pylint: disable=import-outside-toplevel
+-
++    timezone = str(hass.config.time_zone)
+     latitude = hass.config.latitude
+     longitude = hass.config.longitude
+-    timezone = str(hass.config.time_zone)
+     elevation = hass.config.elevation
+-    info = ("", "", latitude, longitude, timezone, elevation)
++    info = ("", "", timezone, latitude, longitude)
+ 
+     # Cache astral locations so they aren't recreated with the same args
+     if DATA_LOCATION_CACHE not in hass.data:
+         hass.data[DATA_LOCATION_CACHE] = {}
+ 
+     if info not in hass.data[DATA_LOCATION_CACHE]:
+-        hass.data[DATA_LOCATION_CACHE][info] = Location(info)
++        hass.data[DATA_LOCATION_CACHE][info] = Location(LocationInfo(*info))
+ 
+-    return hass.data[DATA_LOCATION_CACHE][info]
++    return hass.data[DATA_LOCATION_CACHE][info], elevation
+ 
+ 
+ @callback
+@@ -47,26 +51,31 @@ def get_astral_event_next(
+     offset: Optional[datetime.timedelta] = None,
+ ) -> datetime.datetime:
+     """Calculate the next specified solar event."""
+-    location = get_astral_location(hass)
+-    return get_location_astral_event_next(location, event, utc_point_in_time, offset)
++    location, elevation = get_astral_location(hass)
++    return get_location_astral_event_next(
++        location, elevation, event, utc_point_in_time, offset
++    )
+ 
+ 
+ @callback
+ def get_location_astral_event_next(
+-    location: "astral.Location",
++    location: "astral.location.Location",
++    elevation: "astral.Elevation",
+     event: str,
+     utc_point_in_time: Optional[datetime.datetime] = None,
+     offset: Optional[datetime.timedelta] = None,
+ ) -> datetime.datetime:
+     """Calculate the next specified solar event."""
+-    from astral import AstralError  # pylint: disable=import-outside-toplevel
+-
+     if offset is None:
+         offset = datetime.timedelta()
+ 
+     if utc_point_in_time is None:
+         utc_point_in_time = dt_util.utcnow()
+ 
++    kwargs = {"local": False}
++    if event not in ELEVATION_AGNOSTIC_EVENTS:
++        kwargs["observer_elevation"] = elevation
++
+     mod = -1
+     while True:
+         try:
+@@ -74,13 +83,13 @@ def get_location_astral_event_next(
+                 getattr(location, event)(
+                     dt_util.as_local(utc_point_in_time).date()
+                     + datetime.timedelta(days=mod),
+-                    local=False,
++                    **kwargs,
+                 )
+                 + offset
+             )
+             if next_dt > utc_point_in_time:
+                 return next_dt
+-        except AstralError:
++        except ValueError:
+             pass
+         mod += 1
+ 
+@@ -93,9 +102,7 @@ def get_astral_event_date(
+     date: Union[datetime.date, datetime.datetime, None] = None,
+ ) -> Optional[datetime.datetime]:
+     """Calculate the astral event time for the specified date."""
+-    from astral import AstralError  # pylint: disable=import-outside-toplevel
+-
+-    location = get_astral_location(hass)
++    location, elevation = get_astral_location(hass)
+ 
+     if date is None:
+         date = dt_util.now().date()
+@@ -103,9 +110,13 @@ def get_astral_event_date(
+     if isinstance(date, datetime.datetime):
+         date = dt_util.as_local(date).date()
+ 
++    kwargs = {"local": False}
++    if event not in ELEVATION_AGNOSTIC_EVENTS:
++        kwargs["observer_elevation"] = elevation
++
+     try:
+-        return getattr(location, event)(date, local=False)  # type: ignore
+-    except AstralError:
++        return getattr(location, event)(date, **kwargs)  # type: ignore
++    except ValueError:
+         # Event never occurs for specified date.
+         return None
+ 
+diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt
+index 33a9466f4d..0d7cdf4862 100644
+--- a/homeassistant/package_constraints.txt
++++ b/homeassistant/package_constraints.txt
+@@ -2,7 +2,7 @@ PyJWT==1.7.1
+ PyNaCl==1.3.0
+ aiohttp==3.7.1
+ aiohttp_cors==0.7.0
+-astral==1.10.1
++astral==2.2
+ async_timeout==3.0.1
+ attrs==19.3.0
+ bcrypt==3.1.7
+diff --git a/requirements.txt b/requirements.txt
+index ece1877ea7..4026232eea 100644
+--- a/requirements.txt
++++ b/requirements.txt
+@@ -2,7 +2,7 @@
+ 
+ # Home Assistant Core
+ aiohttp==3.7.1
+-astral==1.10.1
++astral==2.2
+ async_timeout==3.0.1
+ attrs==19.3.0
+ bcrypt==3.1.7
+diff --git a/setup.py b/setup.py
+index d5d133d4a3..ee284b9d87 100755
+--- a/setup.py
++++ b/setup.py
+@@ -33,7 +33,7 @@ PACKAGES = find_packages(exclude=["tests", "tests.*"])
+ 
+ REQUIRES = [
+     "aiohttp==3.7.1",
+-    "astral==1.10.1",
++    "astral==2.2",
+     "async_timeout==3.0.1",
+     "attrs==19.3.0",
+     "bcrypt==3.1.7",
+-- 
+2.29.2
+

Deleted: home-assistant.service
===================================================================
--- home-assistant.service	2020-12-05 17:47:41 UTC (rev 770916)
+++ home-assistant.service	2020-12-05 17:47:49 UTC (rev 770917)
@@ -1,28 +0,0 @@
-[Unit]
-Description=Home assistant
-After=network.target
-
-[Service]
-Restart=on-failure
-User=hass
-Group=hass
-DynamicUser=true
-LogsDirectory=hass
-StateDirectory=hass
-
-ExecStart=/usr/bin/hass \
-  --config /var/lib/hass/ \
-  --log-file /var/log/hass/home-assistant.log \
-  --log-rotate-days 1 \
-  --runner
-RestartForceExitStatus=100
-
-AmbientCapabilities=
-CapabilityBoundingSet=
-LockPersonality=true
-ProtectControlGroups=true
-ProtectKernelModules=true
-ProtectKernelTunables=true
-
-[Install]
-WantedBy=multi-user.target

Copied: home-assistant/repos/community-any/home-assistant.service (from rev 770916, home-assistant/trunk/home-assistant.service)
===================================================================
--- home-assistant.service	                        (rev 0)
+++ home-assistant.service	2020-12-05 17:47:49 UTC (rev 770917)
@@ -0,0 +1,28 @@
+[Unit]
+Description=Home assistant
+After=network.target
+
+[Service]
+Restart=on-failure
+User=hass
+Group=hass
+DynamicUser=true
+LogsDirectory=hass
+StateDirectory=hass
+
+ExecStart=/usr/bin/hass \
+  --config /var/lib/hass/ \
+  --log-file /var/log/hass/home-assistant.log \
+  --log-rotate-days 1 \
+  --runner
+RestartForceExitStatus=100
+
+AmbientCapabilities=
+CapabilityBoundingSet=
+LockPersonality=true
+ProtectControlGroups=true
+ProtectKernelModules=true
+ProtectKernelTunables=true
+
+[Install]
+WantedBy=multi-user.target



More information about the arch-commits mailing list