Bas from DD discord pointed me to a mistake. I thought setting the cover to 100% would fully close it but 100% is actually fully open. Oops. The templates are updated and it should work now.
Edit: I fixed another mistake. Inline comments weren’t processed properly by HA so the template didn’t work. It should finally work now…
To create easily multiple automations for all sides of your home I have build a Blueprint.
The Blueprint uses the sensor you have made based on the template code by @langestefan.
You can configure a time-out, minimum percentage change before adjusting the cover and add multiple actions and conditions to it.
I started to implement and, even if it works, I am trying to fine tune my templates.
I have some few questions for you:
I am not sure I understand h_max and h_min. Are those heights mesured from the ground?
For example
If I have a sliding window (which is 2.1m high) on my ground floor,
h_min=0
h_max=2.1
If I have a regular window (which would be 1.4m high) at the first floor, then
h_min= 3.5 (the first floor is roughly 2.5m high then the window sits 1m above that)
h_max=3.5+1.4=4.9 ?
Or maybe the height is measured from the sea level?
I have those kinds of blinds:
When I set the position to 0, they are completely closed and let no light in. Usually, ona very sunny day, I set the position to 15% because then, I will still see a bit of light through the small holes of the blind which is much more comfortable (This blocks the direct sun light but let a bit of light in)
My question is, how can I set the minimum position to 15% instead of 0%?
Thanks for the reply. Very helpful.
Sorry to be fussy but with that definition of h_min and h_max it means that the 2 same windows with the same azimuth, 1 being at the ground floor and the orther one being at the first or even 2nd floor will have the same result?
I might be wrong but I was expecing them to have a different result
I don’t have any blinds to use this for but I’m interested in seeing the numbers. I’m struggling with the window azimuth part though. I don’t understand what part of the compass needs to be where
You want to measure the azimuth angle of your window in degrees, clockwise, from north (0°). For example if your window faces exactly south it’s at an azimuth angle of 180°. If it faces exactly east it’s at an angle of 90°, if it faces exactly west 270° etc. So basically align the compass such that it points in exactly the same direction as your window is facing.
I think this is awesome project
Do you think it will be possible to add this to blueprint? Not sure if it is possible in full scale, but partially at least?
I Like this Project, more flexible and looks very good.
After testing something goes wrong on my part und i do not understand the reason. My Sensor looks like:
- sensor:
name: Solar blinds height percentage Osten
unique_id: blinds_height_perc_east
unit_of_measurement: '%'
state: >
{% set deg2rad = pi/180 %}
{%- macro norm(x, min, max) %}
{{ (x - min) / (max - min) }}
{%- endmacro %}
{# convert blind height h to percentage [0,100] #}
{%- macro h2perc(x) %}
{{ 100 * float(norm(x, h_min, h_max)) }}
{%- endmacro %}
{%- macro clipv(x, x_min, x_max) %}
{{ max(min(x, x_max), x_min) }}
{%- endmacro %}
{% set win_azi = 108.25 %}
{% set d = 0.5 %}
{% set h_max = 2.15 %}
{% set h_min = 0 %}
{# field of view you want to enable control #}
{# !!! MUST be equal or lower than 90 degrees !!! #}
{# > 90 degrees is behind the window and then calculation is invalid! #}
{% set fov = deg2rad * 60 %}
{# get sun elevation / azimuth from sun.sun #}
{% set sun_azi = state_attr('sun.sun', 'azimuth') %}
{% set sun_ele = state_attr('sun.sun', 'elevation') %}
{% set def_h = 0.6 * h_max %}
{% set alpha = deg2rad * sun_ele %}
{% set gamma = deg2rad * (win_azi - sun_azi) %}
{% set h = (d / cos(gamma)) * tan(alpha) %}
{% if (alpha > 0) and (gamma | abs < fov) %}
{{ clipv(h2perc(h) | round(0) | int , 50, 100) }}
{% else %}
{{ clipv(h2perc(def_h) | round(0) | int , 50, 100) }}
{% endif %}
The calculation itself works but in time where the blinds have to be set to 100% it jumps to 60%
Did you set the azimuth angle correctly? It jumps to 60% (the standard value def_h = 0.6 * h_max) when either the sun moves behind the window or the sun moves below the horizon. Since it happened