On light on, select brightness based on time of day

Hi guys

I just installed node-red and I have exactly one production automation working in it right now. (Well, two, I have a test-light-on whatever-ya-callits groups of bubbles).

I want to essentially do a case statement - on light on event, check the time and set brightness as appropriate (~8pm, 10pm, midnight - 6am).

If anyone has the urge would you mind giving me an idea of how I would do this?
(so much easier to get into this stuff when you have a bit working)

thanks

You can get the hour of the day nodered way by using the moment node if you pass the timestamp as input. but you can also use function node and use use new Date()

so in code woould be

var d = new Date()
hour = d.toLocaleTimeString(undefined, {  hour: 'numeric' })

From there you can work your case statement

1 Like

Instead of using the time of day, you could as well use the sun position :slight_smile:

1 Like

I have zero coding skills which is why I love Node-Red.

There is probably a better way but this is the way I would do it.

1 Like

Yes, with the time_node this is one of the simpliest solutions.

Within the sun_position module you can specify the different light_levels and assign the out-node accordingly

This would make your flow even simpler and would adjust for summer/winter season as it considers the actual sun_position.

1 Like