Hi,
Writing a few new rules that run on an item changing but also implicitly rely on running only if my presence item is ON, ie I am home, or OFF I am away.
The bulk of my rules run:
rule "My new rule"
when
Item someitem changed
then
if(vPresent.state == ON)
{
// do some stuff when I am home
}
else
{
// do some other stuff as vPresent must be OFF
}
end
Simples.
However, as some of my rules run implicitly ONLY when say vPresent = ON so I’m thinking could I cut down on my code and just add this to my ‘when’ expression.
rule "My new rule 2"
when
Item someitem changed and vPresent.state == ON
then
// do some stuff when I am home
end
I know you can have multiple ‘or’ in the when part but can you have an ‘and’ there and then reduce the code in the main then part? Seems less code.
If so, what is the best practise, and why?