Good Morning, Afternoon, and Evening

Instead of using “MORNING”, use “Good Morning” for the state.

Alternatively you can use the sun angle channel from Astro and set the phrase based on ho high up the sun is instead of wall clock time.

The key using time will be along the lines of:

var time = "Good Night"
if(now.isAfter(now.plusDays(1).minusHours(24-6)) time = "Good Morning"
if(now.isAfter(now.plusDays(1).minusHours(24-11)) time = "Good Afternoon"
if(now.isAfter(now.plusDays(1).minusHours(24-18)) time = "Good Evening"

Why the plusDays minusHours 24-x? To handle daylight savings.

Then just trigger the rule to run at system started and at those times and you are good to go.

It’s just a simplified version of the ToD DP.

1 Like