Need some help with energy monitoring and rules

Hi there!

I’m still pretty new to Openhab but I’ve gotten most of what I wanted set up, but now I’m a bit stumped as to how I should proceed.

The problem: I have a HS110 outlet that monitors the energy usage of my second freezer, this freeze has a tendency to sometimes cut out, if it is installed in our shed. The freezer works fine if the power is cycled after it randomly cuts out. My theory is that energy usage/current would drop during such a cut out.

My intended solution: I want to log 30 days worth of info on it’s daily average energy usage and current, then use these numbers in a rule that triggers a notification if a significant drop is detected compared to my average values.

As it stands the HS110 reports its current values just fine, but I’m not currently logging them anywhere, so if I understood it correctly, I’ll need:

Some kind of persistence, and a rule to log the daily values into said persistence.
A rule that compares the current values gathered with the average values logged in the persistence.

And that’s kinda where I stopped, I’m a novice programmer at best, and still learning Openhab I’m not entirely sure if this is the correct approach.

Any feedback is welcome!

You don’t need the Rule. You configure persistence and it will save the values based on the configured strategy (only command, every update, periodically, etc).

The rest sounds reasonable.

It’s fairly easy enough to setup influxdb (persistance) and grafana (visualisation) using some of the tutorials about. I tend to use grafana for my alerts as it easier than doing the maths / emails in openhab rules. It already allows you to easily work out mean and you can alert on certain thresholds and also (somewhat more important I find) when there is no data being received for the x min / hour (depending on your zwave energy reporting intervals)

Ah right, that definitely sounds easier than learning a new, albeit similar language, I’ll look into that, thanks!

One tip I will give you is that if you’re going to use Influx + Grafana to watch for missing data, you need to set the persistence config file to everyUpdate, as if there is no value change, then openhab will not update the table and you will get Grafana triggering erroneously.

Here I dump everything in my openhab on every update (however most of my items don’t report more often than 15min, most an hour so DB does not fill up too much)

openhabian@openHABianPi:/etc/openhab2/persistence $ cat influxdb.persist
// persistence strategies have a name and a definition and are referred to in the “Items” section
Strategies {
// if no strategy is specified for an item entry below, the default list will be used
default = everyUpdate
Items {
// persist all items once a day and on every change and restore them from the db at startup
// careful, this might result in huge databases - that’s why it is in comment here ;

* : strategy = everyUpdate, everyDay, restoreOnStartup
// persist all temperature and weather values at every change and every hour
// * : strategy = everyChange, everyHour

Thank you!

I’ve followed this guide and gotten InfluxDB up and running and I can dump garbage data into it and show it with Grafana, so far so good.

But I’m not entirely sure Openhab is connected to the DB, if I understand the .persist file correctly it should at the very least persist all my devices at least once, and 3 items from my freezer, every hour.

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

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

 * 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 {

        Fryser_EnergyUsage, Fryser_Voltage, Fryser_Current : strategy = everyhour
        // persist all items once a day and on every change and restore them from the db at startup
        * : strategy = everyChange, everyDay, restoreOnStartup


But I’m not seeing anything in Grafana. I’ve looked to the logs but haven’t found any mentions of influxDB, is there a specific log file I’m missing that’d keep track of it’s attempts to connect?

So you need the influx persistence binding installed, and also the following (I use IP can’t recall if local loopback or localhost causes issues…:

openhabian@openHABianPi:/etc/openhab2/services $ cat influxdb.cfg
# The database URL, e.g. or .
# Defaults to:

# The name of the database user, e.g. openhab.
# Defaults to: openhab

# The password of the database user.

# The name of the database, e.g. openhab.
# Defaults to: openhab

The port must match in /etc/influxdb/influxdb.conf:

  # Determines whether HTTP endpoint is enabled.
enabled = true

  # The bind address used by the HTTP service.
bind-address = ":8086"

My mistake I should’ve included that in my previous post, but I’ve already set up those 2 configs and added the InfluxDB binding.

I’m gonna go over them again and see if I spot some inconsistency.

I can’t seem to find anything that’d cause this, it almost looks like Openhab isn’t even attempting, there’s only one thing in the log regarding influxDB, aside from when it loads the persistence model at boot:

InfluxDBPersistenceService at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(

Check /var/log/syslog. Every time openHAB tries to write, you should see something logged there (assuming you have the default settings). This is a successful write:

Mar  2 07:18:00 myrpi influxd[23460]: [httpd] - openhab [02/Mar/2019:07:18:00 -0800] "POST /write?consistency=one&db=openhab_db&p=%5BREDACTED%5D&precision=n&rp=rp_1month&u=openhab HTTP/1.1" 204 0 "-" "okhttp/2.4.0" 5d88ad69-3cfe-11e9-95ab-000000000000 1989

Thank you.

Lines with that syntax only shows up when I ran the garbage data python script, aside from that, nothing has been written to the database.

I’m still curious if the Influx dependecy has been installed correctly, I did it through PaperUI, and the .conf file is there with the correct info, but I can’t pick Influx as my default persistence, nor is it listed if I poll the REST api for any current persistence.

Oh for f…

In my .conf file all my detials was commented out. After removing them the API now confirms the persistence is there. And all my data is now available in Grafana.

Apologies for overlooking this simple mistake for so long. I feel ashamed.