From b5eed585caf1264d47bea2af574803b7935b811e Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Fri, 30 Apr 2021 10:46:14 +0200 Subject: [PATCH] support Astral v2 --- custom_components/adaptive_lighting/switch.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 03ad8d93..6fa23bf2 100755 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -529,10 +529,17 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): self._transition = min( data[CONF_TRANSITION], self._interval.total_seconds() // 2 ) + _loc = get_astral_location(self.hass) + if isinstance(_loc, tuple): + # Astral v2.2 + location, _ = _loc + else: + # Astral v1 + location = _loc self._sun_light_settings = SunLightSettings( name=self._name, - astral_location=get_astral_location(self.hass), + astral_location=location, max_brightness=data[CONF_MAX_BRIGHTNESS], max_color_temp=data[CONF_MAX_COLOR_TEMP], min_brightness=data[CONF_MIN_BRIGHTNESS],