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.*
import org.java.math.*
rule "turn on"
when
Time cron "0 30 15 * * ?"
then
sendCommand(Annies_room, ON)
logDebug("Annie","Annies_room changed")
end
rule "turn off"
when
Time cron "0 45 19 * * ?"
then
sendCommand(Annies_room, OFF)
logDebug("Annie","Annies_room changed")
end
Would be greatful for some help, thanks in advance!
//Johan
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.
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…
@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?
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.
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.”