Need testers for updated Enphase Envoy sensor

@DHoefakker took some of your code and refined my output… Think this will work better now

hi,
your card looks good.

question.
how often do you receive data from the envoy?

every few min… seems very close to real-time.

ah, ok.
I have it limited to once / 5 minutes. using REST currently.

I have tried to find that sensor.py, but failed. maybe I will give it an other try if you tell me that the update frequency will be higher using this method instead of rest :slight_smile:

thanks for the update !!

The updated sensor.py code was updating the values every 30 seconds. Probably a little over kill. So I updated the sensor.py code to update every 60 seconds. This can be changed to a higher value if you want such as 120 seconds, by using the scan_interval setting in the envoy sensor section.

Example:

sensor:
  - platform: enphase_envoy
    ip_address: !secret enphase_ip_addr
    username: !secret enphase_user
    password: !secret enphase_pass
    scan_interval: 120
    monitored_conditions:
      - production
      - daily_production
      - seven_days_production
      - lifetime_production
      - inverters

The updated code is located at envoy sensor.py

@fireheadman can you share your cards yaml ?

Great work

I recently learnt one can override the inbuilt integration with custom component. I did it with DSMR sensor. Works like a charm.
Do you maybe have a github link so I can copy the complete envoy component and all files in the custom_components folder?

NEver mind… found it :slight_smile:

I created the folder in custom_components\enphase_envoy
put these files in there: init.py manifest.json and sensor.py

add in configuration.yaml sensor enphase_envoy

- platform: enphase_envoy
  name: Enphase_new
  username: !secret enphase_user
  password: !secret enphase_pass
  ip_address: hidden_ip
  monitored_conditions:
    - production
    - daily_production
    - seven_days_production
    - lifetime_production
    - inverters

and I think it is working. I will need to wait until tomorrow to see numbers flowing :slight_smile: no sun now. gheheh

I will keep you posted.

1 Like

An update.

The integration is working.
But with my envoy does not produce more frequent new data than once per 30 minutes.
The REST sensor I use, gives a new value per 5 minutes.

image

another update
it is not updating after first boot. I marked the REST sensor, which does update.
image

this is my config

- platform: enphase_envoy
  name: Enphase_new
  username: !secret string_18
  password: !secret string_19
  ip_address: 192.168.1.70
  scan_interval: 60
  monitored_conditions:
    - production
    - daily_production
    - seven_days_production
    - lifetime_production
    - inverters

I fixed a typo in the sensor code relating to the polling interval. The updated code is located here sensor.py.

Can you try out the updated sensor.py code?

EDIT: What I have noticed with the updated code I mentioned above, is that if the value retrieved from the Envoy device is the same as the last value than Home Assistant does not update the value or time since it was last retrieved. For example I have an older Envoy device which updates only every 15minutes. Even though I have Home Assistant poll every 1 minutes (60 seconds in the config) the data in Home Assistant only shows updates about every 15 minutes. So it seems Home Assistant (with my updated code) will only show an update if it has retrieved an updated value from the Envoy, which can be anywhere between 5 to 15 minutes based on the model of your Envoy device. I’ll look into that not sure if it’ll effect any calculations you maybe doing.

1 Like

hi, I downloaded te new sensor.py. I can tell you tomorrow if it updates correctly again. :smiley: too dark to see anything more than 0W. :stuck_out_tongue:

I will give an update tomorrow

1 Like

I think it is working fine now, based on the picture below.
I do see a very small delay (which is not a problem of course) compared to REST sensor. Seems like the REST sensor is faster. is it lighter or something than the Enphase integration? Just wondering :slight_smile:

In the picture below, in the graph, the lines of REST and Enphase integration are ontop of eachother.

PS
You are right. I do see as well sensors sometimes not updating if the value is the same. :+1:

Great! Thank you for the update. The REST sensor is lighter weight. Even though I have reduced some of the calls made from Home Assistant to the API in this code there are more improvements that need to be made on the API side. Which is actually being worked on now. I’ve reduced one of the main calls dramatically in this envoy_reader PR. Even though the PR talks about polling pages based on the Metering setup, there is an enhancement made to reduce polling.

“The PR also includes a reduction in HTTP calls that are made to the production pages to retrieve the data.”

So hopefully with this change in the Home Assistant sensor code and the changes on the API side, the speed should be the same as the REST sensor.

1 Like

Great. Good to read. If you need someone to test some more, just give me a nudge.

1 Like

Stumbled onto this post. I just started to include my envoy, the the communication is sporadic and not continuous, its an older model envoy from 2017 ENV-S-AB-120-A. Is there a setting I need to adjust? The data history has 2 hour gaps, very annoying! I really don’t see an API as I am connecting locally via LAN IP.

- platform: enphase_envoy
  name: Solar
  ip_address: XXX.XXX.XX.XX (private)
  monitored_conditions:
    - production
    - daily_production
    - seven_days_production
    - lifetime_production

EDIT: disregard, google wifi mesh network issue. Love the integration BTW, thanks for all the hard work!

1 Like

Hi, any plans to add phase information to this?

I have a Envoy-S Metered 3phase system and I would love to have the information added for the “per phase” data.
This can be extracted from the installer page, but for that you need to have an installer login. Maybe there is another way.
Anyhow, running:
curl --anyauth --user installer:pass http://192.168.1.65/stream/meter

outputs a stream of data:

data: {"production":{"ph-a":{"p":5.953,"q":85.77,"s":86.864,"v":227.468,"i":0.381,"pf":0.06,"f":50.0},"ph-b":{"p":4.48,"q":79.023,"s":79.023,"v":222.525,"i":0.356,"pf":0.07,"f":50.0},"ph-c":{"p":5.107,"q":70.649,"s":97.889,"v":223.626,"i":0.438,"pf":0.06,"f":50.0}},"net-consumption":{"ph-a":{"p":326.534,"q":-194.884,"s":428.075,"v":227.55,"i":1.881,"pf":0.77,"f":50.0},"ph-b":{"p":42.295,"q":-68.316,"s":92.793,"v":222.464,"i":0.418,"pf":0.47,"f":50.0},"ph-c":{"p":125.388,"q":-229.094,"s":279.196,"v":223.345,"i":1.25,"pf":0.45,"f":50.0}},"total-consumption":{"ph-a":{"p":332.487,"q":-280.655,"s":514.554,"v":227.509,"i":2.262,"pf":0.65,"f":50.0},"ph-b":{"p":46.775,"q":-147.34,"s":172.139,"v":222.495,"i":0.774,"pf":0.27,"f":50.0},"ph-c":{"p":130.496,"q":-299.744,"s":377.25,"v":223.486,"i":1.688,"pf":0.35,"f":50.0}}}

Which corresponds to this (this is not the data from the exact same time):

More information on this on this brilliant page:

More on the installer password here:

Sadly my skills are not sufficiënt to code this myself :frowning:

@michel72 If the current pages that the API polls contains the 3 phase info than it might be possible.

The pages that are retrieved from the API are
/api/v1/production
/production.json

It may not contain the live stream data but if the pages contain the phase data and behave like the other Envoys than data is updated every 5 to 15 minutes for individual inverters and 5 mins or less for the total Production and Consumption values

Yes, but this page only contains the data of the sum of all phases. Better then nothing though👍

For anyone interested, I have a really hacky way of getting this individual phase data into home assistant. I would much prefer Greg’s integration to support production and consumption values (sums), so when that gets done, I’ll use that :slight_smile:

For now:

shell_command:
  envoy_phase_data: 'bash /config/include/curl/envoy_phase_data.sh'

envoy_phase_data.sh

#!/bin/bash
timeout 15 curl --silent --anyauth --user installer:PASSWORD http://192.168.1.65/stream/meter | sed 's,data,{"data",g' | sed 's,}}},}}}},g' | head -1 > /config/www/enphase/stream.json
sensor:
  - platform: enphase_envoy
    name: Envoy-S metered
    ip_address: 192.168.1.65
    username: installer
    password: PASSWORD
    monitored_conditions:
      - production
      - daily_production
      - seven_days_production
      - lifetime_production
      - consumption
      - daily_consumption
      - seven_days_consumption
      - lifetime_consumption
      - inverters

  - platform: rest
    name: Enphase productie fase 1
    resource: https://https://your_HA_instance:8123/local/enphase/stream.json
    scan_interval: 30
    verify_ssl: false
    value_template: "{{ (value_json['data']['production']['ph-a']['p'] | float / 1000) | round(2) }}"
    unit_of_measurement: 'kWh'
    json_attributes_path: $['data']['production']['ph-a']
    json_attributes:
      - f
      - i
      - q
      - p
      - s
      - pf
      - v

  - platform: rest
    name: Enphase productie fase 2
    resource: https://https://your_HA_instance:8123/local/enphase/stream.json
    scan_interval: 30
    verify_ssl: false
    value_template: "{{ (value_json['data']['production']['ph-b']['p'] | float / 1000) | round(2) }}"
    unit_of_measurement: 'kWh'
    json_attributes_path: $['data']['production']['ph-b']
    json_attributes:
      - f
      - i
      - q
      - p
      - s
      - pf
      - v
  - platform: rest
    name: Enphase productie fase 3
    resource: https://your_HA_instance:8123/local/enphase/stream.json
    scan_interval: 30
    verify_ssl: false
    value_template: "{{ (value_json['data']['production']['ph-c']['p'] | float / 1000) | round(2) }}"
    unit_of_measurement: 'kWh'
    json_attributes_path: $['data']['production']['ph-c']
    json_attributes:
      - f
      - i
      - q
      - p
      - s
      - pf
      - v
automation:
  - id: get_envoy_phase_data
    alias: get envoy phase data
    trigger:
    - seconds: '/30'
      platform: time_pattern
    action:
      service: shell_command.envoy_phase_data

I hope someone can help me :slight_smile:

This is my config:

sensor:
  - platform: enphase_envoy
    name: Envoy-S metered
    ip_address: 192.168.1.65
    username: installer
    password: PASSWORD
    monitored_conditions:
      - production
      - daily_production
      - seven_days_production
      - lifetime_production
      - consumption
      - daily_consumption
      - seven_days_consumption
      - lifetime_consumption
      - inverters

But I’m not getting the correct inverter information:

But the data seems to be there: http://192.168.1.65/api/v1/production/inverters

[
  {
    "serialNumber": "122022009125",
    "lastReportDate": 1606045464,
    "devType": 1,
    "lastReportWatts": 6,
    "maxReportWatts": 198
  },
  {
    "serialNumber": "122022007165",
    "lastReportDate": 1606045471,
    "devType": 1,
    "lastReportWatts": 6,
    "maxReportWatts": 233
  },
  {
    "serialNumber": "122022010765",
    "lastReportDate": 1606045462,
    "devType": 1,
    "lastReportWatts": 6,
    "maxReportWatts": 200
  },
  {
    "serialNumber": "122022007141",
    "lastReportDate": 1606045467,
    "devType": 1,
    "lastReportWatts": 6,
    "maxReportWatts": 235
  },
  {
    "serialNumber": "122022003320",
    "lastReportDate": 1606045473,
    "devType": 1,
    "lastReportWatts": 6,
    "maxReportWatts": 176
  },