Hoffmann77 / home_assistant_enphase_gateway

A custom integration for Home Assistant to read data from your Enphase Gateway.
Apache License 2.0
0 stars 0 forks source link

Could not connect or determine Envoy model #2

Closed catsmanac closed 1 year ago

catsmanac commented 1 year ago

Using EU Envoy-S non-metered, HA 2023-6-3 docker with HACS. Installed v0.1.1-beta using hacs. Restarted HA and added enphase-gateway. It wouldn't initialize and retried. It is able to get api/v1/production. It gets 401 of api/v1/production/inverters and production.json.

Then it errors out on message_battery_not_available attribute.

2023-07-03 12:02:27.821 DEBUG (MainThread) [custom_components.enphase_gateway.gateway_reader.gateway_reader] Fetched from https://192.168.3.112/api/v1/production: <Response [200 OK]>: {
  "wattHoursToday": 13312,
  "wattHoursSevenDays": 251778,
  "wattHoursLifetime": 4779946,
  "wattsNow": 3910
}

2023-07-03 12:02:27.823 ERROR (MainThread) [custom_components.enphase_gateway] Unexpected error fetching envoy Envoy 122302045041 data: 'GatewayReader' object has no attribute 'message_battery_not_available'
Traceback (most recent call last):
  File "/config/custom_components/enphase_gateway/gateway_reader/gateway_reader.py", line 286, in _async_get
    self._update_token()
    ^^^^^^^^^^^^^^^^^^
AttributeError: 'GatewayReader' object has no attribute '_update_token'

Startup log below:

home-assistant-v011-beta.log

Some observations:

from log is seems it accesses /production.json first. it hits a 401. /Auth/check_jwt should be used first. /api/v1/production works fine as that isn't subjected to the auth check.

catsmanac commented 1 year ago

The 'could not detect envoy model' comes from the original HA Enphase envoy integration (which doesn't support the new firmwares). With the rename to enphase_gateway, the custom integration no longer replaces the HA Core enphase envoy and that will trigger it detecting the envoy as well. It will require the HA user to specifically disable the enphase-envoy in the integrations screen.

Hoffmann77 commented 1 year ago

Fixed the two obvious errors and added some additional debug information.

Couldn't figure out why error 401 is raised in the first place.

Hoffmann77 commented 1 year ago

The 'could not detect envoy model' comes from the original HA Enphase envoy integration (which doesn't support the new firmwares). With the rename to enphase_gateway, the custom integration no longer replaces the HA Core enphase envoy and that will trigger it detecting the envoy as well. It will require the HA user to specifically disable the enphase-envoy in the integrations screen.

You mean when both the default integration or a custom integration that overrides the default and this integration are configured?

catsmanac commented 1 year ago

The 'could not detect envoy model' comes from the original HA Enphase envoy integration (which doesn't support the new firmwares). With the rename to enphase_gateway, the custom integration no longer replaces the HA Core enphase envoy and that will trigger it detecting the envoy as well. It will require the HA user to specifically disable the enphase-envoy in the integrations screen.

You mean when both the default integration or a custom integration that overrides the default and this integration are configured?

When you name the custom integration with same name as ha core integration then the custom integration will be used instead of the HA Core integration. The original name is enphase_envoy. When you renamed yours (folder) to enphase_gateway it was no longer same name as the HA Core one and did not replace the HA Core one. As Result both HA Core enphase_envoy and your enphase_gateway become active. That may be a conscious choice, but since yours uses same naming scheme and so I'd recommend to not rename it so it will replace the HA core one. Similar yours would not replace/overwrite Brian Campbells one as that sits in enphase_envoy. (Or other way around) Again, it be be a choice to rename, but in my opinion it seems to make matters more complex with 2 potential active for same device.

catsmanac commented 1 year ago

Installed V0.1.2-beta and disabled the HA Core enphase_envoy and that got rid of the 'could not determine envoy model' and the attribute errors. I now have other attribute missing but I'll open new issue for it.

Hoffmann77 commented 1 year ago

Yes that's true this integration uses a different domain than the other forks. It started as an accidental change and continued as a conscious decision. Not too sure if I will continue like this or switch back in the future, but I will update the readme accordingly. This should have been stated more clearly in the first place.

Huge thanks for your much appreciated help by the way :)

catsmanac commented 1 year ago

Welcome, and my vote is for the original enphase_envoy name (no pressure), too much of a hassle if not.