Skip to content

Commit

Permalink
Merge pull request #9 from basbruss/dev
Browse files Browse the repository at this point in the history
Fix no start/end time calculated
  • Loading branch information
basbruss authored Nov 2, 2023
2 parents e8e6402 + 87cf097 commit e13e714
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Restart Home-Assistant and add the integration.

## Setup

Adaptive Cover supports (for now) two types of covers/blinds; Vertical and Horizontal.
Adaptive Cover supports (for now) three types of covers/blinds; Vertical and Horizontal and Venetian (Tilted) blinds.
Each type has its own specific parameters to setup a sensor. To setup the sensor you first need to find out the azimuth of the window(s). This can be done by finding your location on [Open Street Map Compass](https://osmcompass.com/).

### Simulation
Expand Down
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 e13e714

Please sign in to comment.