Hi all,
I am on the latest GA stable release OH 2.3
I suspect I am doing something dumb but for the life of me cannot figure out what, I have done similar rules in the past and have them all working but this one has escaped me and I resorted to a simple set of if statements to workaround while I request the communities assistance.
I am trying to use the technique where I create an items name to update using triggered items names and a suffix.
here is my configuration
.items
Group gContact // presense contacts last changes
Switch cPaul_Phone "Paul (Phone)" (chartpersist, statepersist, gPresent, gContact)
Switch cHolly_Phone "Holly (Phone)" (chartpersist, statepersist, gPresent, gContact)
DateTime cPaul_Phone_Last "[%1$tY-%1$tm-%1$td %1$tH:%1$tM]"
DateTime cHolly_Phone_Last "[%1$tY-%1$tm-%1$td %1$tH:%1$tM]"
This is the workaround rule which functions but not happy with it
.rules
rule "Contact update Last Change"
when
Member of gContact received update or
Member of gContact changed
then
logInfo("phone.rules", triggeringItem.name + " Phone received a change")
val pContact = triggeringItem.name.split("_").get(0)
//val _Last = gContact.members.findFirst[ contact | contact.name == triggeringItem.name+"_Last" ]
if (pContact == "cPaul") {postUpdate(cPaul_Phone_Last,new DateTimeType())}
if (pContact == "cHolly") {postUpdate(cHolly_Phone_Last,new DateTimeType())}
logInfo("phone.rules", "Changed - "+triggeringItem.name)
end
Instead of the two if statements in my example I would prefer to uncomment the _Last definition and use something like this one liner to replace the if statements with a single line (in reality I have many if statements).
postUpdate(_Last,new DateTimeType())
But it just does not update the item with the current date time-stamp
Can someone point out what I am doing wrong? It is possible I have hit a bug but kind of thinking its me at this stage.
Many thanks
Paul