Time Of Day Rule

I am new to openHAB and trying to learn how to write rules. Ive started with this time of day rule

(Code at very top of page).

I have basicaly installed the astro binding, and copy / paste the items file and rules file.
how ever im logging this error

13:31:56.663 [ERROR] [untime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'Calculate time of day state': Invalid format: "NULL"

This is my items file

/* Groups */
Group All
Group Lights                "All Lights [(%d)]"                                  (All)
Group IndoorLights          "Indoor Lights [(%d)]"                               (All)
Group OutdoorLights         "Outdoor Lights [(%d)]"                              (All)
Group SecurityLights        "Security Lights [(%d)]"                             (All)
Group NightLights           "Night Lights [(%d)]"                                (All)
Group Configuration         "Configuration"	           <settings>		         (Status)
Group Status                "Status"                                             (Configuration)
Group Atsro                                            <sun_clouds>              (Configuration)

/* Config Items */
Switch VacationMode			"Vacation Mode"	            <vacation>	             (Configuration)
Switch NightSwitch			"Night Switch"			                             (Configuration) ["Switchable"]		
Switch Christmas			"Christmas Lights"			                         (Configuration)


/* Virtual Switches */
String SecurityLightBackyardLeftSelect                                           (Status)

/* Astro */
DateTime    Current_DateTime     "Today [%1$tA, %1$td.%1$tm.%1$tY]"                 <clock>          (Astro)    {channel="ntp:ntp:local:dateTime"}
//
String      vTimeOfDay      "Current Time of Day [MAP(weather.map):%s]"             <tod>            (Astro)
DateTime    vMorning_Time   "Morning [%1$tH:%1$tM]"                                 <sunrise>        (Astro)
DateTime    vSunrise_Time   "Day [%1$tH:%1$tM]"                                     <sun>            (Astro)    { channel="astro:sun:home:rise#start" }
DateTime    vSunset_Time    "Evening [%1$tH:%1$tM]"                                 <sunset>         (Astro)    { channel="astro:sun:home:set#start" }
DateTime    vNight_Time     "Night [%1$tH:%1$tM]"                                   <moon>           (Astro)
DateTime    vBed_Time       "Bed [%1$tH:%1$tM]"                                     <bedroom_blue>   (Astro)
DateTime    vEvening_Time   "Afternoon [ %1$tH:%1$tM]"                              <sunset>         (Astro)    { channel="astro:sun:minus90:set#start" }




/* Wall SwitchPlates */
Switch   WsPatioRelay1          "Relay 1"                (Lights)      ["switchable"]    {channel="mqtt:topic:b6d9115a:Relay1"}
Switch   WsPatioSwitchShort1    "Switch short 1"         (Status)                        {channel="mqtt:topic:b6d9115a:SwitchShort1"}
Switch   WsPatioSwitchLong1     "Switch long 1"          (Status)                        {channel="mqtt:topic:b6d9115a:SwitchLong1"}

Switch   WsKitchenRelay1         "Relay 1"               (Lights)                        {channel="mqtt:topic:0a52d8c3:Relay1"}
Switch   WsKitchenSwitchShort1   "Switch short 1"        (Status)                        {channel="mqtt:topic:0a52d8c3:SwitchShort1"}
Switch   WsKitchenSwitchLong1    "Switch long 1"         (Status)                        {channel="mqtt:topic:0a52d8c3:SwitchLong1"}
Switch   WsKitchenRelay2         "Relay 2"               (Lights)      ["switchable"]    {channel="mqtt:topic:0a52d8c3:Relay2"}
Switch   WsKitchenSwitchShort2   "Switch short 2"        (Status)                        {channel="mqtt:topic:0a52d8c3:SwitchShort2"}
Switch   WsKitchenSwitchLong2    "Switch long 2"         (Status)                        {channel="mqtt:topic:0a52d8c3:SwitchLong2"}



/* Security Lights */
Switch   SecurityLightBackyardLeft   "Security light backyard (left)"  (Lights) ["switchable"] {channel="mqtt:topic:846b6b01:SecurityLight_BackyardLeft"}

/* Lifx Lighting */

Color    LightKitchen1Color                  "Kitchen Light 1 Color"                <colorlight>         (Lights) ["lighting"]  {channel="lifx:colorlight:D073D55410F1:color"}
Switch   KitchenLightSwitch                                                                              (Lights)               {channel="lifx:colorlight:D073D55410F1:color"}
Dimmer   LightKitchen1Temperature            "Kitchen Light 1 Temperature"          <light>              (Lights)               {channel="lifx:colorlight:D073D55410F1:temperature"}
Number   LightKitchen1Signalstrength         "Kitchen Light 1 Signal strength"      <qualityofservice>                          {channel="lifx:colorlight:D073D55410F1:signalstrength"}

Color    LightDiningRoom1Color               "Dining Room Light 1 Color"            <colorlight>         (Lights) ["lighting"]  {channel="lifx:colorlight:D073D553DC9F:color"}
Dimmer   LightDiningRoom1Temperature         "Dining Room Light 1 Temperature"      <light>              (Lights)               {channel="lifx:colorlight:D073D553DC9F:temperature"}
Number   LightDiningRoom1Signalstrength      "Dining Room Light 1 Signal strength"  <qualityofservice>                          {channel="lifx:colorlight:D073D553DC9F:signalstrength"}

Color    LightLivingRoom1Color               "Living Room Light 1 Color"            <colorlight>         (Lights) ["lighting"]  {channel="lifx:colorlight:D073D555AFEB:color"}
Dimmer   LightLivingRoom1Temperature         "Living Room Light 1 Temperature"      <light>              (Lights)               {channel="lifx:colorlight:D073D555AFEB:temperature"}
Number   LightLivingRoom1Signalstrength      "Living Room Light 1 Signal strength"  <qualityofservice>                          {channel="lifx:colorlight:D073D555AFEB:signalstrength"}

And this is my Rule

val logName = "Time Of Day"

rule "Calculate time of day state" 
when
  System started or // run at system start in case the time changed when OH was offline
  Channel 'astro:sun:home:rise#event'    triggered START or
  Channel 'astro:sun:home:set#event'     triggered START or
  Channel 'astro:sun:minus90:set#event'  triggered START or
  Time cron "0 1 0 * * ? *" or // one minute after midnight so give Astro time to calculate the new day's times
  Time cron "0 0 6 * * ? *" or
  Time cron "0 0 23 * * ? *"
then

  logInfo(logName, "Calculating time of day...")

  // Calculate the times for the static tods and populate the associated Items
  // Update when changing static times
  // Jump to tomorrow and subtract to avoid problems at the change over to/from DST
  val morning_start = now.withTimeAtStartOfDay.plusDays(1).minusHours(18)
  vMorning_Time.postUpdate(morning_start.toString) 

  val night_start = now.withTimeAtStartOfDay.plusDays(1).minusHours(1)
  vNight_Time.postUpdate(night_start.toString)

  val bed_start = now.withTimeAtStartOfDay
  vBed_Time.postUpdate(bed_start.toString)

  // Convert the Astro Items to Joda DateTime
  val day_start = new DateTime(vSunrise_Time.state.toString) 
  val evening_start = new DateTime(vSunset_Time.state.toString)
  val afternoon_start = new DateTime(vEvening_Time.state.toString)

  // Calculate the current time of day
  var curr = "UNKNOWN"
  switch now {
  	case now.isAfter(morning_start)   && now.isBefore(day_start):       curr = "MORNING"
  	case now.isAfter(day_start)       && now.isBefore(afternoon_start): curr = "DAY"
  	case now.isAfter(afternoon_start) && now.isBefore(evening_start):   curr = "AFTERNOON"
  	case now.isAfter(evening_start)   && now.isBefore(night_start):     curr = "EVENING"
  	case now.isAfter(night_start):                                      curr = "NIGHT"
  	case now.isAfter(bed_start)       && now.isBefore(morning_start):   curr = "BED"
  }

  // Publish the current state
  logInfo(logName, "Calculated time of day is " + curr)
  vTimeOfDay.sendCommand(curr)
end

// Examples for use of vTimeOfDay
rule "Day time started"
when
  Item vTimeOfDay changed to "DAY" // does not work prior to OH 2.3 Release
then
  // do stuff when DAY starts
end

//rule "Some rule"
//when
    // some trigger
//then
//  if(vTimeOfDay.state != "BED") return;

  // do stuff to do when it isn't BED time
//end 

As i said i am new and try to get my head around how it all works
any help would be appreaceated

You should start by figuring out which line is throwing the error. Put some added log statements before each major section and observe which ones don’t get output.

Thankyou,
I did not have my astro binding setup propley, so now that is fixed.

however im now getting this error

15:25:10.530 [WARN ] [orm.AbstractFileTransformationService] - Could not transform 'DAY' with the file 'weather.map' : Target value not found in map for 'DAY'

it seems either you do not havy a map-file called “weather.map” in folder “transform” or at least the entry “DAY” is missing. my map-file for example looks like this:

// iSternkreiszeichen
ARIES=♈ Widder
TAURUS=♉ Stier
GEMINI=♊ Zwilling
CANCER=♋ Krebs
LEO=♌ Löwe
VIRGO=♍ Jungfrau
LIBRA=♎ Waage
SCORPIO=♏ Skorpion
SAGITTARIUS=♐ Schütze
CAPRICORN=♑ Steinbock
AQUARIUS=♒ Wassermann
PISCES=♓ Fisch

// iJahreszeit
SPRING=Frühling
SUMMER=Sommer
AUTUMN=Herbst
WINTER=Winter

// iTageszeit
DAYLIGHT=Tag
SUN_SET=Sonnenuntergang
CIVIL_DUSK=zivile Abenddämmerung
NAUTIC_DUSK=nautische Abenddämmerung
ASTRO_DUSK=astronomische Abenddämmerung
NIGHT=Nacht
ASTRO_DAWN=astronomische Morgendämmerung
NAUTIC_DAWN=nautische Morgendämmerung
CIVIL_DAWN=zivile Morgendämmerung
SUN_RISE=Sonnenaufgang

//
MORNING=Morgen
DAY=Vormittag
AFTERNOON=Nachmittag
EVENING=Abend
NIGHT=Nacht
BED=Bettzeit

// iMondphase
NEW=🌑 Neumond
WAXING_CRESCENT=🌑→🌓 zunehmender Halbmond
FIRST_QUARTER=🌓 erstes Viertel
WAXING_GIBBOUS=🌓→🌕 zunehmender Mond
FULL=🌕 Vollmond
WANING_GIBBOUS=🌕→🌗 abnehmender Mond
THIRD_QUARTER=🌗 letztes Viertel
WANING_CRESCENT=🌗→🌑 abnehmender Halbmond

// unbekannt
NULL=unbekannt ⁉
UNDEF=unbekannt ⁉
-=unbekannt ⁉

you see there is an entry “DAY” that will be transformed to “Vormittag” (for Germany) - and “Vormittag” is what will be displayed in sitemap

Ok, thank you. I have it sorted now.

What was your problem here? I have the same issue and can’t get it to work.

I installed the open weather binding and one of the transformation add ons, can’t remember witch one. Then created a map file like above but in English