[SOLVED] Graphing Power from Neurio Power Monitoring Device - Need to Subtract Metrics

  • Platform information:
    • Hardware: Raspberry Pi 2
    • OS: openHABian 2.3.0
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: 2.3.0

Hello, new openHABian user here.

I have my system mostly working. I have a Neurio power monitor Neurio which has four CTs: two for Phase A and B and two more which I use for my home AC and my garage AC units.

I currently have all the data in inFluxDB and graphs in Grafana.

What I want to add is a graph which shows my net power consumption MINUS the AC units. I can think of two approaches:

  1. Use math somehow in the Grafana metric definition. I can’t figure out how to subtract when the metrics are in separate tables (i.e. FROM clause is different)
  2. Create a rule which will do the math and then store another metric in the database.

Has anyone solved this problem before? Seems pretty common. Right now I don’t understand the Rules syntax well enough to write it myself. I’m hoping for an example. I know that this method would incur more storage in the DB but I really don’t think Grafana can do it.

Once I get this working I will write up my solution notes and post in the right section.

For now, here are notes on how I got Neurio working, via HTTP binding with JSONPATH transform. The Neurio device has a local API that returns a JSON string with all the CT power & voltage details, updated every second.

openhab2-conf/services/http.cfg:

neurioCache.url=http://10.1.1.23/current-sample
neurioCache.updateInterval=1000

openhab2-conf/items/neurio.items

Group gNeurio "Power" <energy>

Number Power_Consumption "Value: [%.1f W]" { http="<[neurioCache:1000:JSONPATH($..channels[?(@.type=='CONSUMPTION')].p_W)]" }
Number AC_House_Consumption "Value: [%.1f W]" { http="<[neurioCache:1000:JSONPATH($..channels[?(@.label=='AC House')].p_W)]" }
Number AC_Garage_Consumption "Value: [%.1f W]" { http="<[neurioCache:1000:JSONPATH($..channels[?(@.label=='AC Garage')].p_W)]" }

Thanks for any advice!

-Nathan

Add an item:

Number Power_WithoutAC "Value: [%.1f W]"

Add your existing items to the group:

Number Power_Consumption "Value: [%.1f W]" (gNeurio) { http="<[neurioCache:1000:JSONPATH($..channels[?(@.type=='CONSUMPTION')].p_W)]" }
Number AC_House_Consumption "Value: [%.1f W]" (gNeurio) { http="<[neurioCache:1000:JSONPATH($..channels[?(@.label=='AC House')].p_W)]" }
Number AC_Garage_Consumption "Value: [%.1f W]" (gNeurio) { http="<[neurioCache:1000:JSONPATH($..channels[?(@.label=='AC Garage')].p_W)]" }

And a rule:

rule "Calculate Power without AC"
when
    Member of gNeurio changed
then
    val power = Power_Consumption.state as Number
    val house = AC_House_Consumption.state as Number
    val garage = AC_Garage_Consumption.state as Number
    Power_WithoutAC.postUpdate(power - house - garage)
end

Hey, thanks for your help! That got me a lot further. Can you comment on this error I got for the rules?

2018-07-09 23:12:37.189 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'neurio.rules' has errors, therefore ignoring it: [3,5]: no viable alternative at input 'member'

What version of openHAB are you running?
The member of trigger is new to OH 2.3
If you are stil using 2.2 then your trigger will be:

rule "Calculate Power without AC"
when
    Item Power_Consumption changed or
    Item AC_House_Consumption changed or
    Item AC_Garage_Consumption changed
then
    ....

I’m using OH 2.3.0.

I fixed it. I guess the rules keywords are case sensitive. I changed your “member of” to “Member of” and it started working.

Reference: https://community.openhab.org/t/design-pattern-working-with-groups-in-rules/20512

Yes silly typo.
Glad it works

1 Like