I’m trying to create a log with changes of the status from an open/closed node (door, window, fence…).
But it seems that my filter isn’t sorted correctly (or to fast, or …). sortBy[lastUpdate].last.
But sometimes, the wrong device is being shown. See the entry on 07:31:02 in my logfile below.
Maybe because that node sends an global update about his status (thinking out loud here)?
Can I filter on ‘last change’ or so?
items (20 in total)
Contact Deur_Atelier "Atelier Deur [%s]" <Door> (ALL_entries, AllDoors, ent_POL) { channel = "zwave:device:2f4ef5d0:node93:sensor_door" }
Contact Poort_Atelier "Poort Atelier [%s]" <garagedoor> (ALL_entries, ent_POL) { channel = "zwave:device:2f4ef5d0:node32:sensor_door" }
...
rule
rule "Logging van open zaken"
when
Member of ALL_entries changed
then
val String currentTime = String::format( "%1$te/%1$tm/%1$tY %1$tT", new java.util.Date )
val ODstate = ALL_entries.members.filter[s | s.state == OPEN || s.state == CLOSED].sortBy[lastUpdate].last
executeCommandLine("/bin/sh@@-c@@(echo '" + currentTime + " " + ODstate.label + " " + ODstate.state + ".' >> /var/log/openhab2/OpenClose.log)", 5000)
end
OpenClose.log
4/06/2020 06:48:21 Poort Werkplaats OPEN.
4/06/2020 06:48:55 Poort Werkplaats CLOSED.
4/06/2020 07:31:02 Leefruimte Venster CLOSED.
4/06/2020 07:31:10 Hal Deur CLOSED.
4/06/2020 07:44:32 Hal Deur OPEN.
4/06/2020 07:44:37 Hal Deur CLOSED.
4/06/2020 07:45:36 Hal Deur OPEN.
4/06/2020 07:47:14 Hal Deur CLOSED.