I am seeing the following errors occasionally in the log file. The rule is one that came recommended with the EcoBee binding to track changes in occupancy.
Anyone share some insight as to what might be going on?
2017-12-10 18:35:10.000 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'D_LastMotionOFF': An error occurred during the script execution: null
2017-12-10 18:17:06.540 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'U_LastMotionOFF': An error occurred during the script execution: null
RULE:
var D_DateTime
var U_DateTime
//Downstairs
rule D_LastMotionON
when
Item D_Hvac_Occu changed to ON
then
postUpdate(D_Hvac_LastOccuTime, new DateTimeType())
end
rule D_LastMotionOFF
when
Item D_Hvac_Occu changed to OFF
then
switch D_Hvac_LastOccuTime.state {
DateTimeType: {
var D_DateTime halfHourAgo = now.minusMinutes(30)
var D_DateTime lastKnownMotion = new D_DateTime((D_Hvac_LastOccuTime.state as DateTimeType).calendar.timeInMillis)
if (halfHourAgo.isAfter(lastKnownMotion)) {
D_Hvac_LastOccuTime.postUpdate(new DateTimeType(halfHourAgo.toString))
}
}
}
end
//Upstairs
rule U_LastMotionON
when
Item U_Hvac_Occu changed to ON
then
postUpdate(U_Hvac_LastOccuTime, new DateTimeType())
end
rule U_LastMotionOFF
when
Item U_Hvac_Occu changed to OFF
then
switch U_Hvac_LastOccuTime.state {
DateTimeType: {
var U_DateTime halfHourAgo = now.minusMinutes(30)
var U_DateTime lastKnownMotion = new U_DateTime((U_Hvac_LastOccuTime.state as DateTimeType).calendar.timeInMillis)
if (halfHourAgo.isAfter(lastKnownMotion)) {
U_Hvac_LastOccuTime.postUpdate(new DateTimeType(halfHourAgo.toString))
}
}
}
end
There is a command switch, but as far as I know, this is to decide between two or more options, given by another command case
So the rule should be more like
rule D_LastMotionOFF
when
Item D_Hvac_Occu changed to OFF
then
var DateTime halfHourAgo = now.minusMinutes(30)
var DateTime lastKnownMotion = new DateTime((D_Hvac_LastOccuTime.state as DateTimeType).calendar.timeInMillis)
if (halfHourAgo.isAfter(lastKnownMotion)) {
D_Hvac_LastOccuTime.postUpdate(new DateTimeType(halfHourAgo.toString))
}
end
I am using the latest version of vs code and the OH plugin…I may have stepped back a version or two on the snapshot as I’ve been encountering issues with the HUE Emulation plugin and haven’t found a fix as of yet.
I implemented the change you suggested above and now see the following in my openhab.log
Rule 'D_LastMotionOFF': An error occurred during the script execution: The name '<XFeatureCallImplCustom>.isAfter(<XFeatureCallImplCustom>)' cannot be resolved to an item or type.
You tell OpenHAB to create a variable of type D_DateTime, which is not a valid type (someone correct me if I’m wrong), and since the type does not exist, it doesn’t have the isAfter() method.
The reason I appended a D_to D_DateTime is the fact that I have two similar rules on the same page…one for the DOWNSTAIRS thermostat which is D_DateTime and one for the UPSTAIR thermostat U_DateTime.
I was concerned about using the same variable for both. If I need to remove the prefix, should I break the rules into separate files?
Sorry for that typo… have corrected this one above.
The point is:
var DateTime D_halfHourAgo
^ ^ ^ named D_halfHourAgo
| of Type DateTime
define a variable
This is the meaning of the code line
Of course, if defining a var within a rule, the name will only be used in this rule, so, you don’t need to differ these var names.