vk2him / Enphase-Envoy-mqtt-json

Takes real time stream from Enphase Envoy and publishes to mqtt broker
MIT License
58 stars 25 forks source link

Doesn’t work on Envoy 7.x.x firmware #5

Closed immesys closed 11 months ago

immesys commented 3 years ago

I am getting 401 Authorization Required when the requests gets made to the stream endpoint.

I can reproduce with curl as well (installer password is generated using envoy serial number in the script you provided):

Doing this

curl --insecure --digest --user installer:123456 https://192.168.1.115/stream/meter

Gives me back this:


<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>Redirecting to <a id='link' href=''></a></center>
<script>
const redirect_url = window.location.protocol + '//' + window.location.host + '/home';
function redirect() { window.location.href = redirect_url; }
window.onload = function() {
    const link = document.getElementById('link');
    link.href = redirect_url;
    link.text = redirect_url;
    setTimeout(redirect, 500);
}
</script>
</body>
</html>

My envoy is running firmware D7.0.66 (ddd0d7).

Is your envoy running the same firmware, but it works? Do you not have issues with getting redirected to HTTPS and having a self-signed certificate cause issues? I noticed you have modified your code recently, so I assumed you are still using this code successfully.

vk2him commented 3 years ago

My envoy gives that error when trying to connect to https - I connect using http only and it doesn't redirect to https. My Envoy details: Envoy-S-Metered-EU Software Version 5.0.55

I stumbled across this thread recently while programming this code - is this what you're seeing?

Mine is working fine - I modded the code recently for error logging as a user had connectivity issues via wifi.

https://community.enphase.com/s/question/0D53m00006ySLuR/unimpressed-with-loss-of-local-api-connectivity-to-envoys

vk2him commented 3 years ago

From the above thread - a few comments are:

"The internal API that everyone has lost access to is - http://x.x.x.x/api/v1/production

As mentioned it now expects a token or Enphase credentials, and forces to https.

7.x.x uses new authentication method and is installed on installation with Ensemble Devices"

So it sounds like you are affected by this - 7.x.x can't use this code unfortunately.

immesys commented 3 years ago

Ah..

Well. That's unfortunate. That is what I am seeing.

I'm doing my own digging around how to get things to work with the new envoy firmware, I'll let you know if I find out a way to get this working again.

Feel free to close this issue, but you may want to leave it open in case others have the same problem

vk2him commented 3 years ago

Ok thanks, yes please advise if you find anything. I’ve renamed this issue to better describe the issue

immesys commented 2 years ago

@vk2him here is a writeup of my findings, that I wrote for a different scraper project: https://github.com/dlmcpaul/EnphaseCollector/issues/22#issuecomment-973656321

vk2him commented 2 years ago

@immesys - Thanks for that Michael - that's really helpful. The other day my Envoy was upgraded without my approval by Enphase - I'm now on 7.x.x and the integration broke. I was able to view the steam in a browser by creating a token, however the stream only outputs every 30-40 seconds - it seems to send a page, then wait 30-40 seconds before dumping another page. Maybe you could assist please - can you get your token then visit https://envoy.local/stream/meter and advise if you see the same 30-40 second delay?

immesys commented 2 years ago

I did actually see the same behavior when first trying out the stream/meter endpoint. I thought maybe it was a bug on my side with line buffering or something like that. Guess that's new then? I haven't found a way around that, I just focused on the production.json endpoint for now. Let me know if you find out how to fix that, it'd be neat to have more real-time data

vk2him commented 2 years ago

Yeah, I've tried a few browsers on a few machines - with the same page at a time output. It might be something "they" have to fix ....

vk2him commented 2 years ago

Update - I am still waiting for Enphase to fix the 30+second delay with the https://envoy.local/stream/meter json stream. They have released a token system that negates the need for the installer password, however that method doesn't currently work for the https://envoy.local/stream/meter stream.

vk2him commented 2 years ago

Update - 7.x.x firmware is still a hot mess - most API URLs fail with 504 errors. In desperation I contacted Enphase Support via telephone and requested they downgrade my Envoy to version 5.x.x ... after placing me on hold for a few minutes the operator confirmed she could do this and went ahead and did so. I also requested that i remain on 5.x.x until I specifically requested an upgrade - again she confirmed my Envoy will remain at 5.x.x. My script is now running again perfectly.

parallelsys commented 2 years ago

@vk2him Do you need somebody willing to test and debug?

vk2him commented 2 years ago

@parallelsys - I'm not sure how to get 7.x.x working although there's now a few examples available of how to pass the required credentials, but I haven't investigated further. You're welcome to fork and test - the main program shouldn't need much modification, it's just the initial and ongoing authentication to get connected. Good luck! Cheers

parallelsys commented 2 years ago

I'll give it a go.

del13r commented 2 years ago

I did some experimenting with cURL and found how to generate the JSON Web Token (JWT) by first obtaining a session ID. 2 step process as follows.

Step 1 Login and generate session_id via cURL (replace my@emailaddress.com and MyPassword)

curl -s https://enlighten.enphaseenergy.com/login/login.json \
-d 'user[email]=my@emailaddress.com&user[password]=MyPassword' \
| jq -r '.session_id'

Results

32alphanumericcharacterSession_ID

Note, session ID's are transient (lasting only for a short time; impermanent) so it is always advisable to do step 1 to refresh your Session ID before trying step 2.

Step 2

cURL command that generates the JSON Web Token (JWT) using the session ID from Step 1. (replace myserialnumber and 32alphanumericcharacterSession_IDFromStep1)

curl -s 'https://enlighten.enphaseenergy.com/entrez-auth-token?serial_num=myserialnumber' \
  -H 'cookie: _enlighten_4_session=32alphanumericcharacterSession_IDFromStep1' \
| jq -r '.token'

Results

ThisIsYourJsonWebToken_Stringof408Characters

This JSON Web Token (JWT) lasts a year.

parallelsys commented 2 years ago

Well done @del13r

eleventhaus commented 2 years ago

Update - 7.x.x firmware is still a hot mess - most API URLs fail with 504 errors. In desperation I contacted Enphase Support via telephone and requested they downgrade my Envoy to version 5.x.x ... after placing me on hold for a few minutes the operator confirmed she could do this and went ahead and did so. I also requested that i remain on 5.x.x until I specifically requested an upgrade - again she confirmed my Envoy will remain at 5.x.x. My script is now running again perfectly.

What firmware did she downgrade you to and do you recommend downgrading? Have there been any issues since? I'm debating whether I should also downgrade.

vk2him commented 2 years ago

I was put back to D5.0.62 (5e57a9) and I have had zero issues since. My understanding is that V7 is ONLY needed if you have batteries ...

eleventhaus commented 2 years ago

I was put back to D5.0.62 (5e57a9) and I have had zero issues since. My understanding is that V7 is ONLY needed if you have batteries ...

I have batteries :(

parallelsys commented 1 year ago

It seems that there is a working version

HA-TB303 commented 1 year ago

Any chance you will modify this for firmware v7.x ? Check: https://github.com/posixx/home_assistant_custom_envoy

vk2him commented 1 year ago

I'm not planning to modify for v7.x for a few reasons:

  1. I don't have v7.x - they "upgraded" my envoy to v7.x a while ago without my permission and I had to ask them to revert me permanently back to v5.x - see next point
  2. For the week or so I had v7.x, I used the method described in your link and found that most v5 data endpoints don't work, or they work with issues. I was unable to get a 1 second stream from v7.x and it seems the person in the link you gave is only able to provide 30 second updates. There's a long thread on the Enphase forum group about this - they promised over 18 month ago to fix those issues but never did and haven't provided any timeline of if/when it will ever work
  3. That same thread discusses the fact that Enphase are effectively locking us out of our systems by using the Auth tokens - the tokens need to be renewed and if Enphase go out of business then we will never have access. Enphase said 18 months ago they will issue lifetime tokens, but they haven't said any more since then despite hundreds of people asking for updates
  4. I'm not planning to ever update to v7, even if they fix it and issue lifetime tokens. V5 does all I need, I don't have batteries
  5. People are welcome to fork this repo and get it working on v7 if they want - but they won't be able to get 1 second updates until Enphase fix the firmare. Cheers
Matthew1471 commented 1 year ago
5. People are welcome to fork this repo and get it working on v7 if they want - but they won't be able to get 1 second updates until Enphase fix the firmare.

If someone else wants to fork but needs either a library to do the auth or want documentation these links may help:

Example: https://github.com/Matthew1471/Enphase-API/blob/main/Python/examples/gateway_database_meters.py

API Documentation: https://github.com/Matthew1471/Enphase-API/blob/main/Documentation/IQ%20Gateway%20API/Stream/Meter.adoc

niggles1973 commented 1 year ago

had my envoy updated to V7.6.175 not happy ... anyway; I generated a token and have this curl -f -k -H "Accept: application/json" -H "Authorization: Bearer ALongToken -X GET https://envoy.local/ivp/meters/readings returning 1 second readings so I think @vk2him concerns about update intervals has been addressed (I agree with everything else though ..) I have no idea how to fork in GitHub and have never used python so say a little prayer for me as I dabble in the code

networkerict commented 1 year ago

Mine was updated to the same D7 release last night as well.... sigh.... If anyone with python knowledge is able to fork this release and make it work for D7 firmware.... PLEASE DO SO!

niggles1973 commented 1 year ago

OK, I'm a little bit further but two steps backwards

while curl -f -k -H "Accept: application/json" -H "Authorization: Bearer ALongToken -X GET https://envoy.local/ivp/meters/readings does return 1 second updates on each seperate GET request; its not a stream

curl -f -k -H "Accept: application/json" -H "Authorization: Bearer ALongToken" -X GET https://192.168.1.8/stream/meter
returns 401/Forbidden

forums are saying that V7.6.175 has a "bug" and that /steam/meter is only available to an installer token with "oh we will fix that in the next release" - the code as it is needs the the stream version (unless its rewritten to query repeatedly)

del13r commented 1 year ago

Yep, on v5, you still need installer:password to access http://envoy.local/stream/meter

Here is the curl command I am using to verify my v5 firmware stream from my home assistant terminal

curl --digest -u installer:PASSWORD -v http://envoy.local/stream/meter/

Here is some truncated output for 2 seconds worth of data:

data: {"production":{"ph-a":{"p":2631.228,"q":314.365,"s":2649.303,"v":232.592,"i":11.359,"pf":0.99,"f":50.06},"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":916.304,"q":-751.004,"s":1251.341,"v":232.812,"i":5.364,"pf":0.79,"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":3547.532,"q":-1065.37,"s":3891.513,"v":232.702,"i":16.723,"pf":0.91,"f":50.03},"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}}}

vk2him commented 1 year ago

OK, I'm a little bit further but two steps backwards

while curl -f -k -H "Accept: application/json" -H "Authorization: Bearer ALongToken -X GET https://envoy.local/ivp/meters/readings does return 1 second updates on each seperate GET request; its not a stream

curl -f -k -H "Accept: application/json" -H "Authorization: Bearer ALongToken" -X GET https://192.168.1.8/stream/meter returns 401/Forbidden

forums are saying that V7.6.175 has a "bug" and that /steam/meter is only available to an installer token with "oh we will fix that in the next release" - the code as it is needs the the stream version (unless its rewritten to query repeatedly)

Your methodology is sound - before you can write the code you need to verify the commands will work from terminal. You're seeing a variation on the "hot mess' post I made above 15 months ago - one step forward, twosteps back indeed.

Wishing you luck - unless you need 7.0 for batteries, you can always request Enphase permanently downgraded your firmware to 5.xx as I did, then this issue goes away. Cheers

niggles1973 commented 1 year ago

I’m getting a 5P/system controller 3 in a couple of Months so rolling back is just going to postpone 7.x - May as well attack it now

niggles1973 commented 1 year ago

OK, I've got a good enough workaround (but not pretty when compared to the stream solution) - uses the equivalent of curl -f -k -H "Accept: application/json" -H "Authorization: Bearer ALongToken -X GET https://envoy.local/ivp/meters/readings
in configuration.yaml with a rest template

rest:
  - headers:
      Authorization: Bearer ***TheToken****
    verify_ssl: False
    scan_interval: 1
    resource: https://envoy.local/ivp/meters/readings    
    sensor:
      - name: "the_total_production"
        unique_id: the_total_production
        value_template: '{% if is_state("sun.sun", "below_horizon")%}0{%else%} {{ value_json[0].activePower | float }}{%endif%}'
        device_class: power
        unit_of_measurement: W
        state_class: measurement
      - name: "the_total_consumption"
        unique_id: the_total_consumption
        value_template: '{% if is_state("sun.sun", "below_horizon")%}value_json[1].activePower{%else%}{{ value_json[1].activePower - value_json[0].activePower  | float }}{%endif%}'
        device_class: power
        unit_of_measurement: W
vk2him commented 1 year ago

Interesting- what data does https://envoy.local/ivp/meters/readings provide, can you dump the output here?

niggles1973 commented 1 year ago

readings gives the most relevant metrics via a single api call that be used to duplicate the enphase integration - but you have to hit the envoy.local every second; I occassionally get to many sessions - I'm trying to work out what the rate limit is (or I'm just hitting it too hard while debugging from multiple IP addresses) - i really have no idea what I'm doing - making it up as I go along - I didn't even know how to decode JSON 24 hours ago

[
    {
        "eid": 704643328,
        "timestamp": 1688747134,
        "actEnergyDlvd": 53457940.250,
        "actEnergyRcvd": 102882.138,
        "apparentEnergy": 64452408.104,
        "reactEnergyLagg": 11447952.939,
        "reactEnergyLead": 1570264.360,
        "instantaneousDemand": -15.184,
        "activePower": -15.184,
        "apparentPower": 1433.530,
        "reactivePower": 1419.968,
        "pwrFactor": -0.010,
        "voltage": 716.121,
        "current": 6.006,
        "freq": 50.000,
        "channels": [
            {
                "eid": 1778385169,
                "timestamp": 1688747134,
                "actEnergyDlvd": 18007780.121,
                "actEnergyRcvd": 32493.281,
                "apparentEnergy": 21780901.616,
                "reactEnergyLagg": 3956061.302,
                "reactEnergyLead": 330755.947,
                "instantaneousDemand": -4.958,
                "activePower": -4.958,
                "apparentPower": 496.173,
                "reactivePower": 490.175,
                "pwrFactor": -0.015,
                "voltage": 237.923,
                "current": 2.086,
                "freq": 50.000
            },
            {
                "eid": 1778385170,
                "timestamp": 1688747134,
                "actEnergyDlvd": 17875774.043,
                "actEnergyRcvd": 12976.762,
                "apparentEnergy": 21539705.521,
                "reactEnergyLagg": 3804013.582,
                "reactEnergyLead": 599499.184,
                "instantaneousDemand": -2.110,
                "activePower": -2.110,
                "apparentPower": 476.495,
                "reactivePower": 472.980,
                "pwrFactor": 0.000,
                "voltage": 239.413,
                "current": 1.990,
                "freq": 50.000
            },
            {
                "eid": 1778385171,
                "timestamp": 1688747134,
                "actEnergyDlvd": 17574386.086,
                "actEnergyRcvd": 57412.095,
                "apparentEnergy": 21131800.966,
                "reactEnergyLagg": 3687878.056,
                "reactEnergyLead": 640009.230,
                "instantaneousDemand": -8.115,
                "activePower": -8.115,
                "apparentPower": 460.863,
                "reactivePower": 456.814,
                "pwrFactor": -0.016,
                "voltage": 238.785,
                "current": 1.929,
                "freq": 50.000
            }
        ]
    },
    {
        "eid": 704643584,
        "timestamp": 1688747134,
        "actEnergyDlvd": 22984313.125,
        "actEnergyRcvd": 36889465.180,
        "apparentEnergy": 75005727.629,
        "reactEnergyLagg": 690026.580,
        "reactEnergyLead": 25946784.470,
        "instantaneousDemand": 3958.407,
        "activePower": 3958.407,
        "apparentPower": 5209.561,
        "reactivePower": -2945.972,
        "pwrFactor": 0.760,
        "voltage": 716.550,
        "current": 21.809,
        "freq": 50.125,
        "channels": [
            {
                "eid": 1778385425,
                "timestamp": 1688747134,
                "actEnergyDlvd": 8775639.959,
                "actEnergyRcvd": 12568251.034,
                "apparentEnergy": 25610630.935,
                "reactEnergyLagg": 199715.930,
                "reactEnergyLead": 7406932.417,
                "instantaneousDemand": 1361.722,
                "activePower": 1361.722,
                "apparentPower": 1694.904,
                "reactivePower": -832.508,
                "pwrFactor": 0.806,
                "voltage": 238.052,
                "current": 7.118,
                "freq": 50.125
            },
            {
                "eid": 1778385426,
                "timestamp": 1688747134,
                "actEnergyDlvd": 7471792.993,
                "actEnergyRcvd": 11470877.359,
                "apparentEnergy": 24964774.206,
                "reactEnergyLagg": 260425.150,
                "reactEnergyLead": 9708022.585,
                "instantaneousDemand": 1205.898,
                "activePower": 1205.898,
                "apparentPower": 1763.992,
                "reactivePower": -1181.869,
                "pwrFactor": 0.681,
                "voltage": 239.399,
                "current": 7.370,
                "freq": 50.125
            },
            {
                "eid": 1778385427,
                "timestamp": 1688747134,
                "actEnergyDlvd": 6736880.174,
                "actEnergyRcvd": 12850336.786,
                "apparentEnergy": 24430322.489,
                "reactEnergyLagg": 229885.501,
                "reactEnergyLead": 8831829.467,
                "instantaneousDemand": 1390.786,
                "activePower": 1390.786,
                "apparentPower": 1750.664,
                "reactivePower": -931.595,
                "pwrFactor": 0.794,
                "voltage": 239.099,
                "current": 7.321,
                "freq": 50.125
            }
        ]
    }
vk2him commented 1 year ago

Thanks for that - looks like the similar data from /stream but in a different format. The downside of course is that it's not a stream so you need to send a request and hammering the envoy every second may cause an overflow. Did you just post a question on the Enphase Community as Barling_114 asked a similar question? It's a shame the /stream feed is still broken on V7 - it didn't work nearly two years ago when I had V7 temporarily ...

niggles1973 commented 1 year ago

yeah I'm working both angles ... (this and trying to get /stream back accessible by the owner token)

helderfmf commented 1 year ago

I have done it, see here https://github.com/helderfmf/Enphase-Envoy-mqtt-json. Ignore the Freeds stuff, I'm publishing to 2 different topics over mqtt. Need to implement the automatic generation of the token on startup, and error handling, as there is none at the moment. But it works. Also the sensors on the HA changed:

mqtt:
  ###############
  #   SENSOR    #
  ###############
  sensor:
    ###############
    #    Envoy    #
    ###############
    - name: envoy mqtt consumption
      state_topic: "envoy/json"
      value_template: '{{ value_json["consumption"][0]["wNow"] | round(0) | int(0)}}'
      unique_id: envoy_mqtt_consumption
      qos: 0
      unit_of_measurement: "W"
      state_class: measurement
      device_class: power
    - name: envoy mqtt voltage
      state_topic: "envoy/json"
      value_template: '{{ value_json["consumption"][0]["rmsVoltage"] | round(0) | int(0)}}'
      unique_id: envoy_mqtt_voltage
      qos: 0
      unit_of_measurement: "V"
      state_class: measurement
      device_class: voltage
    - name: envoy mqtt current
      state_topic: "envoy/json"
      value_template: '{{ value_json["consumption"][0]["rmsCurrent"] | round(2)}}'
      unique_id: envoy_mqtt_current
      qos: 0
      unit_of_measurement: "A"
      state_class: measurement
      device_class: current
    - name: envoy mqtt power factor
      state_topic: "envoy/json"
      value_template: '{{ value_json["consumption"][0]["pwrFactor"] | round(2)}}'
      unique_id: envoy_mqtt_power_factor
      qos: 0
      unit_of_measurement: "%"
      state_class: measurement
      device_class: power_factor
vk2him commented 1 year ago

I have done it, see here https://github.com/helderfmf/Enphase-Envoy-mqtt-json. Ignore the Freeds stuff, I'm publishing to 2 different topics over mqtt. Need to implement the automatic generation of the token on startup, and error handling, as there is none at the moment. But it works. ```

Hey @helderfmf , well done! I took a look at your code yesterday and was wondering how you were going with it.

I see you're using production.json - what data does that show on V7 and is it a stream with one second resolution similar to /stream/meter?

On v5 production.json displays the following but it's not a stream so you have you call it once a second (and I'm not sure if that may overload the Envoy?)

{"production":[{"type":"inverters","activeCount":18,"readingTime":1688987548,"wNow":0,"whLifetime":9973564},{"type":"eim","activeCount":1,"measurementType":"production","readingTime":1688988016,"wNow":0.0,"whLifetime":9654608.448,"varhLeadLifetime":1274839.461,"varhLagLifetime":1609377.931,"vahLifetime":11282217.87,"rmsCurrent":0.922,"rmsVoltage":242.477,"reactPwr":223.591,"apprntPwr":223.591,"pwrFactor":0.0,"whToday":18181.448,"whLastSevenDays":110997.448,"vahToday":21164.87,"varhLeadToday":2306.461,"varhLagToday":2997.931}],"consumption":[{"type":"eim","activeCount":1,"measurementType":"total-consumption","readingTime":1688988016,"wNow":894.924,"whLifetime":10749873.218,"varhLeadLifetime":6245444.46,"varhLagLifetime":1853514.342,"vahLifetime":16601486.731,"rmsCurrent":5.985,"rmsVoltage":242.582,"reactPwr":-849.341,"apprntPwr":1451.76,"pwrFactor":0.62,"whToday":17648.218,"whLastSevenDays":166009.218,"vahToday":25598.731,"varhLeadToday":12518.46,"varhLagToday":3025.342},{"type":"eim","activeCount":1,"measurementType":"net-consumption","readingTime":1688988016,"wNow":894.924,"whLifetime":7354081.586,"varhLeadLifetime":4970605.0,"varhLagLifetime":244136.411,"vahLifetime":16601486.731,"rmsCurrent":5.063,"rmsVoltage":242.686,"reactPwr":-625.75,"apprntPwr":1199.172,"pwrFactor":0.73,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0}],"storage":[{"type":"acb","activeCount":0,"readingTime":0,"wNow":0,"whNow":0,"state":"idle"}]}
helderfmf commented 1 year ago

This is a reading I got just now:

{
    "consumption": [
        {
            "activeCount": 1,
            "apprntPwr": 1232.878,
            "measurementType": "total-consumption",
            "pwrFactor": -0.01,
            "reactPwr": 10.129,
            "readingTime": 1688988057,
            "rmsCurrent": -5.199,
            "rmsVoltage": 237.148,
            "type": "eim",
            "vahLifetime": 8290045.344,
            "vahToday": 6501.344,
            "varhLagLifetime": 112923.965,
            "varhLagToday": 9.965,
            "varhLeadLifetime": 2276016.539,
            "varhLeadToday": 2979.539,
            "whLastSevenDays": 20581.0,
            "whLifetime": 3882261.863,
            "whToday": 1242.0,
            "wNow": -18.304
        },
        {
            "activeCount": 1,
            "apprntPwr": 1232.878,
            "measurementType": "net-consumption",
            "pwrFactor": -0.01,
            "reactPwr": 0.0,
            "readingTime": 1688988057,
            "rmsCurrent": -5.199,
            "rmsVoltage": 237.148,
            "type": "eim",
            "vahLifetime": 8227015.712,
            "vahToday": 0,
            "varhLagLifetime": 112142.171,
            "varhLagToday": 0,
            "varhLeadLifetime": 2276012.831,
            "varhLeadToday": 0,
            "whLastSevenDays": 0,
            "whLifetime": 3882261.8,
            "whToday": 0,
            "wNow": -18.304
        }
    ],
    "production": [
        {
            "activeCount": 0,
            "readingTime": 0,
            "type": "inverters",
            "whLifetime": 0,
            "wNow": 0
        },
        {
            "activeCount": 1,
            "apprntPwr": 0.0,
            "measurementType": "production",
            "pwrFactor": 0.0,
            "reactPwr": -0.0,
            "readingTime": 1688988057,
            "rmsCurrent": -0.0,
            "rmsVoltage": 237.23,
            "type": "eim",
            "vahLifetime": 63029.632,
            "vahToday": 69.632,
            "varhLagLifetime": 781.794,
            "varhLagToday": 0.794,
            "varhLeadLifetime": 3.709,
            "varhLeadToday": 0.709,
            "whLastSevenDays": 0.063,
            "whLifetime": 0.063,
            "whToday": 0.063,
            "wNow": 0.0
        }
    ],
    "storage": [
        {
            "activeCount": 0,
            "readingTime": 0,
            "state": "idle",
            "type": "acb",
            "whNow": 0,
            "wNow": 0
        }
    ]
}

In HA i got a latency of 2-4s between readings.

del13r commented 1 year ago

Give it a try for 24 hours and see how the envoy likes being queried that often. I tried every 5 seconds and saw lengthy times where envoy would not respond at all

niggles1973 commented 1 year ago

Production.Json is too slow to respond and sometimes takes up to 60 seconds or more (I’ve got 84 microinverters so might be my system only) - https://envoy.local/ivp/meters/readings Is consistently 1 second

On Mon, 10 Jul 2023 at 21:47, Helder Ferreira @.***> wrote:

This is a reading I got just now:

{ "consumption": [ { "activeCount": 1, "apprntPwr": 1232.878, "measurementType": "total-consumption", "pwrFactor": -0.01, "reactPwr": 10.129, "readingTime": 1688988057, "rmsCurrent": -5.199, "rmsVoltage": 237.148, "type": "eim", "vahLifetime": 8290045.344, "vahToday": 6501.344, "varhLagLifetime": 112923.965, "varhLagToday": 9.965, "varhLeadLifetime": 2276016.539, "varhLeadToday": 2979.539, "whLastSevenDays": 20581.0, "whLifetime": 3882261.863, "whToday": 1242.0, "wNow": -18.304 }, { "activeCount": 1, "apprntPwr": 1232.878, "measurementType": "net-consumption", "pwrFactor": -0.01, "reactPwr": 0.0, "readingTime": 1688988057, "rmsCurrent": -5.199, "rmsVoltage": 237.148, "type": "eim", "vahLifetime": 8227015.712, "vahToday": 0, "varhLagLifetime": 112142.171, "varhLagToday": 0, "varhLeadLifetime": 2276012.831, "varhLeadToday": 0, "whLastSevenDays": 0, "whLifetime": 3882261.8, "whToday": 0, "wNow": -18.304 } ], "production": [ { "activeCount": 0, "readingTime": 0, "type": "inverters", "whLifetime": 0, "wNow": 0 }, { "activeCount": 1, "apprntPwr": 0.0, "measurementType": "production", "pwrFactor": 0.0, "reactPwr": -0.0, "readingTime": 1688988057, "rmsCurrent": -0.0, "rmsVoltage": 237.23, "type": "eim", "vahLifetime": 63029.632, "vahToday": 69.632, "varhLagLifetime": 781.794, "varhLagToday": 0.794, "varhLeadLifetime": 3.709, "varhLeadToday": 0.709, "whLastSevenDays": 0.063, "whLifetime": 0.063, "whToday": 0.063, "wNow": 0.0 } ], "storage": [ { "activeCount": 0, "readingTime": 0, "state": "idle", "type": "acb", "whNow": 0, "wNow": 0 } ] }

In HA i got a latency of 2-4s between readings.

— Reply to this email directly, view it on GitHub https://github.com/vk2him/Enphase-Envoy-mqtt-json/issues/5#issuecomment-1628803492, or unsubscribe https://github.com/notifications/unsubscribe-auth/AW4FODWGCMHDXJXBOJVN6J3XPPTTNANCNFSM5HQMYXHQ . You are receiving this because you commented.Message ID: @.***>

niggles1973 commented 1 year ago

I’ve been hitting https://envoy.local/ivp/meters/readings Every second for 48 hours now; production.Json was timing out repeatedly in only 12 hours of Testing and was averaging 3 seconds or so. Testing is with the home assistant rest template.

del13r commented 1 year ago

unfortunately i didnt have as good results as you with 5 second polling https://envoy.local/ivp/meters/readings I have found 10 seconds to be much less problematic. graph of dropouts when using 5 second polling:

image

Keep an eye on your logs for anything like this:

Logger: homeassistant.components.rest.data Source: components/rest/data.py:116 Integration: RESTful (documentation, issues) First occurred: July 10, 2023 at 6:39:58 PM (1 occurrences) Last logged: July 10, 2023 at 6:39:58 PM

Timeout while fetching data: https://homeassistant.local/ivp/meters/readings

helderfmf commented 1 year ago

I'm using only as a meter from the grid, my inverter is from Huawei, and the solar installer instead of using some cheaper meter, installed this one that is a overkill for the function it does.

So way less information to compute on each call. Screenshot_2023-07-10-21-28-15-067_io.homeassistant.companion.android.jpg

del13r commented 1 year ago

I'm using only as a meter from the grid So way less information to compute on each call.

I'm glad you could fix your problem, but we need to be considerate of the wider community expectations that may read your posts and expect the same results. This definitely does not fit the typical use case and your solution could potentially be misleading for your average enphase user. You might get a lot of people asking you why it works for you but not for them.

helderfmf commented 1 year ago

Your are using REST, I'm using the python with stream, don't know if it makes a diference. Any way, try this: curl -k -H "Authorization: Bearer YourVeryLongToken" https://envoy.local/ipv/livedata/stream/ -X POST '{"enable": 1}' You should get a response:

{
"sc_stream": "enabled"
}

After that this counters should update, and for me they are quick: curl -k -H "Authorization: Bearer YourVeryLongToken" https://envoy.local/ipv/livedata/status

helderfmf commented 1 year ago

When I say its fast, it is really fast, @del13r can you try it? here is the code:

def scrape_stream():
    n=0
    while True:
        try:
            url = 'https://%s/ivp/livedata/status' % ENVOY_HOST 
            stream = requests.get(url, auth=auth, stream=True, timeout=5, verify=False, headers=headers)
            json_string = stream.json()
            pp.pprint(json_string)
            pp.pprint(time.ctime())
            n=n+1
            pp.pprint('Run %s times' %n)
        except requests.exceptions.RequestException as e:
            print(dt_string, ' Exception fetching stream data: %s' % e)

The output, in 2 seconds 7 replies:

>>> scrape_stream()
{'connection': {'auth_state': 'ok',
                'mqtt_state': 'disconnected',
                'prov_state': 'configured',
                'sc_debug': 'disabled',
                'sc_stream': 'enabled'},
 'counters': {'MqttClient_connect': 14809,
              'MqttClient_connect_Err': 14809,
              'MqttClient_connect_err': 14809,
              'MqttClient_create': 14809,
              'MqttClient_setCallbacks': 14809,
              'SSL_Keys_Create': 14809,
              'main_CfgChanged': 1,
              'main_CfgLoad': 1,
              'rest_Counters': 20,
              'rest_Meters': 23,
              'rest_Status': 3982,
              'rest_Tasks': 1,
              'rest_Test': 2,
              'sc_SendDemandRspCtrl': 1,
              'sc_SendStreamCtrl': 10,
              'sc_hdlDataPub': 11668},
 'dry_contacts': {'': {'dry_contact_id': '',
                       'dry_contact_load_name': '',
                       'dry_contact_status': 3050996,
                       'dry_contact_type': ''}},
 'meters': {'acb_agg_energy': 0,
            'acb_agg_soc': 0,
            'backup_bat_mode': 1,
            'backup_soc': 30,
            'enc_agg_energy': 0,
            'enc_agg_soc': 0,
            'gen_relay_state': 5,
            'generator': {'agg_p_mw': 0,
                          'agg_p_ph_a_mw': 0,
                          'agg_p_ph_b_mw': 0,
                          'agg_p_ph_c_mw': 0,
                          'agg_s_mva': 0,
                          'agg_s_ph_a_mva': 0,
                          'agg_s_ph_b_mva': 0,
                          'agg_s_ph_c_mva': 0},
            'grid': {'agg_p_mw': 98293,
                     'agg_p_ph_a_mw': 98293,
                     'agg_p_ph_b_mw': 0,
                     'agg_p_ph_c_mw': 0,
                     'agg_s_mva': 1217741,
                     'agg_s_ph_a_mva': 1217741,
                     'agg_s_ph_b_mva': 0,
                     'agg_s_ph_c_mva': 0},
            'is_split_phase': 0,
            'last_update': 1689071148,
            'load': {'agg_p_mw': 98293,
                     'agg_p_ph_a_mw': 98293,
                     'agg_p_ph_b_mw': 0,
                     'agg_p_ph_c_mw': 0,
                     'agg_s_mva': 1217741,
                     'agg_s_ph_a_mva': 1217741,
                     'agg_s_ph_b_mva': 0,
                     'agg_s_ph_c_mva': 0},
            'main_relay_state': 1,
            'phase_count': 1,
            'pv': {'agg_p_mw': 0,
                   'agg_p_ph_a_mw': 0,
                   'agg_p_ph_b_mw': 0,
                   'agg_p_ph_c_mw': 0,
                   'agg_s_mva': 0,
                   'agg_s_ph_a_mva': 0,
                   'agg_s_ph_b_mva': 0,
                   'agg_s_ph_c_mva': 0},
            'soc': 0,
            'storage': {'agg_p_mw': 0,
                        'agg_p_ph_a_mw': 0,
                        'agg_p_ph_b_mw': 0,
                        'agg_p_ph_c_mw': 0,
                        'agg_s_mva': 0,
                        'agg_s_ph_a_mva': 0,
                        'agg_s_ph_b_mva': 0,
                        'agg_s_ph_c_mva': 0}},
 'tasks': {'task_id': 0, 'timestamp': 0}}
'Tue Jul 11 11:25:05 2023'
'Run 1 times'
{'connection': {'auth_state': 'ok',
                'mqtt_state': 'disconnected',
                'prov_state': 'configured',
                'sc_debug': 'disabled',
                'sc_stream': 'enabled'},
 'counters': {'MqttClient_connect': 14809,
              'MqttClient_connect_Err': 14809,
              'MqttClient_connect_err': 14809,
              'MqttClient_create': 14809,
              'MqttClient_setCallbacks': 14809,
              'SSL_Keys_Create': 14809,
              'main_CfgChanged': 1,
              'main_CfgLoad': 1,
              'rest_Counters': 20,
              'rest_Meters': 23,
              'rest_Status': 3983,
              'rest_Tasks': 1,
              'rest_Test': 2,
              'sc_SendDemandRspCtrl': 1,
              'sc_SendStreamCtrl': 10,
              'sc_hdlDataPub': 11669},
 'dry_contacts': {'': {'dry_contact_id': '',
                       'dry_contact_load_name': '',
                       'dry_contact_status': 3050996,
                       'dry_contact_type': ''}},
 'meters': {'acb_agg_energy': 0,
            'acb_agg_soc': 0,
            'backup_bat_mode': 1,
            'backup_soc': 30,
            'enc_agg_energy': 0,
            'enc_agg_soc': 0,
            'gen_relay_state': 5,
            'generator': {'agg_p_mw': 0,
                          'agg_p_ph_a_mw': 0,
                          'agg_p_ph_b_mw': 0,
                          'agg_p_ph_c_mw': 0,
                          'agg_s_mva': 0,
                          'agg_s_ph_a_mva': 0,
                          'agg_s_ph_b_mva': 0,
                          'agg_s_ph_c_mva': 0},
            'grid': {'agg_p_mw': 94520,
                     'agg_p_ph_a_mw': 94520,
                     'agg_p_ph_b_mw': 0,
                     'agg_p_ph_c_mw': 0,
                     'agg_s_mva': 1214225,
                     'agg_s_ph_a_mva': 1214225,
                     'agg_s_ph_b_mva': 0,
                     'agg_s_ph_c_mva': 0},
            'is_split_phase': 0,
            'last_update': 1689071149,
            'load': {'agg_p_mw': 94520,
                     'agg_p_ph_a_mw': 94520,
                     'agg_p_ph_b_mw': 0,
                     'agg_p_ph_c_mw': 0,
                     'agg_s_mva': 1214225,
                     'agg_s_ph_a_mva': 1214225,
                     'agg_s_ph_b_mva': 0,
                     'agg_s_ph_c_mva': 0},
            'main_relay_state': 1,
            'phase_count': 1,
            'pv': {'agg_p_mw': 0,
                   'agg_p_ph_a_mw': 0,
                   'agg_p_ph_b_mw': 0,
                   'agg_p_ph_c_mw': 0,
                   'agg_s_mva': 0,
                   'agg_s_ph_a_mva': 0,
                   'agg_s_ph_b_mva': 0,
                   'agg_s_ph_c_mva': 0},
            'soc': 0,
            'storage': {'agg_p_mw': 0,
                        'agg_p_ph_a_mw': 0,
                        'agg_p_ph_b_mw': 0,
                        'agg_p_ph_c_mw': 0,
                        'agg_s_mva': 0,
                        'agg_s_ph_a_mva': 0,
                        'agg_s_ph_b_mva': 0,
                        'agg_s_ph_c_mva': 0}},
 'tasks': {'task_id': 0, 'timestamp': 0}}
'Tue Jul 11 11:25:05 2023'
'Run 2 times'
{'connection': {'auth_state': 'ok',
                'mqtt_state': 'disconnected',
                'prov_state': 'configured',
                'sc_debug': 'disabled',
                'sc_stream': 'enabled'},
 'counters': {'MqttClient_connect': 14809,
              'MqttClient_connect_Err': 14809,
              'MqttClient_connect_err': 14809,
              'MqttClient_create': 14809,
              'MqttClient_setCallbacks': 14809,
              'SSL_Keys_Create': 14809,
              'main_CfgChanged': 1,
              'main_CfgLoad': 1,
              'rest_Counters': 20,
              'rest_Meters': 23,
              'rest_Status': 3984,
              'rest_Tasks': 1,
              'rest_Test': 2,
              'sc_SendDemandRspCtrl': 1,
              'sc_SendStreamCtrl': 10,
              'sc_hdlDataPub': 11669},
 'dry_contacts': {'': {'dry_contact_id': '',
                       'dry_contact_load_name': '',
                       'dry_contact_status': 3050996,
                       'dry_contact_type': ''}},
 'meters': {'acb_agg_energy': 0,
            'acb_agg_soc': 0,
            'backup_bat_mode': 1,
            'backup_soc': 30,
            'enc_agg_energy': 0,
            'enc_agg_soc': 0,
            'gen_relay_state': 5,
            'generator': {'agg_p_mw': 0,
                          'agg_p_ph_a_mw': 0,
                          'agg_p_ph_b_mw': 0,
                          'agg_p_ph_c_mw': 0,
                          'agg_s_mva': 0,
                          'agg_s_ph_a_mva': 0,
                          'agg_s_ph_b_mva': 0,
                          'agg_s_ph_c_mva': 0},
            'grid': {'agg_p_mw': 94520,
                     'agg_p_ph_a_mw': 94520,
                     'agg_p_ph_b_mw': 0,
                     'agg_p_ph_c_mw': 0,
                     'agg_s_mva': 1214225,
                     'agg_s_ph_a_mva': 1214225,
                     'agg_s_ph_b_mva': 0,
                     'agg_s_ph_c_mva': 0},
            'is_split_phase': 0,
            'last_update': 1689071149,
            'load': {'agg_p_mw': 94520,
                     'agg_p_ph_a_mw': 94520,
                     'agg_p_ph_b_mw': 0,
                     'agg_p_ph_c_mw': 0,
                     'agg_s_mva': 1214225,
                     'agg_s_ph_a_mva': 1214225,
                     'agg_s_ph_b_mva': 0,
                     'agg_s_ph_c_mva': 0},
            'main_relay_state': 1,
            'phase_count': 1,
            'pv': {'agg_p_mw': 0,
                   'agg_p_ph_a_mw': 0,
                   'agg_p_ph_b_mw': 0,
                   'agg_p_ph_c_mw': 0,
                   'agg_s_mva': 0,
                   'agg_s_ph_a_mva': 0,
                   'agg_s_ph_b_mva': 0,
                   'agg_s_ph_c_mva': 0},
            'soc': 0,
            'storage': {'agg_p_mw': 0,
                        'agg_p_ph_a_mw': 0,
                        'agg_p_ph_b_mw': 0,
                        'agg_p_ph_c_mw': 0,
                        'agg_s_mva': 0,
                        'agg_s_ph_a_mva': 0,
                        'agg_s_ph_b_mva': 0,
                        'agg_s_ph_c_mva': 0}},
 'tasks': {'task_id': 0, 'timestamp': 0}}
'Tue Jul 11 11:25:05 2023'
'Run 3 times'
{'connection': {'auth_state': 'ok',
                'mqtt_state': 'disconnected',
                'prov_state': 'configured',
                'sc_debug': 'disabled',
                'sc_stream': 'enabled'},
 'counters': {'MqttClient_connect': 14809,
              'MqttClient_connect_Err': 14809,
              'MqttClient_connect_err': 14809,
              'MqttClient_create': 14809,
              'MqttClient_setCallbacks': 14809,
              'SSL_Keys_Create': 14809,
              'main_CfgChanged': 1,
              'main_CfgLoad': 1,
              'rest_Counters': 20,
              'rest_Meters': 23,
              'rest_Status': 3985,
              'rest_Tasks': 1,
              'rest_Test': 2,
              'sc_SendDemandRspCtrl': 1,
              'sc_SendStreamCtrl': 10,
              'sc_hdlDataPub': 11669},
 'dry_contacts': {'': {'dry_contact_id': '',
                       'dry_contact_load_name': '',
                       'dry_contact_status': 3050996,
                       'dry_contact_type': ''}},
 'meters': {'acb_agg_energy': 0,
            'acb_agg_soc': 0,
            'backup_bat_mode': 1,
            'backup_soc': 30,
            'enc_agg_energy': 0,
            'enc_agg_soc': 0,
            'gen_relay_state': 5,
            'generator': {'agg_p_mw': 0,
                          'agg_p_ph_a_mw': 0,
                          'agg_p_ph_b_mw': 0,
                          'agg_p_ph_c_mw': 0,
                          'agg_s_mva': 0,
                          'agg_s_ph_a_mva': 0,
                          'agg_s_ph_b_mva': 0,
                          'agg_s_ph_c_mva': 0},
            'grid': {'agg_p_mw': 94520,
                     'agg_p_ph_a_mw': 94520,
                     'agg_p_ph_b_mw': 0,
                     'agg_p_ph_c_mw': 0,
                     'agg_s_mva': 1214225,
                     'agg_s_ph_a_mva': 1214225,
                     'agg_s_ph_b_mva': 0,
                     'agg_s_ph_c_mva': 0},
            'is_split_phase': 0,
            'last_update': 1689071149,
            'load': {'agg_p_mw': 94520,
                     'agg_p_ph_a_mw': 94520,
                     'agg_p_ph_b_mw': 0,
                     'agg_p_ph_c_mw': 0,
                     'agg_s_mva': 1214225,
                     'agg_s_ph_a_mva': 1214225,
                     'agg_s_ph_b_mva': 0,
                     'agg_s_ph_c_mva': 0},
            'main_relay_state': 1,
            'phase_count': 1,
            'pv': {'agg_p_mw': 0,
                   'agg_p_ph_a_mw': 0,
                   'agg_p_ph_b_mw': 0,
                   'agg_p_ph_c_mw': 0,
                   'agg_s_mva': 0,
                   'agg_s_ph_a_mva': 0,
                   'agg_s_ph_b_mva': 0,
                   'agg_s_ph_c_mva': 0},
            'soc': 0,
            'storage': {'agg_p_mw': 0,
                        'agg_p_ph_a_mw': 0,
                        'agg_p_ph_b_mw': 0,
                        'agg_p_ph_c_mw': 0,
                        'agg_s_mva': 0,
                        'agg_s_ph_a_mva': 0,
                        'agg_s_ph_b_mva': 0,
                        'agg_s_ph_c_mva': 0}},
 'tasks': {'task_id': 0, 'timestamp': 0}}
'Tue Jul 11 11:25:06 2023'
'Run 4 times'
{'connection': {'auth_state': 'ok',
                'mqtt_state': 'disconnected',
                'prov_state': 'configured',
                'sc_debug': 'disabled',
                'sc_stream': 'enabled'},
 'counters': {'MqttClient_connect': 14809,
              'MqttClient_connect_Err': 14809,
              'MqttClient_connect_err': 14809,
              'MqttClient_create': 14809,
              'MqttClient_setCallbacks': 14809,
              'SSL_Keys_Create': 14809,
              'main_CfgChanged': 1,
              'main_CfgLoad': 1,
              'rest_Counters': 20,
              'rest_Meters': 23,
              'rest_Status': 3986,
              'rest_Tasks': 1,
              'rest_Test': 2,
              'sc_SendDemandRspCtrl': 1,
              'sc_SendStreamCtrl': 10,
              'sc_hdlDataPub': 11670},
 'dry_contacts': {'': {'dry_contact_id': '',
                       'dry_contact_load_name': '',
                       'dry_contact_status': 3050996,
                       'dry_contact_type': ''}},
 'meters': {'acb_agg_energy': 0,
            'acb_agg_soc': 0,
            'backup_bat_mode': 1,
            'backup_soc': 30,
            'enc_agg_energy': 0,
            'enc_agg_soc': 0,
            'gen_relay_state': 5,
            'generator': {'agg_p_mw': 0,
                          'agg_p_ph_a_mw': 0,
                          'agg_p_ph_b_mw': 0,
                          'agg_p_ph_c_mw': 0,
                          'agg_s_mva': 0,
                          'agg_s_ph_a_mva': 0,
                          'agg_s_ph_b_mva': 0,
                          'agg_s_ph_c_mva': 0},
            'grid': {'agg_p_mw': 98428,
                     'agg_p_ph_a_mw': 98428,
                     'agg_p_ph_b_mw': 0,
                     'agg_p_ph_c_mw': 0,
                     'agg_s_mva': 1219422,
                     'agg_s_ph_a_mva': 1219422,
                     'agg_s_ph_b_mva': 0,
                     'agg_s_ph_c_mva': 0},
            'is_split_phase': 0,
            'last_update': 1689071150,
            'load': {'agg_p_mw': 98428,
                     'agg_p_ph_a_mw': 98428,
                     'agg_p_ph_b_mw': 0,
                     'agg_p_ph_c_mw': 0,
                     'agg_s_mva': 1219422,
                     'agg_s_ph_a_mva': 1219422,
                     'agg_s_ph_b_mva': 0,
                     'agg_s_ph_c_mva': 0},
            'main_relay_state': 1,
            'phase_count': 1,
            'pv': {'agg_p_mw': 0,
                   'agg_p_ph_a_mw': 0,
                   'agg_p_ph_b_mw': 0,
                   'agg_p_ph_c_mw': 0,
                   'agg_s_mva': 0,
                   'agg_s_ph_a_mva': 0,
                   'agg_s_ph_b_mva': 0,
                   'agg_s_ph_c_mva': 0},
            'soc': 0,
            'storage': {'agg_p_mw': 0,
                        'agg_p_ph_a_mw': 0,
                        'agg_p_ph_b_mw': 0,
                        'agg_p_ph_c_mw': 0,
                        'agg_s_mva': 0,
                        'agg_s_ph_a_mva': 0,
                        'agg_s_ph_b_mva': 0,
                        'agg_s_ph_c_mva': 0}},
 'tasks': {'task_id': 0, 'timestamp': 0}}
'Tue Jul 11 11:25:06 2023'
'Run 5 times'
{'connection': {'auth_state': 'ok',
                'mqtt_state': 'disconnected',
                'prov_state': 'configured',
                'sc_debug': 'disabled',
                'sc_stream': 'enabled'},
 'counters': {'MqttClient_connect': 14809,
              'MqttClient_connect_Err': 14809,
              'MqttClient_connect_err': 14809,
              'MqttClient_create': 14809,
              'MqttClient_setCallbacks': 14809,
              'SSL_Keys_Create': 14809,
              'main_CfgChanged': 1,
              'main_CfgLoad': 1,
              'rest_Counters': 20,
              'rest_Meters': 23,
              'rest_Status': 3987,
              'rest_Tasks': 1,
              'rest_Test': 2,
              'sc_SendDemandRspCtrl': 1,
              'sc_SendStreamCtrl': 10,
              'sc_hdlDataPub': 11670},
 'dry_contacts': {'': {'dry_contact_id': '',
                       'dry_contact_load_name': '',
                       'dry_contact_status': 3050996,
                       'dry_contact_type': ''}},
 'meters': {'acb_agg_energy': 0,
            'acb_agg_soc': 0,
            'backup_bat_mode': 1,
            'backup_soc': 30,
            'enc_agg_energy': 0,
            'enc_agg_soc': 0,
            'gen_relay_state': 5,
            'generator': {'agg_p_mw': 0,
                          'agg_p_ph_a_mw': 0,
                          'agg_p_ph_b_mw': 0,
                          'agg_p_ph_c_mw': 0,
                          'agg_s_mva': 0,
                          'agg_s_ph_a_mva': 0,
                          'agg_s_ph_b_mva': 0,
                          'agg_s_ph_c_mva': 0},
            'grid': {'agg_p_mw': 98428,
                     'agg_p_ph_a_mw': 98428,
                     'agg_p_ph_b_mw': 0,
                     'agg_p_ph_c_mw': 0,
                     'agg_s_mva': 1219422,
                     'agg_s_ph_a_mva': 1219422,
                     'agg_s_ph_b_mva': 0,
                     'agg_s_ph_c_mva': 0},
            'is_split_phase': 0,
            'last_update': 1689071150,
            'load': {'agg_p_mw': 98428,
                     'agg_p_ph_a_mw': 98428,
                     'agg_p_ph_b_mw': 0,
                     'agg_p_ph_c_mw': 0,
                     'agg_s_mva': 1219422,
                     'agg_s_ph_a_mva': 1219422,
                     'agg_s_ph_b_mva': 0,
                     'agg_s_ph_c_mva': 0},
            'main_relay_state': 1,
            'phase_count': 1,
            'pv': {'agg_p_mw': 0,
                   'agg_p_ph_a_mw': 0,
                   'agg_p_ph_b_mw': 0,
                   'agg_p_ph_c_mw': 0,
                   'agg_s_mva': 0,
                   'agg_s_ph_a_mva': 0,
                   'agg_s_ph_b_mva': 0,
                   'agg_s_ph_c_mva': 0},
            'soc': 0,
            'storage': {'agg_p_mw': 0,
                        'agg_p_ph_a_mw': 0,
                        'agg_p_ph_b_mw': 0,
                        'agg_p_ph_c_mw': 0,
                        'agg_s_mva': 0,
                        'agg_s_ph_a_mva': 0,
                        'agg_s_ph_b_mva': 0,
                        'agg_s_ph_c_mva': 0}},
 'tasks': {'task_id': 0, 'timestamp': 0}}
'Tue Jul 11 11:25:07 2023'
'Run 6 times'
{'connection': {'auth_state': 'ok',
                'mqtt_state': 'disconnected',
                'prov_state': 'configured',
                'sc_debug': 'disabled',
                'sc_stream': 'enabled'},
 'counters': {'MqttClient_connect': 14809,
              'MqttClient_connect_Err': 14809,
              'MqttClient_connect_err': 14809,
              'MqttClient_create': 14809,
              'MqttClient_setCallbacks': 14809,
              'SSL_Keys_Create': 14809,
              'main_CfgChanged': 1,
              'main_CfgLoad': 1,
              'rest_Counters': 20,
              'rest_Meters': 23,
              'rest_Status': 3988,
              'rest_Tasks': 1,
              'rest_Test': 2,
              'sc_SendDemandRspCtrl': 1,
              'sc_SendStreamCtrl': 10,
              'sc_hdlDataPub': 11670},
 'dry_contacts': {'': {'dry_contact_id': '',
                       'dry_contact_load_name': '',
                       'dry_contact_status': 3050996,
                       'dry_contact_type': ''}},
 'meters': {'acb_agg_energy': 0,
            'acb_agg_soc': 0,
            'backup_bat_mode': 1,
            'backup_soc': 30,
            'enc_agg_energy': 0,
            'enc_agg_soc': 0,
            'gen_relay_state': 5,
            'generator': {'agg_p_mw': 0,
                          'agg_p_ph_a_mw': 0,
                          'agg_p_ph_b_mw': 0,
                          'agg_p_ph_c_mw': 0,
                          'agg_s_mva': 0,
                          'agg_s_ph_a_mva': 0,
                          'agg_s_ph_b_mva': 0,
                          'agg_s_ph_c_mva': 0},
            'grid': {'agg_p_mw': 98428,
                     'agg_p_ph_a_mw': 98428,
                     'agg_p_ph_b_mw': 0,
                     'agg_p_ph_c_mw': 0,
                     'agg_s_mva': 1219422,
                     'agg_s_ph_a_mva': 1219422,
                     'agg_s_ph_b_mva': 0,
                     'agg_s_ph_c_mva': 0},
            'is_split_phase': 0,
            'last_update': 1689071150,
            'load': {'agg_p_mw': 98428,
                     'agg_p_ph_a_mw': 98428,
                     'agg_p_ph_b_mw': 0,
                     'agg_p_ph_c_mw': 0,
                     'agg_s_mva': 1219422,
                     'agg_s_ph_a_mva': 1219422,
                     'agg_s_ph_b_mva': 0,
                     'agg_s_ph_c_mva': 0},
            'main_relay_state': 1,
            'phase_count': 1,
            'pv': {'agg_p_mw': 0,
                   'agg_p_ph_a_mw': 0,
                   'agg_p_ph_b_mw': 0,
                   'agg_p_ph_c_mw': 0,
                   'agg_s_mva': 0,
                   'agg_s_ph_a_mva': 0,
                   'agg_s_ph_b_mva': 0,
                   'agg_s_ph_c_mva': 0},
            'soc': 0,
            'storage': {'agg_p_mw': 0,
                        'agg_p_ph_a_mw': 0,
                        'agg_p_ph_b_mw': 0,
                        'agg_p_ph_c_mw': 0,
                        'agg_s_mva': 0,
                        'agg_s_ph_a_mva': 0,
                        'agg_s_ph_b_mva': 0,
                        'agg_s_ph_c_mva': 0}},
 'tasks': {'task_id': 0, 'timestamp': 0}}
'Tue Jul 11 11:25:07 2023'
'Run 7 times'
niggles1973 commented 1 year ago

Hi @helderfmf , what scope is your token? installer or owner - from V7.6.175 prompt@Nigels-Mac-mini-5 ~ % curl -k -H #VeryLongToken# https://envoy.local/ipv/livedata/stream/ -X POST '{"enable": 1}'

404 Not Found

404 Not Found


openresty/1.17.8.1

curl: (3) URL using bad/illegal format or missing URL

I might work out how to install python

helderfmf commented 1 year ago

sorry, made a typo, NOT https://envoy.local/ipv/livedata/stream/ but https://envoy.local/ipv/livedata/stream without the ending /

del13r commented 1 year ago

command: curl -f -k -H "Authorization:bearer tokengoeshere" -H "Content-Type:application/json" -d "{\"enable\":1}" https://envoy.local/ivp/livedata/stream

result: { "sc_stream": "enabled" }

command: curl -f -k -H "Authorization:bearer tokengoeshere" -H "Content-Type:application/json" https://envoy.local/ivp/livedata/status -v

Result:

Thanks for the pointers, but it's not a traditional stream if you have to keep querying it.

del13r commented 1 year ago

If it was a proper stream, it should say:

< Content-Type: text/event-stream

niggles1973 commented 1 year ago

This is on 7.6.175 without the / - tried both below and helderfmf's version of the command prompt @Nigels-Mac-mini-5 ~ % curl -v -f -k -H "Authorization:bearer Mytoken" -H "Content-Type:application/json" -d "{"enable":1}" https://envoy.local/ivp/livedata/stream

helderfmf's - your version get's 404 Not Found prompt@Nigels-Mac-mini-5 ~ % curl -v -k -H "Authorization: Bearer TheBearer" https://envoy.local/ipv/livedata/stream -X POST '{"enable": 1}'

< HTTP/1.1 404 Not Found < Server: openresty/1.17.8.1 < Date: Tue, 11 Jul 2023 11:15:09 GMT < Content-Type: text/html < Content-Length: 159 < Connection: keep-alive <

404 Not Found

404 Not Found


openresty/1.17.8.1
helderfmf commented 1 year ago

Something is off, my version is the same as yours, https://envoy.local/info: <software>D7.6.175</software> My token was obtained at https://entrez.enphaseenergy.com/entrez_tokens: image If you start typing 10000 it should apear, if not go to https://enlighten.enphaseenergy.com/ and obtain this information of the system and gateway.

My curl commands work as I typed above: image

image

I honestly don't know why yours are giving 404, could be 401 ou 405, but not 404.