basbruss / adaptive-cover

An Adaptive Cover component for HomeAsisstant to control covers based on the sun's position
MIT License
71 stars 10 forks source link

Distance to shaded area not taking length of horizontal awning into account #258

Closed Appesteijn closed 1 month ago

Appesteijn commented 1 month ago

What version of Adaptive Cover are you using?

1.3.2

What version of Home Assistant are you using?

2024.7.2

Checklist

Describe the issue

I tried to find the code, but my coding is a little bit rusty. I have the feeling that 'distance to shaded area' doesn't take an extending horizontal awning into account. For horizontal shades the distance is constant and stay's the same, but an extending awning should add the current extend (percentage_closed * awning_length) into the calculation.

Reproduction steps

When sun still reaches your 'shaded area', increase the 'distance to shaded area' in the config.

Diagnostics dump

No response

basbruss commented 1 month ago

The distance parameter remains constant in all scenarios because it measures the distance from the window or cover to the specified shaded area, as indicated by the orange line in the diagram. horizontal_cover

The percentage is determined using the maximum awning length. This length is adjusted using geometric calculations to account for different angles relative to a vertical blind. The length of the vertical blind, based on the sun's position, is then converted back to the length of a horizontal cover using these geometric principles.

For more details, you can check the related code here: https://github.com/basbruss/adaptive-cover/blob/07b235edb1210aa89fd8cb3b87ff48e750101d52/custom_components/adaptive_cover/calculation.py#L426-L442

Appesteijn commented 1 month ago

Thank you!

Appesteijn commented 1 month ago

I was too fast. With these settings Screenshot_20240719-173348

I get this: IMG_20240719_172537420

I would expect it to be: IMG_20240719_172858752

What am I doing wrong? :)

basbruss commented 1 month ago

Can you share the diagnostics dump from the integration tab and maybe add some debug logs from the integration? There are just too many parameters that can influence the actual position.

Appesteijn commented 1 month ago

When I change the 'Shaded area' to 2 meters, the extension is correct.

basbruss commented 1 month ago

What are the percentages that HA shows when the awning is fully opened and fully closed? I suspect it's the inverse of the general HA convention that is used for covers, where 100% is fully open/extended and 0% is fully closed/not extended.

Appesteijn commented 1 month ago

100% is open or up, 0% is closed or down.

basbruss commented 1 month ago

Seems indeed the opposite as is assumed within the integration for horizontal covers. You can use the inverse option in the options menu.

Appesteijn commented 1 month ago

Is it also for vertical covers? 100% is open and 0% is closed?

Appesteijn commented 1 month ago

I'll test tomorrow and will close this ticket when it works. Thank you for you fast response and help!

Appesteijn commented 1 month ago

Looks like this was the solution. The percentage should be interpreted as '% closed'. I though it was '% open'