Smart flow for controlling covers for sun protection

I have a philips hue outdoor sensor which I use to meassure the amount of lux. When it is above 40.000 lux for 5 minutes then the covers will close.

When the lux value is below 40.000 lux for 25 minutes, the covers will open.

The difficult thing is off course that you don't want to have covers go up and down every minute.

So I was wondering how other people has done this kind of automation when using a hardware sensor.

Hey Martinst,

I am also interested in implementing such sun protection. In my mind this is smart-shading.

Measuring the light outside can be good start for such a project especially if you are targeting optimal indoor lighting/ glazing prevention.

Things get a bit more complicated if on top of this certain indoor thermal comfort is targeted, as well.

There are plenty of scientific papers on the "indoor thermal comfort" topic, where Japan is ahead with this field of research.

In general, outdoor temperature & humidity, indoor temperature & humidity + outdoor UV index also should be into consideration.

It can get even more "fancy" .... if Outdoor "Air quality" / Indoor "Air quality" is also monitored.

This sounds like a fun project. Just recently, I planned to do some sort of blinds control which could react to hail if we're not at home and the storm is hitting.

By definition, your covers should not go up and down every minute because you have these 25 and 5 minute timers, right?

Just did a quick search for nodes but could not find any. Maybe the smart home experts can help?

The trigger node can be used as a simple lockout to prevent extra messages for a period of time.

Hey rko,

You have brought very good point! During storm .... hail and glass don't get along together :slight_smile:
.... a protection over them could save big money.

By the way, this was an issue also with the solar cells, no?

if you are meassuring every minute store the data in an array. If after 5 min the sum is 200000 or greater its above 40000 for 5 min. Same for lower lux measures.

The funny thing is, over here in Switzerland the so-called experts recommend to open the blinds when there is hail. Modern windows seem to withstand hail. The blinds however look funny after a storm :wink:

Yes, I had the same idea of using some sort of numerical integral over time. However, if right after the 5 minutes period there’s no sun anymore, there’s also no need to close the blinds, right? So, the algorithm will be a bit more tricky than just an integral, I think.

Edit: Maybe an integral with weights could work, I am sure this thing has a fancy name.

I'm using at the moment this flow:

[{"id":"3e392f9e.dd512","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"ef095062.ac324","type":"server-state-changed","z":"3e392f9e.dd512","name":">= 40000 lux for 5 min","server":"86ae6045.37d9d","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.hue_outdoor_motion_sensor_1_light_level","entityidfiltertype":"exact","outputinitially":false,"state_type":"num","haltifstate":"40000","halt_if_type":"num","halt_if_compare":"gte","outputs":2,"output_only_on_state_change":true,"for":"5","forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":160,"y":80,"wires":[["a640df68.83719"],[]]},{"id":"c34c9d98.ad42","type":"server-state-changed","z":"3e392f9e.dd512","name":"< 40000 lux for 25 min","server":"86ae6045.37d9d","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.hue_outdoor_motion_sensor_1_light_level","entityidfiltertype":"exact","outputinitially":false,"state_type":"num","haltifstate":"40000","halt_if_type":"num","halt_if_compare":"lt","outputs":2,"output_only_on_state_change":true,"for":"25","forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":160,"y":500,"wires":[["bd3aa6b7.82cf98"],[]]},{"id":"23df8600.d0327a","type":"api-current-state","z":"3e392f9e.dd512","name":"Automations sun protection enabled?","server":"86ae6045.37d9d","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.zon_bescherming_rolluiken","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":250,"y":180,"wires":[["9de7fe17.ef204","d94ece80.25308","1439e480.93dcec"],[]]},{"id":"2235e111.0941ae","type":"api-current-state","z":"3e392f9e.dd512","name":"Automations enabled?","server":"86ae6045.37d9d","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.automatiseringen_enabled","state_type":"habool","state_location":"","override_payload":"none","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":580,"y":80,"wires":[["23df8600.d0327a"],[]]},{"id":"3061ee63.e6b2f2","type":"api-call-service","z":"3e392f9e.dd512","name":"Close cover zijraam","server":"86ae6045.37d9d","version":1,"debugenabled":false,"service_domain":"tahoma","service":"set_cover_position_low_speed","entityId":"cover.06_zijraam","data":"{\"entity_id\":\"cover.06_zijraam\",\"position\":0}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":610,"y":260,"wires":[[]]},{"id":"a640df68.83719","type":"time-range-switch","z":"3e392f9e.dd512","name":"","lat":"51.81828","lon":"4.78229","startTime":"08:00","endTime":"21:00","startOffset":0,"endOffset":0,"x":370,"y":80,"wires":[["2235e111.0941ae"],[]]},{"id":"9de7fe17.ef204","type":"api-current-state","z":"3e392f9e.dd512","name":"Zijraam enabled?","server":"86ae6045.37d9d","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.zon_bescherming_rolluik_zijraam","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":350,"y":260,"wires":[["3061ee63.e6b2f2"],[]]},{"id":"7b567c82.672994","type":"api-call-service","z":"3e392f9e.dd512","name":"Close cover computerkamer","server":"86ae6045.37d9d","version":1,"debugenabled":false,"service_domain":"tahoma","service":"set_cover_position_low_speed","entityId":"cover.04_computer_kamer","data":"{\"entity_id\":\"cover.04_computer_kamer\",\"position\":0}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":640,"y":320,"wires":[[]]},{"id":"d94ece80.25308","type":"api-current-state","z":"3e392f9e.dd512","name":"Computer kamer enabled?","server":"86ae6045.37d9d","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.zon_bescherming_rolluik_computer_kamer","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":360,"y":320,"wires":[["7b567c82.672994"],[]]},{"id":"f2a334a1.850b88","type":"api-call-service","z":"3e392f9e.dd512","name":"Close cover Hal 1e etage","server":"86ae6045.37d9d","version":1,"debugenabled":false,"service_domain":"tahoma","service":"set_cover_position_low_speed","entityId":"cover.05_hal_1e_etage","data":"{\"entity_id\":\"cover.05_hal_1e_etage\",\"position\":0}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":650,"y":380,"wires":[[]]},{"id":"1439e480.93dcec","type":"api-current-state","z":"3e392f9e.dd512","name":"Hal 1e etage enabled?","server":"86ae6045.37d9d","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.zon_bescherming_rolluik_hal_1e_etage","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":340,"y":380,"wires":[["f2a334a1.850b88"],[]]},{"id":"bd3aa6b7.82cf98","type":"time-range-switch","z":"3e392f9e.dd512","name":"","lat":"51.81828","lon":"4.78229","startTime":"08:00","endTime":"21:00","startOffset":0,"endOffset":0,"x":390,"y":500,"wires":[["118e5572.08f7cb"],[]]},{"id":"118e5572.08f7cb","type":"api-current-state","z":"3e392f9e.dd512","name":"Automations enabled?","server":"86ae6045.37d9d","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.automatiseringen_enabled","state_type":"habool","state_location":"","override_payload":"none","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":600,"y":500,"wires":[["cfea96c0.ce2428"],[]]},{"id":"cfea96c0.ce2428","type":"api-current-state","z":"3e392f9e.dd512","name":"Automations sun protection enabled?","server":"86ae6045.37d9d","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.zon_bescherming_rolluiken","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":270,"y":600,"wires":[["31906929.b488a6","cc252dda.cad75","3dcc6759.b445b8"],[]]},{"id":"9f1a338a.6600f","type":"api-call-service","z":"3e392f9e.dd512","name":"Open cover zijraam","server":"86ae6045.37d9d","version":1,"debugenabled":false,"service_domain":"tahoma","service":"set_cover_position_low_speed","entityId":"cover.06_zijraam","data":"{\"entity_id\":\"cover.06_zijraam\",\"position\":100}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":570,"y":660,"wires":[[]]},{"id":"31906929.b488a6","type":"api-current-state","z":"3e392f9e.dd512","name":"Zijraam enabled?","server":"86ae6045.37d9d","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.zon_bescherming_rolluik_zijraam","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":310,"y":660,"wires":[["9f1a338a.6600f"],[]]},{"id":"9b29b120.e6891","type":"api-call-service","z":"3e392f9e.dd512","name":"Open cover  computerkamer","server":"86ae6045.37d9d","version":1,"debugenabled":false,"service_domain":"tahoma","service":"set_cover_position_low_speed","entityId":"cover.04_computer_kamer","data":"{\"entity_id\":\"cover.04_computer_kamer\",\"position\":100}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":600,"y":720,"wires":[[]]},{"id":"cc252dda.cad75","type":"api-current-state","z":"3e392f9e.dd512","name":"Computer kamer enabled?","server":"86ae6045.37d9d","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.zon_bescherming_rolluik_computer_kamer","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":320,"y":720,"wires":[["9b29b120.e6891"],[]]},{"id":"7d87be18.4d2e1","type":"api-call-service","z":"3e392f9e.dd512","name":"Open cover hal 1e etage","server":"86ae6045.37d9d","version":1,"debugenabled":false,"service_domain":"tahoma","service":"set_cover_position_low_speed","entityId":"cover.05_hal_1e_etage","data":"{\"entity_id\":\"cover.05_hal_1e_etage\",\"position\":100}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":610,"y":780,"wires":[[]]},{"id":"3dcc6759.b445b8","type":"api-current-state","z":"3e392f9e.dd512","name":"Hal 1e etage enabled?","server":"86ae6045.37d9d","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.zon_bescherming_rolluik_hal_1e_etage","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":300,"y":780,"wires":[["7d87be18.4d2e1"],[]]},{"id":"86ae6045.37d9d","type":"server","name":"Home Assistant","addon":true}]

There is also another requirement that every X minutes there should be a repeat signal of closing the covers (when still the lux is above the 40.000 lux).

I'm thinking about setting a flow variable "sun_protection" in flow to on and off. Then checking every x minutes if this flow variable is on then also closing the covers.

Here is a example using trigger nodes and rbe nodes
hope it helps

[{"id":"1823f8a4.c4a7c7","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"50000","payloadType":"num","x":140,"y":2160,"wires":[["c32806b4.e9fe3"]]},{"id":"c32806b4.e9fe3","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"open","pt":"msg","to":"payload < 40000","tot":"jsonata"},{"t":"set","p":"delay","pt":"msg","to":"open ? 10000 : 5000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":2180,"wires":[["f4da14b1.776aa"]]},{"id":"6e3fc1f3.d58d68","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"30000","payloadType":"num","x":140,"y":2200,"wires":[["c32806b4.e9fe3"]]},{"id":"f4da14b1.776aa","type":"rbe","z":"c74669a0.6a34f8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"open","x":490,"y":2180,"wires":[["789c355f.9ea78c"]]},{"id":"789c355f.9ea78c","type":"trigger","z":"c74669a0.6a34f8","name":"","op1":"1","op2":"","op1type":"str","op2type":"pay","duration":"250","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":650,"y":2180,"wires":[["3c8a74d9.4388fc"],["3c2b1c2.9012b64"]]},{"id":"3c2b1c2.9012b64","type":"trigger","z":"c74669a0.6a34f8","name":"msg.delay","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"250","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":870,"y":2200,"wires":[["4a630381.0ef224"]]},{"id":"3c8a74d9.4388fc","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":2160,"wires":[["3c2b1c2.9012b64"]]},{"id":"4a630381.0ef224","type":"rbe","z":"c74669a0.6a34f8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"open","x":1030,"y":2200,"wires":[["c7f6a9d9.b34068"]]},{"id":"c7f6a9d9.b34068","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1170,"y":2200,"wires":[]}]

The name must be "Weighted cubic interpolation" :slight_smile: The thing is that those kind algorithms are improving measurement resolution over time, and the challenge martinst is facing is more like tuning the sensitivity of his feed-back control loop (currently 20 min hysteresis). If too sensitive, it will got into stability issues... and will make the developer, crazy with the up&down movements :slight_smile:

:slight_smile: , they should come over to Bulgaria for experimenting .... in Plovdiv(city).... The hail was so intense, beginning of last July, that many building and cars were left without glasses.

1 Like

I'm working on a "Simulation flow" (ugly one) but will take a while because it's a bit busy at work.

I get it now. But trigger and filter nodes can handle this (hysteresis), as @E1cid suggested.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.