Hi,
For some of my items, I would like to capture and display past events in BasicUI. E.g. I would like to see when someone rang my front doorbell over the past two weeks. This is convenient when I’m on holiday or away for business.
I’ve already found a way to capture the last 10 entries.
BasicUI shows:
How I’ve done it:
When someone presses the frontdoor, I update a “history item”:
// ***************************
// Iemand drukt op de bel aan de voordeur
// ***************************
rule "Gira - Zijdeur - bel"
when
Item GiraDCS_Zijdeur changed from OFF to ON
then
// doing a lot of stuff here
postUpdate(GiraDCS_History_00, "Zijdeur - " + GiraDCS_Zijdeur.lastUpdate.toDateTime.toString("dd-MM-yy HH:mm"))
end
The rule below stores the last 10 events:
// ***************************
// Display the history of the last 10 events
// ***************************
rule "GiraDCS - History of last 10 events"
when
Item GiraDCS_History_00 changed
then
postUpdate(GiraDCS_History_10, GiraDCS_History_09.state.toString)
postUpdate(GiraDCS_History_09, GiraDCS_History_08.state.toString)
postUpdate(GiraDCS_History_08, GiraDCS_History_07.state.toString)
postUpdate(GiraDCS_History_07, GiraDCS_History_06.state.toString)
postUpdate(GiraDCS_History_06, GiraDCS_History_05.state.toString)
postUpdate(GiraDCS_History_05, GiraDCS_History_04.state.toString)
postUpdate(GiraDCS_History_04, GiraDCS_History_03.state.toString)
postUpdate(GiraDCS_History_03, GiraDCS_History_02.state.toString)
postUpdate(GiraDCS_History_02, GiraDCS_History_01.state.toString)
postUpdate(GiraDCS_History_01, GiraDCS_History_00.state.toString)
Thread::sleep(100)
GiraDCS_History_10.label = GiraDCS_History_10.state.toString
GiraDCS_History_09.label = GiraDCS_History_09.state.toString
GiraDCS_History_08.label = GiraDCS_History_08.state.toString
GiraDCS_History_07.label = GiraDCS_History_07.state.toString
GiraDCS_History_06.label = GiraDCS_History_06.state.toString
GiraDCS_History_05.label = GiraDCS_History_05.state.toString
GiraDCS_History_04.label = GiraDCS_History_04.state.toString
GiraDCS_History_03.label = GiraDCS_History_03.state.toString
GiraDCS_History_02.label = GiraDCS_History_02.state.toString
GiraDCS_History_01.label = GiraDCS_History_01.state.toString
end
However, this approach has some disadvantages:
- I only capture the last 10 events. If I would like to keep track of the last x weeks, I would need a huge amount of items.
- If I would follow the same approach for other things I would like to keep track of (other events), that would again mean building rules like the above and a similar amount of items.
- This is a workaround at best. I think it is more healthy to leverage persistence;
For persistence I use influxdb, visualized by Grafana. However, I haven’t found a way to just display historical values in Grafana in a simple list (with timestamp). It seems Grafana is more for graphs.
Can anyone share some experiences?
Thanks!