What am I doing wrong with this rule?

Hi, I’m thinking about switching over to openhab but i’m having some trouble figuring out the rules. I’m trying to create a simple sample rule to test things out. I just want to turn a light off at a specific time. I can control the light using a site map but I can’t figure out how to do it automatically.

I’m getting the following error in designer

Multiple markers at this line

  • This expression is not allowed in this context, since it doesn’t
    cause any side effects.
  • no viable alternative at input ‘Item’

I’m pretty sure my problem is in the imports section but I don’t know what to put in there.

Below is the rule as it’s written in designer. I imported a whole bunch a stuff just to test but I can’t figure this out.

import org.joda.time.*
import org.openhab.core.library.types.*
import org.openhab.core.library.types.PercentType
import org.openhab.core.library.items.SwitchItem
import org.openhab.model.script.actions.*
import org.openhab.model.script.actions.Timer

rule "LightsOut"
when
    Time cron "30 16 * * * ?"
then
    Item Light_FF_Family_Ceiling OFF
end

Can someone give me a hand?

Most likely the issue is in your ‘then’ block where you appear to be using the wrong syntax. Try:

sendCommand(Light_FF_Family_Ceiling, OFF);

See: https://github.com/openhab/openhab/wiki/Actions#event-bus-related-actions for details.

Note that the executable part of the rule is written in the Xtend programming language and does not share a syntax with the triggers section.

HTH

Brilliant!!! That worked. Thank you!

I’m going to have to research Xtend. I can usually understand written code but writing it from scratch is hit or miss.

Thanks!!!

Yes, I agree. It’s not the best and debugging can be difficult. Check out the Jsr223 binding if you want to write in a more familiar language.