Seeing history of lights turned on in a group

Hi All, I am running openHAB 1.8 with a mySQL server and am trying to view a chart of how many lights in total are turned on.

I have a group item defined as follows

Group:Switch:OR(ON, OFF) Lights "All Lights [(%d)]" (All)

and a persistence config as:

Strategies {
    everyHour : "0 0 * * * ?"
    everyDay  : "0 0 0 * * ?"

    default = everyChange

Items {
    Lights : strategy = everyChange, everyHour, restoreOnStartup

Lights are controlled individually but the counter “%d” works as I would like it to, unfortunately when I try to view the number of lights as a history chart (i.e. chart?items=Lights&period=h&service=mysql) it shows up as empty.

I’m guessing this happens because I should be using type “Number”, if this is the case how do I count the ON states of the group so that I can store it in a new Item which persists?

I don’t think the state of a Group is persisted and even if it were I’m positive that non-state info like the count of members who are ON is not persisted so what you would have to do is add a new Number Item and update it with the count of ON lights using a rule along the lines of the following:

rule "Get Lights On Count"
    Item Lights received update

Then make sure that LightsCount is stored in your persistence and chart that instead of the Group.


This works great, thank you for the solution and for explaining where it was going wrong!!