[HELP] Rule not running as expected

I have created the rule below to open my Kitchen blind around Sunrise but not before 6:30. I’m getting the following error when it’s run. Can anyone point me in the right direction?

This is the error I get. For context sunrise was at 7:38 today for me.

2023-11-22 07:38:00.003 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'Kitchen-9' failed: An error occurred during the script execution: Cannot invoke ")" because "type" is null in Kitchen

rule "SCHEDULED: Open the Kitchen blind at Sunrise or after 6:30am"
    Channel 'astro:sun:local:rise#event' triggered START
var vTimeout = (Timeout_15.state as Number).intValue
val DateTime sunriseTime = (Sunrise_Time.state as DateTimeType).getZonedDateTime()
val DateTime minimumTime = new DateTime(now.toLocalDate().toString + "T06:30:00")
if (sunriseTime.isAfter(minimumTime)) {
	logInfo(logName, "SYSTEM MESSAGE: Opening the Kitchen blind in {} minutes.", Timeout_15.state)
	createTimer(now.plusMinutes(vTimeout)) [|

Well, why not using the astro binding as intended? You can setup a upper and lower border for every channel (may it be of Type Trigger or Datetime). just setup parameter earliest to 06:30:00 in the rise#event Channel and the trigger will occur at 06:30:00 or later.

The overall correct solution is to do as @Udo_Hartmann recommends.

But this error probably indicates that you’ve a miss matched set of parens somewhere. In short, there’s an extra closing ).

I would also recommend the astro binding in the correct way.

However just for completeness and in case someone else tries to copy & paste your code, there is an issue with the timer.

You have:

createTimer(now.plusMinutes(vTimeout)) [|

But it should be:

createTimer(now.plusMinutes(vTimeout), [ |
1 Like

Thanks everyone for your input. I’ve updated my Astro thing as suggested.

Both ways are correct :slight_smile: (I also prefer the lambda as a parameter, though)