I think I am getting something really basic wrong in my rules syntax, but am struggling to find anything in the documentation or forums that are helping me. Please can you shed some light for me?
I have a numberItem called Days_away which is represented in the sitemap with a setpoint. I want to use it to tell the system, when I am away, how many days I will be away for.
The idea is that every day at midnight the Days_away value will be decreased by 1, so on the day I am due to return, the whole house will go back to its lived-in state.
In the rules I have:
var Number New_date = 0
rule "Update days_away at midnight"
when
Item Test_switch changed /* for testing this switch is in place of a cron /
then
if ( Days_away.state > 0 ) {
New_date = Days_away.state-1 / This is the line that seems to be wrong */
postUpdate(Days_away, New_date)
}
end
But this returns an error in the debug window:
Error during the execution of rule ‘Use the test switch changing in place of a cron’: The name ’ - ’ cannot be resolved to an item or type.
Please can you help me work out what I am doing wrong?
Thanks,
Philip