An action once a day, every day…

Newbie with Node Red, I would like to open a roller shutter every morning from 8:00 a.m. when the light is above 200 lux.
What nodes should be used so that this action only occurs once a day?
Thanks for your advices,

You can use the core inject node.

If you need more configuration than that, try the contributed CRON+ node.

How are you measuring lux, and how do you get the lux value into the node-RED flow.
Does it send the lux value every 'x' minutes, or do you have to request the value?

I have a sensor.luminosite_toiture for lux which send value every ± 6 minutes.

I shouldn't have skipped the 2nd part of your question!

One way to do this is to send the inject 8am prompt to a gate node. You will want to send another inject at some later point in the day to close the gate. Then you would pass your lux measurement through the gate as well. It will only get through if the gate is open.

Presumably, you will also want to track when the lux value falls too low.

In any case, you will probably want to track whether the blinds are open or closed. which you can do by setting a context variable.

BTW, if you don't like contributed nodes (e.g. simple gate), you can do the same thing by storing a context variable that tells your flows whether it is after 8am or not. Then each time you get a lux value, you can test to see if you need to process it.

Oh, and if you are opening/closing based on Lux, you should also take care to leave a gap between the close lux and the open lux otherwise you will eventually hit a situation at the cutover where the blinds are rapidly opening and closing due to small fluctuations in the light level.

1 Like

Thanks, but I only want the roller shutter to open:

  • if time ≥ 08:00
  • if lux ≥ 300 lux
    If lux ≥ 300 at 09:20, the shutter should open at 09:20.
    And that only once a day.

If I put a node inject, the shutter will not open at 08:00 if lux ≤ 300

This should work.

Record the lux value into a flow/global variable.
At 09:20 read the variable.

1 Like

Thanks, but…

May be it's difficult for me to explain you what I want.
I said 09:20 for example, but the sun does not light the house at 300 lux every day at 09:20…

but the sun does not light the house at 300 lux every day at 09:20…

Yes understood, which means you need to keep track of it.

You can do this by using a change node - setting a context variable.

Where does the sensor.luminosite_toiture come from ? Is it home assistant ?

Yes, it's a sensor on the home roof

Try importing this flow:

[{"id":"c976c33f4cc95606","type":"group","z":"4e2fa50c1ec07f23","name":"lux sensor light value","style":{"label":true},"nodes":["febdd4615d21e4c1","52aee46d107eecb6","c5b42f064b7a5c83","293c094dab5da71b"],"x":94,"y":639,"w":432,"h":162},{"id":"febdd4615d21e4c1","type":"inject","z":"4e2fa50c1ec07f23","g":"c976c33f4cc95606","name":"lux sensor = 400","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"400","payloadType":"num","x":220,"y":680,"wires":[["293c094dab5da71b"]]},{"id":"52aee46d107eecb6","type":"inject","z":"4e2fa50c1ec07f23","g":"c976c33f4cc95606","name":"lux sensor = 300","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"300","payloadType":"num","x":220,"y":720,"wires":[["293c094dab5da71b"]]},{"id":"c5b42f064b7a5c83","type":"inject","z":"4e2fa50c1ec07f23","g":"c976c33f4cc95606","name":"lux sensor =  200","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"200","payloadType":"num","x":220,"y":760,"wires":[["293c094dab5da71b"]]},{"id":"293c094dab5da71b","type":"change","z":"4e2fa50c1ec07f23","g":"c976c33f4cc95606","name":"","rules":[{"t":"set","p":"lux","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":720,"wires":[[]]},{"id":"4ed09fa5bc401301","type":"group","z":"4e2fa50c1ec07f23","name":"Above or below 300 ?","style":{"label":true},"nodes":["3998cfef19570052","f04f633d47d26ee4","2ec3836cb22dfe96","e72f6e04e3354a92"],"x":94,"y":839,"w":532,"h":142},{"id":"3998cfef19570052","type":"switch","z":"4e2fa50c1ec07f23","g":"4ed09fa5bc401301","name":"","property":"lux","propertyType":"flow","rules":[{"t":"gt","v":"300","vt":"num"},{"t":"lte","v":"300","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":900,"wires":[["f04f633d47d26ee4"],["e72f6e04e3354a92"]]},{"id":"f04f633d47d26ee4","type":"debug","z":"4e2fa50c1ec07f23","g":"4ed09fa5bc401301","name":">300","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":880,"wires":[]},{"id":"2ec3836cb22dfe96","type":"inject","z":"4e2fa50c1ec07f23","g":"4ed09fa5bc401301","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"lux","payloadType":"flow","x":190,"y":900,"wires":[["3998cfef19570052"]]},{"id":"e72f6e04e3354a92","type":"debug","z":"4e2fa50c1ec07f23","g":"4ed09fa5bc401301","name":"<300","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":940,"wires":[]}]

Press 1 of the 3 inject nodes in the lux sensor group (this would be your home assistant node)

Then press inject node in the other group and watch to which output the message goes.

This is how you can read the lux value, because it was stored in the flow.lux variable, which can be read at any time (as long as it has been set).

In your case you can schedule it at 09:20, read the variable and only let it pass if it is >300.

Thank you for this flow but I did not know Node Red 10 days ago.
Therefore, I do not know enough nodes to understand their configuration and operation.

Just as an aside...
I use the node called BigTimer to turn the external lights on my home ON at dusk and off at 22:00hrs.
This flow also sends a message to my phone informing me lights turned On or Off.

If you enter your Lat/Lng BigTimer can work out when 'dusk' is (as it changes each day).
If think cronplus+ also offers this facility.

Thanks for the help but in my problem the brightness of 300 lux can come on at any time in the morning (obviously after dawn), then go up, then go back down below 300 lux.
This is why the trigger should only be done once in the morning.
Thank you for your help…

Is this correct?

  1. The blinds stay closed until 08:00
  2. After 08:00, they open when the light level is more than 300 lux

What happens if the light level goes back below 300 lux?

I would highly recommend to go through all the short videos on this node-red playlist on youtube (made by the developers of node-red). It will take you ±30 minutes and you will understand a whole lot more about node-red and how it works.

Because the flow suggestion I made are basic node-red flows which you may need to use more often in the future.

Nothing at all, the blind must remain open because the luminosity will necessarily increase to more than 1000 lux during the day.

Many thanks for this link!
I already saw some tutos but I need to learn more…

Let's assume that this is correct.

  1. The blinds stay closed until 08:00
  2. After 08:00, they open when the light level is more than 300 lux

You need to get the light level into Node-red.
Use a change node to save the latest value as flow.lux.
The flow that @bakman2 posted includes this change node.

Use this flow to test if the blinds should be opened

[{"id":"368519f918adf2ea","type":"group","z":"18302aaec057c898","style":{"stroke":"#0722fc","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#0722fc"},"nodes":["951bf3613f46157d","6074ac50043248f7","75fcf7bbeb6742f3","8c4c72f086832acc","cbcd40a2950a275a","af4b227d43d35891","22c6e6e15e59087a"],"x":54,"y":479,"w":912,"h":162},{"id":"951bf3613f46157d","type":"inject","z":"18302aaec057c898","g":"368519f918adf2ea","name":"From 08:00 to 16:00","props":[{"p":"payload"}],"repeat":"","crontab":"*/1 8-15 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"go","payloadType":"str","x":200,"y":560,"wires":[["6074ac50043248f7"]]},{"id":"6074ac50043248f7","type":"switch","z":"18302aaec057c898","g":"368519f918adf2ea","name":"lux > 300 ?","property":"lux","propertyType":"flow","rules":[{"t":"gte","v":"300","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":410,"y":560,"wires":[["8c4c72f086832acc"]]},{"id":"75fcf7bbeb6742f3","type":"link out","z":"18302aaec057c898","g":"368519f918adf2ea","name":"Your own code to open the blind","mode":"link","links":[],"x":810,"y":560,"wires":[],"l":true},{"id":"8c4c72f086832acc","type":"rbe","z":"18302aaec057c898","g":"368519f918adf2ea","name":"Only once","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":580,"y":560,"wires":[["75fcf7bbeb6742f3","22c6e6e15e59087a"]]},{"id":"cbcd40a2950a275a","type":"inject","z":"18302aaec057c898","g":"368519f918adf2ea","name":"Reset filter at 07:59","props":[{"p":"reset","v":"","vt":"str"}],"repeat":"","crontab":"59 07 * * *","once":false,"onceDelay":0.1,"topic":"","x":380,"y":520,"wires":[["8c4c72f086832acc"]]},{"id":"af4b227d43d35891","type":"inject","z":"18302aaec057c898","g":"368519f918adf2ea","name":"Test","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"go","payloadType":"str","x":250,"y":600,"wires":[["6074ac50043248f7"]]},{"id":"22c6e6e15e59087a","type":"debug","z":"18302aaec057c898","g":"368519f918adf2ea","name":"debug 246","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":520,"wires":[]}]

Please give it a try and let us know if you experience any problems.

Thanks a lot. I'll try it to morrow evening now. Not before, sorry.
I'll tell you back if it's ok.
Have a nice evening (for France only) :rofl: