String empty in Sitemap

I’m trying to display the value of a string in a sitemap, using the TimeOfDay design pattern posting the forum, but it comes up empty:
item:

String        TimeOfDay (gSettings)

rules:

rule "Get time period for right now"
    when
        System started or
        Item SwTest changed to ON
    then
//        val morning = now.withTimeAtStartOfDay.plusHours(6).millis
        val dawn = new DateTime((Dawn_Time.state as DateTimeType).calendar.timeInMillis)
        val sunrise = new DateTime((Sunrise_Time.state as DateTimeType).calendar.timeInMillis)
        val twilight = new DateTime((Twilight_Time.state as DateTimeType).calendar.timeInMillis)
        val evening = new DateTime((Sunset_Time.state as DateTimeType).calendar.timeInMillis)
        val night = now.withTimeAtStartOfDay.plusHours(23).millis

        if(now.isAfter(dawn) && now.isBefore(sunrise))       updateTimeOfDay.apply("Dawn", "Night", true)
        else if(now.isAfter(sunrise) && now.isBefore(twilight)) updateTimeOfDay.apply("Day", "Dawn", true)
        else if(now.isAfter(twilight) && now.isBefore(evening)) updateTimeOfDay.apply("Twilight", "Day", true)
        else if(now.isAfter(evening) && now.isBefore(night))    updateTimeOfDay.apply("Evening", "Twilight", true)
        else                                                    updateTimeOfDay.apply("Night", "Evening", true)
end

Sitemap:

Frame label="Times" {
        Text item=TimeOfDay label="Time of Day"
        Text item=Azimuth
        Text item=Elevation
    }    

Can’t help feeling there’s something glaring I’m missing, but I can’t figure it…

Cheers
J

Try label="Time of Day [%s]". Need a place holder for the item value.

1 Like

And be aware of the problem that you only get values for one day. so night start is infact befor evening.
Example:

Evening start 21:30 22.04.2016
Night start: 0:30 22.04.2016

So your rule will not function correctly

Thomas

Thank you - tried just about everything else!