I have a device, an Enphase Envoy, which has a streaming REST API endpoint that I’d like to consume with Home Assistant. I’m having a lot of trouble figuring out how to even search for how this is done, so am reaching out to see if someone can point me in the right direction.
I am able to use this particular endpoint from an HTML page using either the browser directly (not very useful), or an XMLHttpRequest to open the connection, and then take action on progress events in java script to consume the regularly sent data from the open connection.
The REST endpoint, https://envoy.local/stream/meter, puts out a data like shown below, every 3/4 to 1 second. How can I consume such a stream and act upon the regularly arriving data within HA?
(For non streaming endpoints, I’ve used the REST sensor within HA, but have had better experience with REST command as that provides more detail in response, such as dealing with http failures and also being able to track latency.)
(As a second question, sometimes this endpoint fails and the streaming has to be restarted, so wondering how that might be detected and accomplished within HA.)
data: {“production”:{“ph-a”:{“p”:479.615,“q”:10.347,“s”:480.464,“v”:123.524,“i”:3.889,“pf”:1.0,“f”:60.0},“ph-b”:{“p”:479.155,“q”:10.407,“s”:480.247,“v”:123.361,“i”:3.894,“pf”:1.0,“f”:60.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”:174.2,“q”:-1422.821,“s”:1441.839,“v”:123.501,“i”:11.675,“pf”:0.12,“f”:60.0},“ph-b”:{“p”:621.141,“q”:-1314.328,“s”:1472.328,“v”:123.267,“i”:11.944,“pf”:0.42,“f”:60.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”:653.815,“q”:-1412.474,“s”:1922.196,“v”:123.501,“i”:15.564,“pf”:0.34,“f”:60.0},“ph-b”:{“p”:1100.295,“q”:-1303.922,“s”:1952.286,“v”:123.267,“i”:15.838,“pf”:0.56,“f”:60.0},“ph-c”:{“p”:0.0,“q”:0.0,“s”:0.0,“v”:0.0,“i”:0.0,“pf”:0.0,“f”:0.0}}}
