Skip to content

Commit

Permalink
Update calculation.py
Browse files Browse the repository at this point in the history
  • Loading branch information
basbruss committed Nov 2, 2023
1 parent aa09cd4 commit 87cf097
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions custom_components/adaptive_cover/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@ def solar_times(self):
"""Determine start/end times"""
df_today = pd.DataFrame({"azimuth":self.sun_data.solar_azimuth, "elevation":self.sun_data.solar_elevation})
solpos = df_today.set_index(self.sun_data.times)
frame = (solpos["azimuth"] > self.azi_min_abs) & (solpos["azimuth"] < self.azi_max_abs) & (solpos["elevation"] > 0)
return solpos[frame].index[0].to_pydatetime(), solpos[frame].index[-1].to_pydatetime()

alpha = solpos["azimuth"]
frame = ((alpha - self.azi_min_abs) % 360 <= (self.azi_max_abs - self.azi_min_abs) % 360) & (solpos["elevation"] > 0)

if solpos[frame].empty:
return None, None
else:
return solpos[frame].index[0].to_pydatetime(), solpos[frame].index[-1].to_pydatetime()

def value(self, value: any):
"""Return input value"""
Expand Down

0 comments on commit 87cf097

Please sign in to comment.