vincentwolsink / home_assistant_enphase_envoy_installer

This is a HACS custom integration for Enphase Envoys with firmware version 7 and up.
Apache License 2.0
54 stars 10 forks source link

Use total-consumtion which is calculated consumption for streaming values #35

Closed vincentwolsink closed 12 months ago

vincentwolsink commented 12 months ago

For the non-streaming endpoint we use total-consumption values, which are the values after Envoy did calculations. To keep the streaming endpoint values equal we should use them here too.

vincentwolsink commented 12 months ago

FYI @mnederlof

mnederlof commented 12 months ago

i for one do not have consumption ct installed, so in my opinion the consumption counter in HA should reflect the actual reading value for the installed CT and not the calculated value (or it should be added as different entity 😇 )

Or better yet, maybe we should think about creating a 'device' for every CT that is installed per phase... (though, i'm doubting if that would make sense somehow)

{
    "production": [{
        "type": "inverters",
        "activeCount": 14,
        "readingTime": 1689101742,
        "wNow": 70,
        "whLifetime": 793810
    }, {
        "type": "eim",
        "activeCount": 1,
        "measurementType": "production",
        "readingTime": 1689101754,
        "wNow": 66.759,
        "whLifetime": 1777301.947,
        "varhLeadLifetime": 0.042,
        "varhLagLifetime": 363711.175,
        "vahLifetime": 1958506.263,
        "rmsCurrent": 1.082,
        "rmsVoltage": 224.649,
        "reactPwr": 214.686,
        "apprntPwr": 244.174,
        "pwrFactor": 0.22,
        "whToday": 29312.947,
        "whLastSevenDays": 200553.947,
        "vahToday": 31431.263,
        "varhLeadToday": 0.042,
        "varhLagToday": 5088.175,
        "lines": [{
            "wNow": 66.759,
            "whLifetime": 1777301.947,
            "varhLeadLifetime": 0.042,
            "varhLagLifetime": 363711.175,
            "vahLifetime": 1958506.263,
            "rmsCurrent": 1.082,
            "rmsVoltage": 224.649,
            "reactPwr": 214.686,
            "apprntPwr": 244.174,
            "pwrFactor": 0.22,
            "whToday": 29312.947,
            "whLastSevenDays": 200553.947,
            "vahToday": 31431.263,
            "varhLeadToday": 0.042,
            "varhLagToday": 5088.175
        }]
    }],
    "consumption": [{
        "type": "eim",
        "activeCount": 0,
        "measurementType": "total-consumption",
        "readingTime": 1689101754,
        "wNow": 66.759,
        "whLifetime": 1777301.947,
        "varhLeadLifetime": -0.042,
        "varhLagLifetime": -363711.175,
        "vahLifetime": 0.0,
        "rmsCurrent": 1.082,
        "rmsVoltage": 224.447,
        "reactPwr": 214.686,
        "apprntPwr": 242.768,
        "pwrFactor": 0.27,
        "whToday": 1777301.947,
        "whLastSevenDays": 1777301.947,
        "vahToday": 0.0,
        "varhLeadToday": 0.0,
        "varhLagToday": 0.0,
        "lines": [{
            "wNow": 66.759,
            "whLifetime": 1777301.947,
            "varhLeadLifetime": -0.042,
            "varhLagLifetime": -363711.175,
            "vahLifetime": 0.0,
            "rmsCurrent": 1.082,
            "rmsVoltage": 224.447,
            "reactPwr": 214.686,
            "apprntPwr": 242.768,
            "pwrFactor": 0.27,
            "whToday": 1777301.947,
            "whLastSevenDays": 1777301.947,
            "vahToday": 0.0,
            "varhLeadToday": 0.0,
            "varhLagToday": 0.0
        }]
    }, {
        "type": "eim",
        "activeCount": 0,
        "measurementType": "net-consumption",
        "readingTime": 1689101754,
        "wNow": -0.0,
        "whLifetime": 0.0,
        "varhLeadLifetime": 0.0,
        "varhLagLifetime": 0.0,
        "vahLifetime": 0.0,
        "rmsCurrent": -0.0,
        "rmsVoltage": 224.447,
        "reactPwr": -0.0,
        "apprntPwr": -0.0,
        "pwrFactor": -1.0,
        "whToday": 0,
        "whLastSevenDays": 0,
        "vahToday": 0,
        "varhLeadToday": 0,
        "varhLagToday": 0,
        "lines": [{
            "wNow": -0.0,
            "whLifetime": 0.0,
            "varhLeadLifetime": 0.0,
            "varhLagLifetime": 0.0,
            "vahLifetime": 0.0,
            "rmsCurrent": -0.0,
            "rmsVoltage": 224.447,
            "reactPwr": -0.0,
            "apprntPwr": -0.0,
            "pwrFactor": -1.0,
            "whToday": 0,
            "whLastSevenDays": 0,
            "vahToday": 0,
            "varhLeadToday": 0,
            "varhLagToday": 0
        }]
    }],
    "storage": [{
        "type": "acb",
        "activeCount": 0,
        "readingTime": 0,
        "wNow": 0,
        "whNow": 0,
        "state": "idle"
    }]
}

(example of my production.json?details=1 output)

mnederlof commented 12 months ago

And here is some output from the /stream/meter endpoint (the realtime data url)

data: {"production":{"ph-a":{"p":126.703,"q":221.807,"s":281.032,"v":228.535,"i":1.228,"pf":0.44,"f":50.0},"ph-b":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0},"ph-c":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0}},"net-consumption":{"ph-a":{"p":-0.0,"q":-0.0,"s":-0.0,"v":228.343,"i":-0.0,"pf":-1.0,"f":50.0},"ph-b":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0},"ph-c":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0}},"total-consumption":{"ph-a":{"p":126.703,"q":221.807,"s":280.346,"v":228.343,"i":1.228,"pf":0.45,"f":50.0},"ph-b":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0},"ph-c":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0}}}

data: {"production":{"ph-a":{"p":126.349,"q":222.902,"s":281.895,"v":228.601,"i":1.238,"pf":0.53,"f":50.0},"ph-b":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0},"ph-c":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0}},"net-consumption":{"ph-a":{"p":-0.0,"q":-0.0,"s":-0.0,"v":228.4,"i":-0.0,"pf":-1.0,"f":50.0},"ph-b":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0},"ph-c":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0}},"total-consumption":{"ph-a":{"p":126.349,"q":222.902,"s":282.656,"v":228.4,"i":1.238,"pf":0.45,"f":50.0},"ph-b":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0},"ph-c":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0}}}

data: {"production":{"ph-a":{"p":127.165,"q":222.695,"s":283.468,"v":228.713,"i":1.244,"pf":0.42,"f":50.0},"ph-b":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0},"ph-c":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0}},"net-consumption":{"ph-a":{"p":-0.0,"q":-0.0,"s":-0.0,"v":228.52,"i":-0.0,"pf":-1.0,"f":50.0},"ph-b":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0},"ph-c":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0}},"total-consumption":{"ph-a":{"p":127.165,"q":222.695,"s":284.272,"v":228.52,"i":1.244,"pf":0.45,"f":50.0},"ph-b":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0},"ph-c":{"p":0.0,"q":0.0,"s":0.0,"v":0.0,"i":0.0,"pf":0.0,"f":0.0}}}
mnederlof commented 12 months ago

So yeah, i'm fine if you were to change it to keep it backwards compatible.. (since i do not have consumption CT installed, i did not notice it..)