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
71k stars 29.64k forks source link

Enphase Envoy Component not working on envoy R4.10.24 #16210

Closed rbressers closed 6 years ago

rbressers commented 6 years ago

Home Assistant release with the issue: 0.76.2

Operating environment (Hass.io/Docker/Windows/etc.): Raspbian Stretch in a Python virtual environment

Component/platform: enphase_envoy

Description of problem: Configuring the Enphase Envoy component results in traceback and error on startup.

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

sensors:
  - platform: enphase_envoy
    ip_address: !secret envoy_ip

Traceback (if applicable):

2018-08-26 17:48:00 ERROR (MainThread) [homeassistant.components.sensor] enphase_envoy: Error on device update!
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 322, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/enphase_envoy.py", line 101, in update
    self._ip_address))
ValueError: invalid literal for int() with base 10: '{"production":[{"type":"inverters","activeCount":10,"readingTime":1535305559,"wNow":103,"whLifetime":1046722}],"storage":[{"type":"acb","activeCount":0,"readingTime":0,"wNow":0,"whNow":0,"state":"idl
2018-08-26 17:48:00 ERROR (MainThread) [homeassistant.components.sensor] enphase_envoy: Error on device update!
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 322, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/enphase_envoy.py", line 107, in update
    self._ip_address))
ValueError: invalid literal for int() with base 10: '{"production":[{"type":"inverters","activeCount":10,"readingTime":1535305559,"wNow":103,"whLifetime":1046722}],"storage":[{"type":"acb","activeCount":0,"readingTime":0,"wNow":0,"whNow":0,"state":"idl

Additional information: Envoy information : Software Version : R4.10.24 (21d507) Software Build Date : 21 Jul, 2018 2:55 AM

jesserizzo commented 6 years ago

@rbressers What model of Envoy is it? If you have a minute can you pop over to https://github.com/jesserizzo/envoy_reader/blob/master/envoy_reader/envoy_reader.py and run that python script on the command line and see if it works for you. I believe I've got it supporting the original Envoy, the Envoy S and the Envoy IQ.

rbressers commented 6 years ago

@jesserizzo I am using the Envoy-S model. The output of the script is not that hopeful Enter the Envoy IP address, or press enter to search for it.192.168.1.105 Enter the model of the Envoy ('Original' or 'S'), or press enter.S Traceback (most recent call last): File "env.py", line 167, in <module> print("production {}".format(EnvoyReader(host, envoy_model) File "env.py", line 30, in production production = raw_json["production"][1]["wNow"] IndexError: list index out of range

jesserizzo commented 6 years ago

@rbressers Ok, that's annoying. Seems like they changed the order of the json in a firmware update. Can you just in your browser go to http://envoy/production.json and paste the whole output in a comment here. Thanks for your help.

rbressers commented 6 years ago

@jesserizzo The output is as follows : {"production":[{"type":"inverters","activeCount":10,"readingTime":1535308263,"wNow":24,"whLifetime":1046748}],"storage":[{"type":"acb","activeCount":0,"readingTime":0,"wNow":0,"whNow":0,"state":"idle"}]}

jesserizzo commented 6 years ago

@rbressers Ok, I don't think it's because of the firmware update. I think it's because you don't have the hardware in your main electrical panel that monitors your whole house usage. So you will have less information available.

Can you check one more thing for me. Does http://envoy/api/v1/production give you anything?

rbressers commented 6 years ago

The URL gives me the following information: { "wattHoursToday": 12395, "wattHoursSevenDays": 78702, "wattHoursLifetime": 1046748, "wattsNow": 26 }

rbressers commented 6 years ago

And it is indeed not the Envoy-S metered but the standard Envoy-S

jesserizzo commented 6 years ago

@rbressers Ok, please try https://github.com/jesserizzo/envoy_reader/blob/master/envoy_reader/envoy_reader.py again.

rbressers commented 6 years ago

That's more like it 😉


Enter the Envoy IP address, or press enter to search for it.
production 0
consumption Unavailable
daily_production 12395
daily_consumption Unavailable
seven_days_production 78702
seven_days_consumption Unavailable
lifetime_production 1046748
lifetime_consumption Unavailable```
rgabrielson11 commented 6 years ago

Same result I got from the script and the S. looks like youre on the right track

jesserizzo commented 6 years ago

Excellent, I'll submit a pull request today.

nmichail commented 5 years ago

@jesserizzo I have a first generation Envoy that does not work correctly together with your envoy_reader.py. I have noticed your mention that it was only been tested with Envoy-S. Please review the information that I have posted here: https://community.home-assistant.io/t/trouble-with-enphase-envoy/67359/4 TIA

DavidDeSloovere commented 5 years ago

@nmichail I had added support for the Envoy-C a while back, but that got broken apparently after refactoring on the original branch. Just created a new PR to fix this at https://github.com/jesserizzo/envoy_reader/pull/3