# Lighting logic - analysis of scenarios

Not really specific to Node-RED, but I thought this may be an interesting topic about automation.

Before we wire up our new home, I'm considering where we should place various sensors (PIRs, door sensors, etc). But first I think it would be a good idea to define some scenarios to determine my goals.

Has anyone ever done any formalised analyses of scenarios, for example like the scenarios below? And come up with flows or node contribs to achieve them? Is it good to get really detailed like this, or keep it much more simple?

e.g.

1) Sleep lights out: Turn lights OFF in the bedroom if I forgot to manually turn them off

I fell asleep with the lights on. So I can create a schedule that says "between the hours of 2am and 7am, check if there was movement in the last 15 minutes and turn lights out if not. If there was movement, try again an hour later, etc."

2) Turn lights ON in the bedroom if it's dark and I just walked in, e.g. in the evening

Using a lux sensor, if the room is dark and nobody was in the room within the last x minutes, and if I walk in (i.e. a door sensor triggered, then the ceiling PIR triggered AFTER this within a given timeframe), set the light level.

3) Turn lights OFF in the bedroom when it's already bright during the day

When daytime starts (an hour after sunrise or whatever) check to see if it's bright enough and turn out the lights if they were left on. How can I check for brightness if the lights are already on? Should I check every hour and repeat? Should there be some kind of manual override that stops checking until the next day? Should I only do this if nobody is in the room already (if I'm in the room, I don't want the lights going out even if it's bright when they are out). What about differentiating between "work lights" and ambient light? If I'm at my desk looking at something in detail I don't want the lights suddenly going out even if it's bright.

Am I thinking about this all wrong? Should I just be thinking about ways to have lighting in the rooms where there are people? I want a system that can be mainly driven by light switches, (I still want to be the master of when lights turn on and off!) but helped out by automation, e.g. to save energy.

I could even compile these scenarios into my own page somewhere online, with possible solutions. But I wondered if anyone has done the grunt work in already having thought all of this stuff through?

Thanks

Mat

I would suggest to start simple and then refine when a specific thing starts annoying or you find repeating the same thing. With lights there are a lot of corner cases you might not be able to take into account. And especially other family members might not appreciate if a light goes on/off in the wrong moment.

I have setup a similar logic to a corridor night light - turn light dim orange for 10 minutes if motion is detected, its nighttime, dark and the light isn't already on.

But otherwise the only smartness I've added is that the default color temperature and brightness tthe lights turn on depends on the time of day.

I would agree to start simple and work up.

However, what you've described are "user journeys" and commonly used in enterprise development. It is a good way to capture the main requirements.

Doing that may help you understand some generic patterns that you will then know you need to produce. Taking an action based on both light, movement and time for example. So when you are writing flows, you can keep those in mind.

At the moment, my main smarts are to turn on downstairs hall lights for 5 minutes at night if movement is detected on the landing and to turn on the rear hall light when the light levels get too low.

One day I'll get round to putting in some more PIR's and light sensors and maybe use some finite state machine flows to simplify things. Before then though I need to replace the remaining timing nodes with CRON+ for consistency.

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