- Platform information:
- Hardware: I3 9100 / 16GB
- OS:Windows 10
- Java Runtime Environment:Zulu
- openHAB version:2.5
I want to display the 10 latest motion events in my sitemap.
The problem is that I can’t get the rule to work.
The idea is to log the date/time of the detection and move the older detection time to another item. I created 10 “DateTime” items (MotionTime1 to MotionTime10) in my items file.
I have a switch item called “MotionDtected” which is linked to a channel called “motionAlarm” of the IPcamera binding. The switch works as expected, when motion is detected it switches to on and after a while it switches off again.
I expect my issue has something to do with copying of DateTime to another variable, but I can’t figure out why. Please note that I am not a programmer, so the rule I made is based what I could find in the topics.
Below I pasted my rule. Your help is very much appreciated.
var DateTimeType Time1=null
var DateTimeType Time2=null
var DateTimeType Time3=null
var DateTimeType Time4=null
var DateTimeType Time5=null
var DateTimeType Time6=null
var DateTimeType Time7=null
var DateTimeType Time8=null
var DateTimeType Time9=null
var DateTimeType Time10=null
rule “Create timestamp of latest motion detection”
when
Item MotionDetected received command
then
if (receivedCommand == ON) {
Time10=Time9
Time9=Time8
Time8=Time7
Time7=Time6
Time6=Time5
Time5=Time4
Time4=Time3
Time3=Time2
Time2=Time1
Time1=( new DateTimeType() )
MotionTime1.postUpdate(Time1)
MotionTime2.postUpdate(Time2)
MotionTime3.postUpdate(Time3)
MotionTime4.postUpdate(Time4)
MotionTime5.postUpdate(Time5)
MotionTime6.postUpdate(Time6)
MotionTime7.postUpdate(Time7)
MotionTime8.postUpdate(Time8)
MotionTime9.postUpdate(Time9)
MotionTime10.postUpdate(Time10)
}
end