[arch-commits] Commit in home-assistant/repos/community-any (10 files)
Maxime Gauduin
alucryd at archlinux.org
Thu Mar 26 08:47:08 UTC 2020
Date: Thursday, March 26, 2020 @ 08:47:07
Author: alucryd
Revision: 604414
archrelease: copy trunk to community-any
Added:
home-assistant/repos/community-any/PKGBUILD
(from rev 604413, home-assistant/trunk/PKGBUILD)
home-assistant/repos/community-any/home-assistant-astral2.1.patch
(from rev 604413, home-assistant/trunk/home-assistant-astral2.1.patch)
home-assistant/repos/community-any/home-assistant.service
(from rev 604413, home-assistant/trunk/home-assistant.service)
home-assistant/repos/community-any/home-assistant.sysusers
(from rev 604413, home-assistant/trunk/home-assistant.sysusers)
home-assistant/repos/community-any/home-assistant.tmpfiles
(from rev 604413, home-assistant/trunk/home-assistant.tmpfiles)
Deleted:
home-assistant/repos/community-any/PKGBUILD
home-assistant/repos/community-any/home-assistant-astral2.1.patch
home-assistant/repos/community-any/home-assistant.service
home-assistant/repos/community-any/home-assistant.sysusers
home-assistant/repos/community-any/home-assistant.tmpfiles
--------------------------------+
PKGBUILD | 182 ++++++------
home-assistant-astral2.1.patch | 568 +++++++++++++++++++--------------------
home-assistant.service | 28 -
home-assistant.sysusers | 2
home-assistant.tmpfiles | 2
5 files changed, 391 insertions(+), 391 deletions(-)
Deleted: PKGBUILD
===================================================================
--- PKGBUILD 2020-03-26 08:46:59 UTC (rev 604413)
+++ PKGBUILD 2020-03-26 08:47:07 UTC (rev 604414)
@@ -1,91 +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.107.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-importlib-metadata
- python-jinja
- python-pyjwt
- python-pip
- python-pytz
- python-requests
- python-ruamel-yaml
- python-slugify
- python-sqlalchemy
- python-voluptuous
- python-voluptuous-serialize
- python-yaml
-)
-makedepends=(
- git
- python-setuptools
-)
-optdepends=(
- 'net-tools: Nmap host discovery'
- 'openzwave: Z-Wave integration'
- 'python-lxml: Meteo France integration'
-)
-source=(
- git+https://github.com/home-assistant/home-assistant.git#tag=677c276b41f99dbef34fdbaa9bdb14b3685163ef
- home-assistant.service
- home-assistant.sysusers
- home-assistant.tmpfiles
- home-assistant-astral2.1.patch
-)
-sha256sums=('SKIP'
- '2a87a3b529a1eeddfae0c02c415bed13586b002b9580226bdc749a27bbe83af5'
- '319c7790d3cdb076bf527b1d478edbc99e00b22fbf4a884b395e46460114ee41'
- 'f9e43edb276e0fbbbc2273b836ef1da0ac43347b5c3e4c63774e7f7ecdf25660'
- 'd39e2bb003f5a2ea6a2faca003c5068b26b51883e28124f2bef0dfd5536465c4')
-
-pkgver() {
- cd home-assistant
-
- git describe --tags
-}
-
-prepare() {
- cd home-assistant
-
- patch -Np1 -i ../home-assistant-astral2.1.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/
- install -Dm 644 ../home-assistant.sysusers "${pkgdir}"/usr/lib/sysusers.d/home-assistant.conf
- install -Dm 644 ../home-assistant.tmpfiles "${pkgdir}"/usr/lib/tmpfiles.d/home-assistant.conf
-}
-
-# vim: ts=2 sw=2 et:
Copied: home-assistant/repos/community-any/PKGBUILD (from rev 604413, home-assistant/trunk/PKGBUILD)
===================================================================
--- PKGBUILD (rev 0)
+++ PKGBUILD 2020-03-26 08:47:07 UTC (rev 604414)
@@ -0,0 +1,91 @@
+# 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.107.7
+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-importlib-metadata
+ python-jinja
+ python-pyjwt
+ python-pip
+ python-pytz
+ python-requests
+ python-ruamel-yaml
+ python-slugify
+ python-sqlalchemy
+ python-voluptuous
+ python-voluptuous-serialize
+ python-yaml
+)
+makedepends=(
+ git
+ python-setuptools
+)
+optdepends=(
+ 'net-tools: Nmap host discovery'
+ 'openzwave: Z-Wave integration'
+ 'python-lxml: Meteo France integration'
+)
+source=(
+ git+https://github.com/home-assistant/home-assistant.git#tag=07ce284acd85eb0526fe45c9e05d526ed8820ba7
+ home-assistant.service
+ home-assistant.sysusers
+ home-assistant.tmpfiles
+ home-assistant-astral2.1.patch
+)
+sha256sums=('SKIP'
+ '2a87a3b529a1eeddfae0c02c415bed13586b002b9580226bdc749a27bbe83af5'
+ '319c7790d3cdb076bf527b1d478edbc99e00b22fbf4a884b395e46460114ee41'
+ 'f9e43edb276e0fbbbc2273b836ef1da0ac43347b5c3e4c63774e7f7ecdf25660'
+ 'd39e2bb003f5a2ea6a2faca003c5068b26b51883e28124f2bef0dfd5536465c4')
+
+pkgver() {
+ cd home-assistant
+
+ git describe --tags
+}
+
+prepare() {
+ cd home-assistant
+
+ patch -Np1 -i ../home-assistant-astral2.1.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/
+ install -Dm 644 ../home-assistant.sysusers "${pkgdir}"/usr/lib/sysusers.d/home-assistant.conf
+ install -Dm 644 ../home-assistant.tmpfiles "${pkgdir}"/usr/lib/tmpfiles.d/home-assistant.conf
+}
+
+# vim: ts=2 sw=2 et:
Deleted: home-assistant-astral2.1.patch
===================================================================
--- home-assistant-astral2.1.patch 2020-03-26 08:46:59 UTC (rev 604413)
+++ home-assistant-astral2.1.patch 2020-03-26 08:47:07 UTC (rev 604414)
@@ -1,284 +0,0 @@
-From 1cbaf123c0e38581d3df0be0ad1fb6b15ad8622b 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 1/2] bump astral to 2.1
-
----
- homeassistant/components/sun/__init__.py | 19 ++++-----
- homeassistant/helpers/sun.py | 50 +++++++++++++++---------
- homeassistant/package_constraints.txt | 2 +-
- requirements_all.txt | 2 +-
- setup.py | 2 +-
- 5 files changed, 44 insertions(+), 31 deletions(-)
-
-diff --git a/homeassistant/components/sun/__init__.py b/homeassistant/components/sun/__init__.py
-index 9529a9c0cada..f3137ced65f7 100644
---- a/homeassistant/components/sun/__init__.py
-+++ b/homeassistant/components/sun/__init__.py
-@@ -92,6 +92,7 @@ def __init__(self, hass):
- """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,7 +101,7 @@ def __init__(self, hass):
- self._next_change = None
-
- def update_location(event):
-- self.location = get_astral_location(self.hass)
-+ self.location, self.elevation = get_astral_location(self.hass)
- self.update_events(dt_util.utcnow())
-
- update_location(None)
-@@ -137,7 +138,7 @@ def state_attributes(self):
-
- def _check_event(self, utc_point_in_time, event, before):
- next_utc = get_location_astral_event_next(
-- self.location, event, utc_point_in_time
-+ self.location, self.elevation, event, utc_point_in_time
- )
- if next_utc < self._next_change:
- self._next_change = next_utc
-@@ -164,7 +165,7 @@ def update_events(self, utc_point_in_time):
- )
- 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
-@@ -175,9 +176,7 @@ def update_events(self, utc_point_in_time):
- 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
-@@ -185,7 +184,7 @@ def update_events(self, utc_point_in_time):
- # 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:
-@@ -213,9 +212,11 @@ def update_events(self, utc_point_in_time):
- @callback
- def update_sun_position(self, utc_point_in_time):
- """Calculate the position of the sun."""
-- 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 45ff06f16dea..b1063338acd6 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,27 +14,32 @@
-
- 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 Location
-+ from astral import LocationInfo
-+ from astral.location import Location
-
-+ 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
-@@ -46,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
--
- 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:
-@@ -73,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
-
-@@ -92,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
--
-- location = get_astral_location(hass)
-+ location, elevation = get_astral_location(hass)
-
- if date is None:
- date = dt_util.now().date()
-@@ -102,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 ad8abf3e2c44..0c8a57af3c50 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.1
- aiohttp_cors==0.7.0
--astral==1.10.1
-+astral==2.1
- async_timeout==3.0.1
- attrs==19.3.0
- bcrypt==3.1.7
-diff --git a/requirements_all.txt b/requirements_all.txt
-index c24edaf5dc7f..90a16f75aafc 100644
---- a/requirements_all.txt
-+++ b/requirements_all.txt
-@@ -1,6 +1,6 @@
- # Home Assistant core
- aiohttp==3.6.1
--astral==1.10.1
-+astral==2.1
- async_timeout==3.0.1
- attrs==19.3.0
- bcrypt==3.1.7
-diff --git a/setup.py b/setup.py
-index 0564b7f4773e..3059dfffbed5 100755
---- a/setup.py
-+++ b/setup.py
-@@ -33,7 +33,7 @@
-
- REQUIRES = [
- "aiohttp==3.6.1",
-- "astral==1.10.1",
-+ "astral==2.1",
- "async_timeout==3.0.1",
- "attrs==19.3.0",
- "bcrypt==3.1.7",
-
-From 729500eda8da8c9ff5acf950faa21a35a3dc3233 Mon Sep 17 00:00:00 2001
-From: Maxime Gauduin <alucryd at archlinux.org>
-Date: Fri, 28 Feb 2020 09:51:35 +0100
-Subject: [PATCH 2/2] update the moon component
-
----
- homeassistant/components/moon/sensor.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/homeassistant/components/moon/sensor.py b/homeassistant/components/moon/sensor.py
-index 3a7dd9e20844..77aa6be4333d 100644
---- a/homeassistant/components/moon/sensor.py
-+++ b/homeassistant/components/moon/sensor.py
-@@ -1,7 +1,7 @@
- """Support for tracking the moon phases."""
- import logging
-
--from astral import Astral
-+from astral import moon
- import voluptuous as vol
-
- from homeassistant.components.sensor import PLATFORM_SCHEMA
-@@ -86,4 +86,4 @@ def icon(self):
- 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)
Copied: home-assistant/repos/community-any/home-assistant-astral2.1.patch (from rev 604413, home-assistant/trunk/home-assistant-astral2.1.patch)
===================================================================
--- home-assistant-astral2.1.patch (rev 0)
+++ home-assistant-astral2.1.patch 2020-03-26 08:47:07 UTC (rev 604414)
@@ -0,0 +1,284 @@
+From 1cbaf123c0e38581d3df0be0ad1fb6b15ad8622b 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 1/2] bump astral to 2.1
+
+---
+ homeassistant/components/sun/__init__.py | 19 ++++-----
+ homeassistant/helpers/sun.py | 50 +++++++++++++++---------
+ homeassistant/package_constraints.txt | 2 +-
+ requirements_all.txt | 2 +-
+ setup.py | 2 +-
+ 5 files changed, 44 insertions(+), 31 deletions(-)
+
+diff --git a/homeassistant/components/sun/__init__.py b/homeassistant/components/sun/__init__.py
+index 9529a9c0cada..f3137ced65f7 100644
+--- a/homeassistant/components/sun/__init__.py
++++ b/homeassistant/components/sun/__init__.py
+@@ -92,6 +92,7 @@ def __init__(self, hass):
+ """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,7 +101,7 @@ def __init__(self, hass):
+ self._next_change = None
+
+ def update_location(event):
+- self.location = get_astral_location(self.hass)
++ self.location, self.elevation = get_astral_location(self.hass)
+ self.update_events(dt_util.utcnow())
+
+ update_location(None)
+@@ -137,7 +138,7 @@ def state_attributes(self):
+
+ def _check_event(self, utc_point_in_time, event, before):
+ next_utc = get_location_astral_event_next(
+- self.location, event, utc_point_in_time
++ self.location, self.elevation, event, utc_point_in_time
+ )
+ if next_utc < self._next_change:
+ self._next_change = next_utc
+@@ -164,7 +165,7 @@ def update_events(self, utc_point_in_time):
+ )
+ 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
+@@ -175,9 +176,7 @@ def update_events(self, utc_point_in_time):
+ 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
+@@ -185,7 +184,7 @@ def update_events(self, utc_point_in_time):
+ # 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:
+@@ -213,9 +212,11 @@ def update_events(self, utc_point_in_time):
+ @callback
+ def update_sun_position(self, utc_point_in_time):
+ """Calculate the position of the sun."""
+- 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 45ff06f16dea..b1063338acd6 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,27 +14,32 @@
+
+ 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 Location
++ from astral import LocationInfo
++ from astral.location import Location
+
++ 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
+@@ -46,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
+-
+ 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:
+@@ -73,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
+
+@@ -92,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
+-
+- location = get_astral_location(hass)
++ location, elevation = get_astral_location(hass)
+
+ if date is None:
+ date = dt_util.now().date()
+@@ -102,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 ad8abf3e2c44..0c8a57af3c50 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.1
+ aiohttp_cors==0.7.0
+-astral==1.10.1
++astral==2.1
+ async_timeout==3.0.1
+ attrs==19.3.0
+ bcrypt==3.1.7
+diff --git a/requirements_all.txt b/requirements_all.txt
+index c24edaf5dc7f..90a16f75aafc 100644
+--- a/requirements_all.txt
++++ b/requirements_all.txt
+@@ -1,6 +1,6 @@
+ # Home Assistant core
+ aiohttp==3.6.1
+-astral==1.10.1
++astral==2.1
+ async_timeout==3.0.1
+ attrs==19.3.0
+ bcrypt==3.1.7
+diff --git a/setup.py b/setup.py
+index 0564b7f4773e..3059dfffbed5 100755
+--- a/setup.py
++++ b/setup.py
+@@ -33,7 +33,7 @@
+
+ REQUIRES = [
+ "aiohttp==3.6.1",
+- "astral==1.10.1",
++ "astral==2.1",
+ "async_timeout==3.0.1",
+ "attrs==19.3.0",
+ "bcrypt==3.1.7",
+
+From 729500eda8da8c9ff5acf950faa21a35a3dc3233 Mon Sep 17 00:00:00 2001
+From: Maxime Gauduin <alucryd at archlinux.org>
+Date: Fri, 28 Feb 2020 09:51:35 +0100
+Subject: [PATCH 2/2] update the moon component
+
+---
+ homeassistant/components/moon/sensor.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/homeassistant/components/moon/sensor.py b/homeassistant/components/moon/sensor.py
+index 3a7dd9e20844..77aa6be4333d 100644
+--- a/homeassistant/components/moon/sensor.py
++++ b/homeassistant/components/moon/sensor.py
+@@ -1,7 +1,7 @@
+ """Support for tracking the moon phases."""
+ import logging
+
+-from astral import Astral
++from astral import moon
+ import voluptuous as vol
+
+ from homeassistant.components.sensor import PLATFORM_SCHEMA
+@@ -86,4 +86,4 @@ def icon(self):
+ 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)
Deleted: home-assistant.service
===================================================================
--- home-assistant.service 2020-03-26 08:46:59 UTC (rev 604413)
+++ home-assistant.service 2020-03-26 08:47:07 UTC (rev 604414)
@@ -1,14 +0,0 @@
-[Unit]
-Description=Home assistant
-After=network.target
-
-[Service]
-Restart=on-failure
-User=hass
-Group=hass
-
-ExecStart=/usr/bin/hass --config /var/lib/hass/ --log-rotate-days 1
-RestartForceExitStatus=100
-
-[Install]
-WantedBy=multi-user.target
Copied: home-assistant/repos/community-any/home-assistant.service (from rev 604413, home-assistant/trunk/home-assistant.service)
===================================================================
--- home-assistant.service (rev 0)
+++ home-assistant.service 2020-03-26 08:47:07 UTC (rev 604414)
@@ -0,0 +1,14 @@
+[Unit]
+Description=Home assistant
+After=network.target
+
+[Service]
+Restart=on-failure
+User=hass
+Group=hass
+
+ExecStart=/usr/bin/hass --config /var/lib/hass/ --log-rotate-days 1
+RestartForceExitStatus=100
+
+[Install]
+WantedBy=multi-user.target
Deleted: home-assistant.sysusers
===================================================================
--- home-assistant.sysusers 2020-03-26 08:46:59 UTC (rev 604413)
+++ home-assistant.sysusers 2020-03-26 08:47:07 UTC (rev 604414)
@@ -1 +0,0 @@
-u hass - "Home Assistant daemon user" /var/lib/hass
Copied: home-assistant/repos/community-any/home-assistant.sysusers (from rev 604413, home-assistant/trunk/home-assistant.sysusers)
===================================================================
--- home-assistant.sysusers (rev 0)
+++ home-assistant.sysusers 2020-03-26 08:47:07 UTC (rev 604414)
@@ -0,0 +1 @@
+u hass - "Home Assistant daemon user" /var/lib/hass
Deleted: home-assistant.tmpfiles
===================================================================
--- home-assistant.tmpfiles 2020-03-26 08:46:59 UTC (rev 604413)
+++ home-assistant.tmpfiles 2020-03-26 08:47:07 UTC (rev 604414)
@@ -1 +0,0 @@
-d /var/lib/hass 0750 hass hass -
Copied: home-assistant/repos/community-any/home-assistant.tmpfiles (from rev 604413, home-assistant/trunk/home-assistant.tmpfiles)
===================================================================
--- home-assistant.tmpfiles (rev 0)
+++ home-assistant.tmpfiles 2020-03-26 08:47:07 UTC (rev 604414)
@@ -0,0 +1 @@
+d /var/lib/hass 0750 hass hass -
More information about the arch-commits
mailing list