Open/Close Sun screen with light thresholds

#1

I have light sensor which returns a lux value every 5 minutes.
My flow checks for some weather variables (rain/wind) and light.

If rain and/or too much wind, open screen.
If rain/wind ok and lux>2750, close screen.

If it is closed and lux<2750, I don't want to open it immediately, but want to wait 2 measurement cycles and preferably use some lower thresholds (eg. 2400) before opening upon the 3rd measurement.

Has anyone some ideas how to accomplish this ?

Currently if there are some clouds the screen opens, 5 minutes later it closes again I want to avoid this and make it more robust.

0 Likes

#2

First you need to clarify the spec. Write down in a methodical way exactly what you want to achieve. So if this then that, otherwise if this then that etc. Avoid woolly language like 'I don't want it to open immediately'. Write down exactly what is has to do.

Once you have that then it is just a matter of implementing it, but at least you will know exactly what you are trying to implement.

0 Likes

#3

That's what I wrote.

but want to wait 2 measurement cycles and preferably use some lower thresholds (eg. 2400) before opening upon the 3rd measurement.

These 'cycles' are my problem and I don't know how to solve. (well i do but not in an elegant way)

0 Likes

#4

Not good enough. You need a sequential set of instructions that you could follow without needing to do any thinking, just following the instructions. I still don't see that.
Step 1. If something then do this.
Step 2 otherwise if something else then do this
Step 3 otherwise wait 20 seconds and then do something else.

Write the whole thing operation down like that. If easier then do it as a flowchart.

0 Likes

#5

Not sure what your point is, I have the flow except for the 2 cycles.

0 Likes

#6

Use a context values
1 to trigger at start of change process
1 to count the number of cycles...

0 Likes

#7

The point is that get a computer to so something you have to tell it exactly what to do, unless you can write that down as a sequence of tests and operations then it is difficult to do that. So let me try.
If rain or wind > something then open screen
otherwise, if lux > 2750 close screen
otherwise if closed then wait two measurement cycles - but here we have the first problem. Do you actually want to do nothing but wait at the next cycle or do you want to check rain and wind again? That is the sort of thing I mean about not be clear. Perhaps you mean that if the lux stays below 2750 for three cycles then you want to open it. But then you have thrown in the 2400 threshold. Do you actually mean you want it below 2400 for three cycles or just that it has been below 2750 for three and is now below 2400?
Once you define it fully then I think the best way will be to write it in a function node, where you can keep track of how many in a row have been below 2750 using node context.

0 Likes

#8

That's why i said

but not in an elegant way

I will solve it with context.

0 Likes