home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.16k stars 29.84k forks source link

Enphase Envoy Sensor Platform Broken on certain envoy firmwares. #30854

Closed mondomx closed 4 years ago

mondomx commented 4 years ago

Home Assistant release with the issue:

Home Assistant 0.104.0

Last working Home Assistant release (if known): Unknown

Operating environment (Hass.io/Docker/Windows/etc.):

Hassio running Docker on Ubuntu 18.04

Integration:

https://www.home-assistant.io/integrations/enphase_envoy/

Description of problem:

First, the sensor.py spits a python error gathering states from the /api/v1/production/inverters API. Included traceback for debugging.

Second, the Integration seems to be scraping the data from http://envoy/production.json URL and not the http://envoy/api/v1/production URL available on envoy firmware R4.10.35 (6ed292).

The data contained on the production.json is wrong in the R4.10.35 (6ed292) firmware, returning incorrect values when compared to the values obtained in the http://envoy/api/v1/production URL

Production.json.

      "wNow": 716.052,
      "whToday": 95.928,
      "whLastSevenDays": 95.928,
      "whLifetime": 1543.928,

/api/v1/production

      "wattsNow": 688
      "wattHoursToday": 2778,
      "wattHoursSevenDays": 111345,
      "wattHoursLifetime": 121601,

As you can see the values for wNow, whToday, whLastSevenDays and whLifetime do not match the ones on the production API (that the enphase smartphone app shows). So the correct values should be scraped from the /api/v1/production API

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

  - platform: enphase_envoy
    name: Solar Panels
    ip_address: (IP_ADDRESS)
    monitored_conditions:
      - production
      - daily_production
      - seven_days_production
      - lifetime_production
      - inverters
    username: (user)
    password: (password)

Traceback (if applicable):

2020-01-16 13:21:35 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.solar_panelsenvoy_inverter_121923055166 fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 459, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/enphase_envoy/sensor.py", line 165, in async_update
    self._state = inverters[serial_number][0]
KeyError: 'Inverter'

Additional information: Enphase Envoy Firmware: R4.10.35

Sample of the output for the http://envoy/api/v1/production/inverters on the R4.10.35 is as follows:

// 20200116133704
// http://envoy/api/v1/production/inverters

[
  {
    "serialNumber": "121923055930",
    "lastReportDate": 1579195583,
    "devType": 1,
    "lastReportWatts": 33,
    "maxReportWatts": 287
  },
  {
    "serialNumber": "121923054590",
    "lastReportDate": 1579195589,
    "devType": 1,
    "lastReportWatts": 34,
    "maxReportWatts": 293
  },
  {
    "serialNumber": "121923047899",
    "lastReportDate": 1579195581,
    "devType": 1,
    "lastReportWatts": 33,
    "maxReportWatts": 288
  }
]
springstan commented 4 years ago

Duplicate of #28532