[SOLVED] Announcing sun rise/set

Hi chaps,

I have the following in a rule:

val String ASTRO_INTRO = "Hi, some astro info, "
val String SUN_RISE_TXT = ASTRO_INTRO + “The sun is due to be rising at [%1$tH,%1$tM] hundred hours”
val String SUN_SET_TXT = ASTRO_INTRO + “The sun is due to be setting at [%1$tH,%1$tM] hundred hours”

rule “Sunrise rules”
when
Channel ‘astro:sun:home:rise#event’ triggered START
then
String tmp = Sunrise.state.format(SUN_RISE_TXT)
say (tmp)
end

rule “Sunset rules”
when
Channel ‘astro:sun:home:set#event’ triggered START
then
String tmp = Sunset.state.format(SUN_SET_TXT)
say (tmp)
end

And the following items:

DateTime Sunrise “Sun rise [%1$tH:%1$tM]” (Astro) { channel=“astro:sun:home:rise#end” }
DateTime Sunset “Sun Set [%1$tH:%1$tM]” (Astro) { channel=“astro:sun:home:set#start” }

The astro binding is generating events nicely, apart from the issue requiring a restart periodically. Events are set to trigger 15 minutes prior to each ‘official’ time.

The aim is simply to have the system announce the time the event will take place. I seem to be getting the following error in the logs:

Rule ‘Sunrise rules’: An error occurred during the script execution: Couldn’t invoke ‘assignValueTo’ for feature JvmVoid: (eProxyURI: astro.rules#|::0.2.0.2.0.1::0::/1)

Any assistance on where I am going wrong would be greatly appreciated.

At first you can’t reasign anything to a “val” (short for value, use “var” as in variable.

The following rule say what you want.
Note: I tried my best to put it in a correct english sentence by seperating the houres from the minutes.

rule "Sunset rules"
 when
      Channel 'astro:sun:local:set#event' triggered START
 then
    var string tmp = "The sun is going to set at time  " + Sunset.state.format("%1$tH") + " hundred " + Sunset.state.format("%1$tM") 
    logInfo ("Sunset Rules", "I'm goin to say: {} ", tmp)
    say (tmp)
 end

Thank you. It’s working :slight_smile: