Sensor to identify sun's entry into window - blind trigger

so something is not working for me. The formula turns negative when the sun’s azimuth is roughly ten degrees further than the azimuth of the wall.

Template:
  - sensor:
    - name: AngleSunLeftBlind
      state_class: measurement
      icon: mdi:blind
      state: >
        {{(state_attr('sun.sun','elevation') - atan(1330/(200/(sin( pi/180 * (state_attr('sun.sun','azimuth') - 141))))) * 180/pi) | round(1)}}

As you can see in the formula, the wall’s azimuth is 141. But the formula turns positive when the sun’s azimuth is 151 roughly, which is obviously wrong.

Do you see a typo in my formula somewhere? I checked it many times, but I can’t find an error.

ah, I think it’s like the sun rise, this is not accounted for in the formula, so I need an additional trigger/condition:

Closing blind:

  • triggers:
    • Sun Elevation above minimum elevation (buildings on the other side of the street)
    • Angle above 0 (using the formula)
    • Sun Azimuth below the max at which sun can enter the window (independently from elevation)
  • Conditions: same as triggers, to ensure only a combination of all three will trigger.

Opening blind:

  • triggers:
    • Angle below 0 (using the formula)
    • Sun Azimuth above the max at which sun can enter the window (independently from elevation)

That should work for any window then.

Great job! and definitively a good source of inspiration!

I however took a slightly different approach for the same issue.
I’ve decided to calculate the shadow length vs the overhang to determine if the light was entering or not the house/window.
Here was my line of thought:

Shadow length is only a function of Sun elevation and height of a pole / overhang

Shadow_length = Overhang_height_to_base / tan( Sun_elevation)

Shadow direction is then based on the Sun Azimuth angle. And from that we can calculate the individual components based on simple trigonometry.
In my case, I am only interesting in understanding if shadow will penetrate beyond the overhang length, for that we can simply say:

Cos(Window_Azimuth - Sun_Azimuth) = Overhang_shadow_component / Shadow_Length

So, to know if we have a shadow is penetrating our window we simply need:

Shadow_penetration = Overhang_length - Cos(Window_Azimuth - Sun_Azimuth) * Overhang_height_to_base / tan( Sun_elevation)

Take care that the formula only works correctly when the sun is over the horizon

So I can build a sensor that drops to negative when sun is entering the window.

So far it seems to be working pretty well and I hope it can help others with the similar issue.

sensor:
 - platform: template
   sensors:
     sun_shadow_lenght_entering:
       friendly_name: "Sun Entering Rooms"
       unit_of_measurement: '°'
       value_template: "{{ (OVERHANG_LENGTH - cos((WINDOW_AZIMUTH-state_attr('sun.sun','azimuth'))*pi/180)*OVERHANG_HEIGHT/tan(state_attr('sun.sun','elevation')*pi/180)) | round(2) }}"
1 Like

Looks good. Without stepping through all parts of the equations, it looks like we are measuring and using different parts of the same triangle.

I think this is about the third time in my life that I have used my high school trig lessons.

My scripts started to fail recently. They are all too late (+2h hours), but I didn’t really change anything. Before it was spot on. Azimuth and elevation seem correct.

Edit: I think I have had the angles wrong and therefore it worked while the sun was at lower angles in the winter and spring. But in summer it won’t. Hope that fixes it.

All the variables come from the Sun sensor and are not time of day based, but rely on latitude/longitude. There is no time variable in my equation. There is a time condition in my automation to stop it triggering at night.

Check that the location in your settings hasn’t changed. The more accurate you are with your location and your wall and eave angles/measurements, the more relevant the sun data will be.

How is it going now? What exactly is the 33 for you? Angle with 0 on North or South?

I have been working for approximately 1 year and it has worked well, the -33 is the north.
Now I am using Node Red and install a node to control the blinds that function very well and is very easy to use.

1 Like

@archi071 Would you mind sharing the NodeRed config?

@Steve61 I’m trying this out, and since I have no overhang i just put that to zero. Would that be correct?

@devilkin
Hello
I am new to Node Red, my code can be improved, because there are things that I still don’t know how to do. The important thing is that it works.
There are a few things that you will have to adapt to your location and orientation of the windows.
I appreciate any idea or improvement of the code that you can think of.

[{"id":"df343becd8bf08d3","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"0ab8381771c9c237","type":"inject","z":"df343becd8bf08d3","name":"","repeat":"600","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":320,"wires":[["b7c349e4c93cd254"]]},{"id":"6f59d44466e7fb39","type":"switch","z":"df343becd8bf08d3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"manual","vt":"str"},{"t":"eq","v":"100","vt":"num"},{"t":"btwn","v":"60","vt":"num","v2":"50","v2t":"num"},{"t":"btwn","v":"49","vt":"num","v2":"40","v2t":"num"},{"t":"btwn","v":"39","vt":"num","v2":"30","v2t":"num"},{"t":"btwn","v":"29","vt":"num","v2":"25","v2t":"num"},{"t":"lt","v":"24","vt":"str"},{"t":"eq","v":"no sun in window","vt":"str"}],"checkall":"true","repair":false,"outputs":8,"x":630,"y":400,"wires":[[],[],["2980f459e08dc76f"],["22c4f3f87508c9e4"],["822bc15595ff153f"],["9cb4bc1f0ff1ac40"],["7bbebe6f0738e942"],["7bbebe6f0738e942"]]},{"id":"2980f459e08dc76f","type":"api-call-service","z":"df343becd8bf08d3","name":"persiana salon 80%","server":"1f23fa40afc14279","version":5,"debugenabled":true,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":[],"entityId":["cover.persiana"],"data":"{\"position\":\"80\"}","dataType":"json","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","x":890,"y":300,"wires":[["6867d11139f6e5fc"]]},{"id":"22c4f3f87508c9e4","type":"api-call-service","z":"df343becd8bf08d3","name":"persiana salon 75%","server":"1f23fa40afc14279","version":5,"debugenabled":true,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":[],"entityId":["cover.persiana"],"data":"{\"position\":75}","dataType":"json","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","x":890,"y":360,"wires":[["1d3bfa03ac4de927"]]},{"id":"822bc15595ff153f","type":"api-call-service","z":"df343becd8bf08d3","name":"persiana salon 70%","server":"1f23fa40afc14279","version":5,"debugenabled":true,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":[],"entityId":["cover.persiana"],"data":"{\"position\":70}","dataType":"json","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","x":890,"y":420,"wires":[["512be81c795cbb30"]]},{"id":"6867d11139f6e5fc","type":"debug","z":"df343becd8bf08d3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1170,"y":300,"wires":[]},{"id":"1d3bfa03ac4de927","type":"debug","z":"df343becd8bf08d3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1170,"y":360,"wires":[]},{"id":"512be81c795cbb30","type":"debug","z":"df343becd8bf08d3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1171,"y":421,"wires":[]},{"id":"b7c349e4c93cd254","type":"blind-control","z":"df343becd8bf08d3","name":"","topic":"","addIdType":"none","addId":"","positionConfig":"","autoTrigger":true,"autoTriggerTime":"1200000","startDelayTime":10000,"contextStore":"","results":[{"p":"","pt":"msgPayload","v":"","vt":"level"}],"blindIncrement":"1","blindOpenPos":"100","blindClosedPos":0,"blindPosReverse":false,"blindPosDefault":"open (max)","blindPosDefaultType":"levelFixed","slatPosDefault":"","slatPosDefaultType":"none","overwriteExpire":"7200000","rules":[{"index":0,"name":"","version":3,"enabled":false,"isValid":true,"conditions":[],"level":{"type":"levelFixed","value":"open (max)","operator":0,"operatorText":"↕ absolute"},"slat":{"type":"none","value":""},"topic":"","resetOverwrite":false,"importance":0,"time":{"type":"pdsTime","value":"goldenHourDuskEnd","operator":1,"operatorText":"↧ from","offsetType":"num","offset":"-45","multiplier":60000,"days":"*","months":"*"},"description":"<div><i class=\"fa fa-clock-o\" aria-hidden=\"true\"></i> ↧ from <var>golden hour dusk end</var> - 00:45</div><div><div class=\"indent-level-text\"> <i class=\"fa fa-angle-down\" aria-hidden=\"true\"></i><span>blind position: </span> ↕ absolute <var>open (max)</var></div></div>"},{"index":1,"name":"","version":3,"enabled":true,"isValid":true,"conditions":[{"valueType":"flow","value":"manual","operator":"true","operatorText":"is true","thresholdType":"num","threshold":0}],"level":{"type":"num","value":"80","operator":0,"operatorText":"↕ absolute"},"slat":{"type":"none","value":""},"topic":"","resetOverwrite":false,"importance":0,"description":"<div><i class=\"fa fa-code-fork\" aria-hidden=\"true\"></i> <var>flow.manual</var> is true</div><div><div class=\"indent-level-text\"> <i class=\"fa fa-angle-down\" aria-hidden=\"true\"></i><span>blind position: </span> ↕ absolute <var>80</var></div></div>"},{"index":2,"name":"","version":3,"enabled":true,"isValid":true,"conditions":[{"valueType":"flow","value":"Domingo","operator":"true","operatorText":"is true","thresholdType":"num","threshold":"0"}],"level":{"type":"num","value":"99","operator":0,"operatorText":"↕ absolute"},"slat":{"type":"none","value":""},"topic":"","resetOverwrite":false,"importance":0,"time":{"type":"entered","value":"13:30","operator":1,"operatorText":"↧ from","offsetType":"none","offset":"1","multiplier":60000,"days":"*","months":"*"},"timeMax":{"type":"pdsTime","value":"goldenHourDuskStart","offsetType":"num","offset":"-45","multiplier":60000},"description":"<div><i class=\"fa fa-code-fork\" aria-hidden=\"true\"></i> <var>flow.Domingo</var> is true</div><div><i class=\"fa fa-clock-o\" aria-hidden=\"true\"></i> ↧ from <var>13:30</var><div class=\"indent-time-text\"><i class=\"fa fa-step-forward\" aria-hidden=\"true\"></i> <span>no later than (max)</span> <var>golden hour dusk start</var> - 00:45</div></div><div><div class=\"indent-level-text\"> <i class=\"fa fa-angle-down\" aria-hidden=\"true\"></i><span>blind position: </span> ↕ absolute <var>99</var></div></div>"}],"sunControlMode":"16","sunFloorLengthType":"num","sunFloorLength":"2300","sunMinDelta":"","blindPosMin":"10%","blindPosMinType":"levelFixed","blindPosMax":"100","blindPosMaxType":"num","blindOpenPosOffset":0,"blindClosedPosOffset":0,"sunSlat":"","sunSlatType":"none","smoothTime":"","sunTopic":"","windowTopType":"num","windowTop":"2680","windowBottomType":"num","windowBottom":"0","windowAzimuthStartType":"numAzimuth","windowAzimuthStart":"220","windowAzimuthEndType":"numAzimuth","windowAzimuthEnd":"290","oversteers":[{"mode":1,"valueType":"msgPayload","value":"","operator":"gte","operatorText":"≥","thresholdType":"num","threshold":"60","onlySunInWindow":true,"blindPos":{"type":"num","value":"100"},"slatPos":{"type":"none","value":""}}],"oversteerTopic":"","x":350,"y":320,"wires":[["6f59d44466e7fb39","7278e6b4a0e83be4"],["21b21195626e365d"]]},{"id":"9cb4bc1f0ff1ac40","type":"api-call-service","z":"df343becd8bf08d3","name":"persiana salon 65%","server":"1f23fa40afc14279","version":5,"debugenabled":true,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":[],"entityId":["cover.persiana"],"data":"{\"position\":65}","dataType":"json","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","x":890,"y":480,"wires":[["ab0adc5904bac825"]]},{"id":"ab0adc5904bac825","type":"debug","z":"df343becd8bf08d3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1171,"y":481,"wires":[]},{"id":"7bbebe6f0738e942","type":"api-call-service","z":"df343becd8bf08d3","name":"persiana salon 100%","server":"1f23fa40afc14279","version":5,"debugenabled":true,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":[],"entityId":["cover.persiana"],"data":"{\"position\":100}","dataType":"json","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","x":900,"y":540,"wires":[["5f5f5cff117468db"]]},{"id":"5f5f5cff117468db","type":"debug","z":"df343becd8bf08d3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1171,"y":541,"wires":[]},{"id":"ec3207f2cdb15f9e","type":"change","z":"df343becd8bf08d3","name":"Domingo","rules":[{"t":"set","p":"Domingo","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":960,"wires":[["b7c349e4c93cd254"]]},{"id":"d226b04e01d93b0d","type":"inject","z":"df343becd8bf08d3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":130,"y":940,"wires":[["ec3207f2cdb15f9e"]]},{"id":"d6675c1d7e283aef","type":"inject","z":"df343becd8bf08d3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":130,"y":980,"wires":[["ec3207f2cdb15f9e"]]},{"id":"7effd58dd8e11139","type":"change","z":"df343becd8bf08d3","name":"manual","rules":[{"t":"set","p":"manual","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":660,"wires":[["b7c349e4c93cd254"]]},{"id":"49adb0b1b1811cfd","type":"inject","z":"df343becd8bf08d3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":130,"y":460,"wires":[["7effd58dd8e11139"]]},{"id":"b904bacb8b8ffa1f","type":"inject","z":"df343becd8bf08d3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":130,"y":520,"wires":[["7effd58dd8e11139"]]},{"id":"1c5c080ba15e0291","type":"server-state-changed","z":"df343becd8bf08d3","name":"Subir","server":"de5bcb2b.ec2a98","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.persiana_channel_2_input","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"true","valueType":"bool"}],"x":130,"y":640,"wires":[["7effd58dd8e11139"],[]]},{"id":"92d89acd3fdeb645","type":"server-state-changed","z":"df343becd8bf08d3","name":"Bajar","server":"de5bcb2b.ec2a98","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.persiana_channel_1_input","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"true","valueType":"bool"}],"x":130,"y":700,"wires":[["7effd58dd8e11139"],[]]},{"id":"4bf006f27707dae5","type":"time-inject","z":"df343becd8bf08d3","name":"reset automatico","nameInt":"⏲ golden hour dusk start↶ = false↷","positionConfig":"03728dba4f3c1960","props":[{"p":"","pt":"msgPayload","v":"false","vt":"bool","o":"1","oT":"num","oM":"60000","f":0,"fS":0,"fT":"UNIX timestamp (ms)","fI":"0","next":true,"days":"*","months":"*","onlyOddDays":false,"onlyEvenDays":false,"onlyOddWeeks":false,"onlyEvenWeeks":false},{"p":"","pt":"msgTopic","v":"","vt":"str","o":"1","oT":"none","oM":"60000","f":0,"fS":0,"fT":"UNIX timestamp (ms)","fI":"0","next":false,"days":"*","months":"*","onlyOddDays":false,"onlyEvenDays":false,"onlyOddWeeks":false,"onlyEvenWeeks":false}],"injectTypeSelect":"time","intervalCount":1,"intervalCountType":"num","intervalCountMultiplier":60000,"time":"goldenHourDuskStart","timeType":"pdsTime","offset":"-45","offsetType":"num","offsetMultiplier":60000,"timeEnd":"","timeEndType":"entered","timeEndOffset":0,"timeEndOffsetType":"num","timeEndOffsetMultiplier":60000,"timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeOnlyOddWeeks":false,"timeOnlyEvenWeeks":false,"timeMonths":"*","timedatestart":"","timedateend":"","property":"","propertyType":"none","propertyCompare":"true","propertyThreshold":"","propertyThresholdType":"num","timeAlt":"","timeAltType":"entered","timeAltDays":"*","timeAltOnlyOddDays":false,"timeAltOnlyEvenDays":false,"timeAltOnlyOddWeeks":false,"timeAltOnlyEvenWeeks":false,"timeAltMonths":"*","timeAltOffset":0,"timeAltOffsetType":"num","timeAltOffsetMultiplier":60000,"once":false,"onceDelay":"","recalcTime":"","x":160,"y":880,"wires":[["7effd58dd8e11139","ec3207f2cdb15f9e"]]},{"id":"413ce83427017ccd","type":"server-state-changed","z":"df343becd8bf08d3","name":"Alexa","server":"de5bcb2b.ec2a98","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"cover.persiana","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"open","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"true","valueType":"bool"}],"x":130,"y":580,"wires":[[],[]]},{"id":"c5abd1ad03fbc856","type":"inject","z":"df343becd8bf08d3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"num","x":130,"y":1160,"wires":[["6fd85e48952e1386"]]},{"id":"0f6d9ecc5819f99f","type":"inject","z":"df343becd8bf08d3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":130,"y":1200,"wires":[["6fd85e48952e1386"]]},{"id":"b4a5976fcb8cb10e","type":"inject","z":"df343becd8bf08d3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"80","payloadType":"num","x":130,"y":1120,"wires":[["6fd85e48952e1386"]]},{"id":"6fd85e48952e1386","type":"change","z":"df343becd8bf08d3","name":"nublado","rules":[{"t":"set","p":"nublado","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":1160,"wires":[["b7c349e4c93cd254"]]},{"id":"d68a4ca0ae7e93da","type":"comment","z":"df343becd8bf08d3","name":"pulsadores","info":"al mover la persiana en manual,respeta esta posicion anulando el posicionamiento automatico","x":140,"y":120,"wires":[]},{"id":"fbe1c75ad8bfb424","type":"comment","z":"df343becd8bf08d3","name":"Configurar","info":"hay que meter la ubicacion y hora a la que reseteamos la posicion de manual","x":140,"y":820,"wires":[]},{"id":"5fd29d709f194159","type":"comment","z":"df343becd8bf08d3","name":"manual","info":"forzar manual y anular\nal mover la persiana en manual,respeta esta posicion anulando el posicionamiento automatico.","x":130,"y":400,"wires":[]},{"id":"42b49ebbfd89f52e","type":"comment","z":"df343becd8bf08d3","name":"Configurar","info":"En este nodo hay que configurar lo siguiente:\nla ubicacion.\nel escalado de la persiana, esta de 0 a 100.\nla posicion de apertura y cierre maxima. de 0 a 100.\nel azimut comienzo y final(el angulo de accionamiento), esta de 220 a 290.\ncota de la ventana esta de 0 a 2680 mm.\nla funcion, esta en restrigir sol\nlongitud del sueloo de donde llega el sol esta a 3000mm.\nlas reglas.\nRegla 1, abre la persiana al 100% 45 minutos  antes de ponerse el sol.Hay que revisar esta regla,las anulaciones manual y Domingo si estan activas no funciona. para que funcione anulo manual y Domingo automaticamente.\nRegla 2 manual,se activa si muevo la persiana con los pulsadores.falta activarla si la persiana la mueve Alexa.\nRegla 3 Domingo,la persiana se pone al 20% a las 13:00.se abre con la regla 1\n","x":360,"y":260,"wires":[]},{"id":"594d23585cd6f897","type":"comment","z":"df343becd8bf08d3","name":"Funcionamiento","info":"La idea de este flow es que la persiana limite la entrada de sol en el interior de la vivienda,permitiendo entrar el maximo de luz.\nen este caso la puerta mira al Oeste y a la puesta de el sol comenzara a bajar conforme va entrando el sol.\nSi se activa la posicion manual la persiana debe quedarse en esta posicion hasta que llegue la puesta de sol en la que subira al 100%.\nLos Domingos a partir de las 13:00 se bajara al 20%, abriendose al 100% al ponerse el sol.","x":620,"y":100,"wires":[]},{"id":"8a304b45fa61ed7e","type":"comment","z":"df343becd8bf08d3","name":"","info":"lee la salida de blind-control y lo traduce a la posicion deseada  real.","x":640,"y":300,"wires":[]},{"id":"40c7140c844bdc72","type":"comment","z":"df343becd8bf08d3","name":"Configurar","info":"llamada a la posicion deseada en la persiana.\nhay que configurar a que entidad llama.","x":880,"y":240,"wires":[]},{"id":"fdf6d65ceb732743","type":"time-inject","z":"df343becd8bf08d3","name":"","nameInt":"⏲ 00:00[Sun] = true","positionConfig":"03728dba4f3c1960","props":[{"p":"","pt":"msgPayload","v":"true","vt":"bool","o":"","oT":"none","oM":"60000","f":0,"fS":0,"fT":"UNIX timestamp (ms)","fI":"0","next":true,"days":"*","months":"*","onlyOddDays":false,"onlyEvenDays":false,"onlyOddWeeks":false,"onlyEvenWeeks":false},{"p":"","pt":"msgTopic","v":"","vt":"str","o":"","oT":"none","oM":"60000","f":0,"fS":0,"fT":"UNIX timestamp (ms)","fI":"0","next":false,"days":"*","months":"*","onlyOddDays":false,"onlyEvenDays":false,"onlyOddWeeks":false,"onlyEvenWeeks":false}],"injectTypeSelect":"time","intervalCount":1,"intervalCountType":"num","intervalCountMultiplier":60000,"time":"00:00","timeType":"entered","offset":0,"offsetType":"none","offsetMultiplier":60000,"timeEnd":"","timeEndType":"entered","timeEndOffset":0,"timeEndOffsetType":"none","timeEndOffsetMultiplier":60000,"timeDays":"0","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeOnlyOddWeeks":false,"timeOnlyEvenWeeks":false,"timeMonths":"*","timedatestart":"","timedateend":"","property":"","propertyType":"none","propertyCompare":"true","propertyThreshold":"","propertyThresholdType":"num","timeAlt":"","timeAltType":"entered","timeAltDays":"*","timeAltOnlyOddDays":false,"timeAltOnlyEvenDays":false,"timeAltOnlyOddWeeks":false,"timeAltOnlyEvenWeeks":false,"timeAltMonths":"*","timeAltOffset":0,"timeAltOffsetType":"none","timeAltOffsetMultiplier":60000,"once":false,"onceDelay":0.1,"recalcTime":2,"x":180,"y":1020,"wires":[["ec3207f2cdb15f9e"]]},{"id":"9c91adae03f608b3","type":"ui_gauge","z":"df343becd8bf08d3","name":"","group":"eea22782cab42204","order":4,"width":0,"height":0,"gtype":"gage","title":"Posicion persiana","label":"º","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":610,"y":1280,"wires":[]},{"id":"80188b387ef503e1","type":"change","z":"df343becd8bf08d3","name":"posicion persiana","rules":[{"t":"set","p":"payload","pt":"msg","to":"data.new_state.attributes.current_position","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":1300,"wires":[["9c91adae03f608b3","62f32911fcee3782"]]},{"id":"d139733a52eefdec","type":"server-state-changed","z":"df343becd8bf08d3","name":"posicion persiana","server":"1f23fa40afc14279","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"cover.persiana","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"0","halt_if_type":"num","halt_if_compare":"gte","outputs":2,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"global.get(\"Variable_name_here\")","valueType":"jsonata"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":140,"y":1300,"wires":[[],["80188b387ef503e1"]]},{"id":"62f32911fcee3782","type":"ui_chart","z":"df343becd8bf08d3","name":"Posicion persiana","group":"eea22782cab42204","order":1,"width":0,"height":0,"label":"Posicion persiana","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":610,"y":1320,"wires":[[]]},{"id":"21b21195626e365d","type":"change","z":"df343becd8bf08d3","name":"no soleado","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.reason.state","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":420,"wires":[["6f59d44466e7fb39"]]},{"id":"7278e6b4a0e83be4","type":"link out","z":"df343becd8bf08d3","name":"trigger_refreshBlind_state","mode":"link","links":["9ae3d36765b4288e"],"x":525,"y":320,"wires":[]},{"id":"c9552520c1183bde","type":"ui_chart","z":"df343becd8bf08d3","name":"posicion sol","group":"367c2b3cd2877157","order":1,"width":0,"height":0,"label":"posicion sol","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":890,"y":1320,"wires":[[]]},{"id":"1da2d7517b4d76d7","type":"ui_gauge","z":"df343becd8bf08d3","name":"posicion sol","group":"367c2b3cd2877157","order":4,"width":0,"height":0,"gtype":"gage","title":"posicion sol","label":"º","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":890,"y":1280,"wires":[]},{"id":"9ae3d36765b4288e","type":"link in","z":"df343becd8bf08d3","name":"do_refreshBlind_state","links":["7278e6b4a0e83be4"],"x":755,"y":1300,"wires":[["1da2d7517b4d76d7","c9552520c1183bde"]]},{"id":"1f23fa40afc14279","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30"},{"id":"de5bcb2b.ec2a98","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30"},{"id":"03728dba4f3c1960","type":"position-config","name":"","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":99,"timeZoneDST":0,"stateTimeFormat":"3","stateDateFormat":"12","contextStore":""},{"id":"eea22782cab42204","type":"ui_group","name":"Posicion persiana","tab":"b885bf5f.d5f31","order":1,"disp":true,"width":"7","collapse":false,"className":""},{"id":"367c2b3cd2877157","type":"ui_group","name":"Posicion sol","tab":"b885bf5f.d5f31","order":2,"disp":true,"width":"7","collapse":false,"className":""},{"id":"b885bf5f.d5f31","type":"ui_tab","name":"Automatizacion persiana","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
1 Like

I need to double check my logic, but if you have no overhang, I don’t think you need this equation and can just use azimuth.

With a zero overhang, the sun should enter (or leave) a window at the same azimuth each day, irrespective of its elevation. That azimuth is likely to be (or very close to) the alignment of your windows off true north.

For example in my case, my house (Southern Hemisphere) is 8-degrees to the east of true north, so with zero overhang, I would expect the sun to start entering western windows at an azimuth below 8. (Of course once it gets to zero, that is 360-degrees, so that needs to figure in automations.)

Where do you put these to measure how much light is actually entering the room? Outside or inside?

I got one for each side of the house too, but not yet sure where to place them. And then I have only manual blinds, so will probably need some kind of sensor to know if they are open or not too…

I like the maths of this thread though and a combination of a light sensor, azimuth and elevation could perhaps make it even better.

Inside. I tried to put them in spots that were relevant to where we are in the room (like in the office by the desk), not too dark but also not getting hit with direct sunlight through the window in the morning or evening. Generally that meant close to where we hang out in the room but kind of high on the wall to avoid the evening sunspots.

Its not a perfect system but works pretty well. And we can always override a tell Google to turn on the lights if necessary.

One thing to keep an eye on - lights turning on increases the light level in the room. This seems obvious but it’s problematic when the ambient light level is very close to your threshold for turning on the lights. If you’re not careful it can cause it to bounce above and below the threshold, toggling the lights each time. To counter this I use a template sensor instead of a threshold sensor and have a slightly higher threshold when the lights in the room are on. That plus running the actual value through statistics sensors to iron out the spikes works pretty well.

EDIT: oh and when experimenting with where to put these sensors, get some painters tape. I stupidly assumed I had the right spot with one or two and just used the sticky ring that comes with it. That thing is very sticky, ripped a circle of paint right off the wall when I moved it 🤦

1 Like

Excellent. Thanks! I’ll play around with lux values and positions.

Yeah, I have a few remotes and sensors I don’t want to put up until I’m 100% sure. Not only could it destroy the wallpaper, but there’s usually only one sticky ring.

1 Like

As an aside here - as well as using the trig, I also use my solar PV panels as a defacto light sensor. If the panels on the roof above the window are producing less than a specified amount of power, I have it set so the blinds don’t close, because the low power = overcast.

It’s a bit blunt but works for me.