Rules problem, read by the system at all?

Im new to this and Im trying writing my first very basic rule…just to turn on lights at a specified time… and then turn off later also at a specified time. But nothing happens at the desired time and nothing is to be found in the logs…

Im running openhab2 on a raspberry pi 2 (jessie)
I have put my test-rules in the pre-created folder: /etc/openhab2/rules

the file is called “Annie.rule” and is owned by “openhab” user.
The items (z-wave switches) I have successfully configured and labeled through the PaperUi.

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.joda.time.*

rule "turn on"
    Time cron "0 30 15 * * ?"
  sendCommand(Annies_room, ON)
  logDebug("Annie","Annies_room changed")

rule "turn off"
    Time cron "0 45 19 * * ?"
  sendCommand(Annies_room, OFF)
  logDebug("Annie","Annies_room changed")

Would be greatful for some help, thanks in advance!

The ending of the file needs to be " .rules" !

1 Like

I had the feeling I would be embarrased in some way …! Thanks :grinning:

No problem, everybody has started once.
You could change “sendCommand(Annies_room, OFF)” to the method version “Annies_room.sendCommand(OFF)”.

BTW: Under my first reply you have a button to mark this one as the solution!

I get “url not found” when I try to click solved-button at your first reply …

Juat an FYI: The first line should only be imported on openHAB 1.x runtime when you need to access the *Type classes. The next two never need to be imported. The last two would only need to be imported if you were using classes in those packages.

Thanks for pointing that out … how can I know what to import and when ? Is there some guide anywhere? :cold_sweat:

I thought the answer to this was here, but I either have the wrong location, or that helpful bit of information has been lost… @ThomDietrich likely knows more…

I know what you are looking for:

@rlkoshak has greatly rewritten the migration tutorial. I also had a moment a few days back when I missed the condensed list of notable differences between OH1 and OH2 that was previously available. Rich, do you think you could re-add it?

1 Like

@ThomDietrich That list is still there only slightly reworded.

Does the title of the section need to be changed so it is more obvious?

The Necessary Changes and New Concepts sections of the tutorial contain all the information that used to be in the old tutorial.

@watou, The primary difference between the old writeup and the new one is I use paragraphs instead of bullet points. Should I go back to bullet points for legibility? The old bullet point on this topic has become the first sentence of the Rules subsection of Necessary Changes:

One set of errors that will occur in rules that refer to the packages of openHAB core classes (e.g. org.openhabs.core.). These classes have moved to org.eclipse.smarthome.core… Furthermore, these classes as well as the Joda time classes no longer need to be imported.

Ah there it is :smiley: Then no change is needed. What do the others think?

Thanks, Rich, for clarifying. I find the list format clearer than a conversational format, because the differences are concrete and finite. But I am open to this being a matter of preference. The specific wording could be clearer by not even mentioning org.eclipse.smarthome because people might only read that far and do a search and replace. Better to say something along the lines of “remove all imports of org.openhab and org.joda packages as they or their equivalents are imported implicitly now.”

Creates an Issue to capture this.

Not sure when I’ll get to this. I’m still struggling with bringing back up my crashed system so time is short for me right now.

1 Like