OH2 rules int

I was trying to get a now.GetDayOfWeek rule to work.

It seemed like it was not working(as if I didn’t know what numbers 1-7 correlated to.
That’s question 1: GetDayOfWeek 1-7 is that Sun-Sat?

In order to try to figure out what it was returning i wrote a test rule that would email me the value returned for today’s day in integer format. I keep getting an error in the log when it runs:
2017-02-25 00:46:42.380 [ERROR] [.script.engine.ScriptExecutionThread] - Rule ‘Test Rule’: An error occured during the script execution: The name ‘.GetDayOfWeek’ cannot be resolved to an item or type.
Question 2: What am i doing wrong here?

var int todayint

rule "Test Rule"
when
Item TestRule received command ON
then

todayint = now.GetDayOfWeek

if (now.getDayOfWeek>1 && now.getDayOfWeek<7) {
sendMail("test@gmail.com", “Office Hue Weekday” + todayint + “”,“Office Hue Weekday”)
}
else{
sendMail("test@gmail.com", “Office Hue Weekend”,“Office Hue Weekend”)
}

now.getDayOfWeek() is a function. You need the (),

Is this true? I call my functions without any () if they don’t have a parameter. Like timer.cancel. Works.

Hi, here is typo - now.getDayOfWeek - case sensitive.

1 Like

In order to test you should use a
logInfo (“YourRuleName”,“todayint: {}”, todayint)

Thanks!