Flow for sun protection (covers)

I need some sun protection to control my covers outside. For this I’m using Node-Red and I have a limunance sensor outside.

What it should do:

  • when the lux value >= X for 5 minutes → the covers will close.
  • when the lux value < X for 20 minutes → the covers will open.

This is now done by 2 “state_changed” events (1 for the close action and 1 for the open action) and I’m using the “For … minutes” option.

What this not do is sending a repeat signal every x minute.

Is there another solution to do this with other nodes?

Is it better to have an inject node → exceute it every second → check if the value is above the signal value → start a timer → etc?

Here is how I use lux to turn my lights on and off.

[{"id":"2e95449.2a386bc","type":"api-call-service","z":"24e54e48.fd06f2","name":"hallway on","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.lights_12_2","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":530,"y":460,"wires":[[]]},{"id":"46fd8dfa.cc29bc","type":"api-call-service","z":"24e54e48.fd06f2","name":"hallway off","server":"","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.lights_12_2","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":610,"y":560,"wires":[[]]},{"id":"5664a55a.0490e4","type":"api-current-state","z":"24e54e48.fd06f2","name":"Day/Night","server":"","version":2,"outputs":2,"halt_if":"above_horizon","halt_if_type":"str","halt_if_compare":"is","entity_id":"sun.sun","state_type":"str","blockInputOverrides":false,"outputProperties":[],"x":370,"y":560,"wires":[["46fd8dfa.cc29bc"],[]],"outputLabels":["Day","Night"],"icon":"font-awesome/fa-question"},{"id":"5a6a7a85.ea22ec","type":"server-state-changed","z":"24e54e48.fd06f2","name":"lux < 20 for 10","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.hallway_lux","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"20","halt_if_type":"num","halt_if_compare":"lt","outputs":2,"output_only_on_state_change":true,"for":"10","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":150,"y":460,"wires":[["2e95449.2a386bc"],[]]},{"id":"7f7e59c2.8555b8","type":"server-state-changed","z":"24e54e48.fd06f2","name":"lux > 20 for 10","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.hallway_lux","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"20","halt_if_type":"num","halt_if_compare":"gt","outputs":2,"output_only_on_state_change":true,"for":"10","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":140,"y":560,"wires":[["5664a55a.0490e4"],[]]}]

Yes my flow works exactly the same, so I use also the state_changed node. I control my Somfy covers in the flow when the lux value is above or below 40.000 lux.

But the Somfy integration is unfortunately a cloud service instead of local service. So this is not always working correct.

Another issue is that I have some check on my windows, so that the cover is not going down when my window is open.

Consider the next situation: the lux value is going above the 40.000. Then there is some check if this is the case for 5 minutes. Then my cover is going down. But the somy service is not working or my window is open. So the result is that the cover is still not down.

What I think is that a good option is to have some repeat signal every x minutes. When the lux will not go below the 40.000 lux, but still rising 50.000 → 60.000 → 80.000 etc… Then the signal is not send any more.

What is a good approch to tackle this?

You could set up a trend sensor in home assistant it will tell you if the lux is rising. The current state node can be used after the trigger to check if the window is open.

Okay I will check that type of sensor if it is usable for me.

I am absolutely fascinated by the following node. But I haven’t finished anything perfect myself.