Persist data for every item in a group

Tags: #<Tag:0x00007f0142d99fa0> #<Tag:0x00007f0142d99a28>

(Peter K) #1


I want to draw a chart of the battery levels of my Tradfri remotes. I tried to follow the steps of the Influx and Grafana Tutorial. I could draw the sinus test chart and managed to insert data from (only one?) Tradfri remote. The data is the current battery level (so, a little success). My Problem is:
I think most of the time only the data of one remote gets persisted (and I don’t know of which one). My setting:

The items/groups:

Group   gFP_Status               "Status"              <status>        (gFP)
Group   gFP_Status_BatteryLevel               "Batterieladung"              <status>        (gFP_Status)
// Remotes
Number      Remote_GF_Bedroom_BatteryLevel             "Batterieladung"               <Battery>         (gFP_Status_BatteryLevel) { channel="tradfri:xx:x:xx:battery_level" }
Switch      Remote_GF_Bedroom_LowBattery               "Niedriger Batteriestatus"     <Battery>         (gFP_Status_LowBattery) { channel="tradfri:xx:xx:xx:battery_low" }
Number      Remote_GF_LivingRoom_BatteryLevel          "Batterieladung"               <Battery>         (gFP_Status_BatteryLevel) { channel="tradfri:xx:xx:xx:battery_level" }
Switch      Remote_GF_LivingRoom_LowBattery            "Niedriger Batteriestatus"     <Battery>         (gFP_Status_LowBattery) { channel="tradfri:xx:xx:xx:battery_low" }
Number      Remote_GF_Kitchen_BatteryLevel             "Batterieladung"               <Battery>         (gFP_Status_BatteryLevel) { channel="tradfri:xx:xx:xx:battery_level" }
Switch      Remote_GF_Kitchen_LowBattery               "Niedriger Batteriestatus"     <Battery>         (gFP_Status_LowBattery) { channel="tradfri:xx:xx:xx:battery_low" }

influxdb.persist (the everyMinute strategy is added in order to get some test data):

// persistence strategies have a name and definition and are referred to in the "Items" section
Strategies {
    everyMinute         : "0 * * * * ?"
    everyFiveMinutes    : "0 */5 * ? * *"
    everyTenMinutes     : "0 */10 * ? * *"
    everyFifteenMinutes : "0 */15 * ? * *"
    everyHalfHour       : "0 */30 * ? * *"
    everyHour           : "0 0 * * * ?"
    everyTwoHours       : "0 0 0/2 ? * *"
    everyTwelveHours    : "0 0 */12 ? * *"
    everyDay            : "0 0 0 * * ?"

    // if no strategy is specified for an Item entry below, the default list will be used
    default = everyChange

 * Each line in this section defines for which Item(s) which strategy(ies) should be applied.
 * You can list single items, use "*" for all items or "groupitem*" for all members of a group
 * Item (excl. the group Item itself).
Items {
    gFP_Status_BatteryLevel* -> "Batterieladung" : strategy = everyChange, everyHour, everyMinute

influxdb data (snippet):

> select * from Batterieladung
name: Batterieladung
time                     value
----                     -----
2019-01-01T14:56:00.1Z   87
2019-01-01T14:57:00.111Z 87
2019-01-01T14:58:00.109Z 87
2019-01-01T14:59:00.128Z 87
2019-01-01T15:00:00.105Z 74
2019-01-01T15:00:00.106Z 87
2019-01-01T15:00:00.33Z  87
2019-01-01T15:01:00.181Z 74
2019-01-01T15:01:00.182Z 87

The data show that mostly one remote’s battery level with 87% battery level gets persistet. Sometimes the data from a second one is added, but just every now and then.
What did I miss? How can I add the values of every remote battery level individually and how can I chart them individually and how can I tell which battery level belongs to which remote?

  • Platform information:
    • Hardware: RP 3b+
    • OS: RaspBian stretch
    • openHAB version: 2.4
    • influxdb 1.7.2

Many thanks in advance and best regards. If you need more information/logs, please tell me.

(Rolf Vermeer) #2

Can you remove the alias:

Items {
    gFP_Status_BatteryLevel* : strategy = everyChange, everyMinute

Right now you are trying to push all values into a single alias, and tbh I do not know what the exact implication of that is, but it might explain this behaviour.
Furthermore, everyHour and everyMinute is a bit double, you do not need everyHour, as it is already stored at every minute, so also the first minute of each hour. Next to that, if you already store every minute, you might also doubt the use of everyChange, especially for battery levels. They typically do not drain that fast…

(Peter K) #3

Thanks, that was the problem. I do now have a measurement for every Item in my InfluxDB and can chart in grafana.

Is it possible to use an alias and additional tags/fields which contain the Item name? That way I would have only one measurement and could select the data I want to chart using a WHERE clause.
Might be a cleaner database and a more flexible measurement.

Yeah, I know. I just had everyMinute added, to have quickly some data. I didn’t want to wait some hours to test :laughing:

(Vincent Regaud) #4

Please mark the thread as solved, thanks

(Rolf Vermeer) #5

Yes and no: you could still use aliases, but then you would need to define the strategy and alias for each item individually, and those aliases would be the only name under which it gets stored in the database, afaik.