How bout:
-
Big Timer for the kickoff, lets say on message is "kickoff"
has the advantage: you can (if you want to go advanced) f.e. set latitude and longitude inside the BigTimer, and then define to always start f.e. always dawn with an offset of -60, which is 60 minutes before dawn in your region.
-
then set a first function node. Something like (just written it before sleep so not tested, may need a bit tweeking):
if (msg.payload == "kickoff")
{
flow.set('lampOn', 0); // reset marker
msg.payload = 0;
return message;
}
which is the start for a second function node you have to add. There, just loop until a specific value, and also check for a flow variable you can change when your lamp is on. Lets say every ten minutes for three hours, is 18 runs (?) max:
var lampOn = flow.get('lampOn') || 0; // look for variable "lampOn", return 0 if not exist
if ((msg.payload < 18) && (lampOn == 0)) // loop has not reacht 18 runs and lamp is not set on so far
{
msg.payload = msg.payload +1;
return msg;
}
and the output of the node is just connected to your lux-stuff and also to a delay-node, which just delays for 10 minutes. And the delay-node output is again connected to the input of the second node. So the second node kicks itself every ten minutes until the 18 is reached.
For the Lux-stuff, just add a function node. Connect its input to where is an output when your lamp is set on, just a one-liner:
flow.set('lampOn', 1); // sets your flow-variable to 1, so the loop will not continue.
An improvement then could be to add a time off message to the BigTimer, lets say "loopOff", and then add to the first function node:
if (msg.payload == "loopOff"){
flow.set('lampOn', 1);
}
which also results in a stop of your loop. Could be helpful if the loop starts before dawn (which varies every day), but should stop always at a certain time.
Again: this is not tested, just written down before sleep. Maybe you need some minor improvements.
Regards
( // means it is commented out in function nodes if you don´t know. Its just to understand the code)