Help with Rule, when item equals

I’m having difficulty creating a rule that occurs at a certain time and is triggered when a String is equal to a defined word.

The string in my item file is:

String CoffeeStatus "The Coffee Maker Is:" { channel="wemo:CoffeeMaker:CoffeeMaker-1_0-221430S00003F5:coffeeMode" }

and I can make it work in this rule when I look for a change:

rule "coffeeready"
when
Item CoffeeStatus changed from Brewing to Brewed
then 
say("Good Morning Madame, Your Coffee is Ready")

end

Yet when I try to look for the status RefillWater I can’t seem to make it work with the rule below:

rule "refillcoffeepot"

when
Time cron "0 0 21 1/1 * ? *"
then
Item CoffeeStatus == "RefillWater"
then
say ("Please refill the coffee pot")
end

I’m sure it’s something with the syntax can someone assist in pointing me in the right direction.

Using == for comparison makes it a numeric comparison, use eq thats the one that compares string equal.

OpenHAB Items are complex objects. You do not want to be comparing the whole object with, say, a string.
It is usually the .state of the Item you are interested in. The .state may or may not be a string, a number, etc. so you usually have to manipulate it a bit into the kind of variable that you want.

Example

when
   Time cron "0 0 21 1/1 * ? *"
then
   if (CoffeeStatus.state.toString == "RefillWater") {
      say ("Please refill the coffee pot")
   }
end

You can only have one then section in a rule.

1 Like

@rossko57

Many thanks for the insight…I’ll use this as I further my knowledge of OH.

Squid