DSL : comparing strings using two variables

Hi, what am i missing in this rule? if i compare WtrScheduleDays.contains = “MONDAY” everythink is ok, but i want to compare it to a variable

rule "days"
    when
    .....
    then
    var String WtrScheduleDays = ""
    if (WtrScheduleMonday.state == ON) { WtrScheduleDays = WtrScheduleDays + "MONDAY,"}
    if (WtrScheduleTuesday.state == ON) { WtrScheduleDays = WtrScheduleDays + "TUESDAY,"}
    if (WtrScheduleWednesday.state == ON) { WtrScheduleDays =  WtrScheduleDays + "WEDNESDAY,"}
    if (WtrScheduleThursday.state == ON) { WtrScheduleDays = WtrScheduleDays + "THURSDAY,"}
    if (WtrScheduleFriday.state == ON) { WtrScheduleDays = WtrScheduleDays + "FRIDAY,"}
    if (WtrScheduleSaturday.state == ON) { WtrScheduleDays = WtrScheduleDays + "SATURDAY,"}
    if (WtrScheduleSunday.state == ON) { WtrScheduleDays = WtrScheduleDays + "SUNDAY,"}
    
    var String NowDayofWeek = now.getDayOfWeek()
    if (WtrScheduleDays.contains = NowDayofWeek){
	}
 end

Where did you come up with that syntax? .contains is a function call. Functions are passed arguments.

if(WtrSchedudule.contains(NowDayOfWeek){

= is an assignment. So what your original line said, in English: Assign the value of NowDayofWeek to WtrScheduleDays.contains.

In addition to Rich:

Add a log statement, so that you can see the content of your variable.

What you maybe really want (and your current script seems to be only a workaround) is to know if the item representing current day is switched on our off?
To get an item (and it’s state) based on a variable/string, maybe have a look here:

thank you both!. This rule is run fron crontab, so it will check the .states of the items when they are needed maybe it’s a workarround but it ok for me and my skills :wink: