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
73.9k stars 30.97k forks source link

Assertion error assert self.data.enpower is not None #116718

Closed jmcollin78 closed 5 months ago

jmcollin78 commented 6 months ago

The problem

After installing Enphase Envoy integration, I've got this error in logs:

2024-05-03 18:08:21.557 ERROR (MainThread) [homeassistant.components.number] Error while setting up enphase_envoy platform for number
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/usr/src/homeassistant/homeassistant/components/enphase_envoy/number.py", line 93, in async_setup_entry
    EnvoyStorageSettingsNumberEntity(coordinator, STORAGE_RESERVE_SOC_ENTITY)
  File "/usr/src/homeassistant/homeassistant/components/enphase_envoy/number.py", line 154, in __init__
    assert self.data.enpower is not None
AssertionError
2024-05-03 18:08:21.648 ERROR (MainThread) [homeassistant.components.select] Error while setting up enphase_envoy platform for select
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/usr/src/homeassistant/homeassistant/components/enphase_envoy/select.py", line 149, in async_setup_entry
    EnvoyStorageSettingsSelectEntity(coordinator, STORAGE_MODE_ENTITY)
  File "/usr/src/homeassistant/homeassistant/components/enphase_envoy/select.py", line 212, in __init__
    assert coordinator.envoy.data.enpower is not None
AssertionError

The integration seems to work fin either. Only some storage values are missing (battery energy charged and discharged which are needed for Energy dashboard).

What version of Home Assistant Core has the issue?

core-2024.4.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

enphase_envoy

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 6 months ago

Hey there @bdraco, @cgarwood, @dgomes, @joostlek, @catsmanac, mind taking a look at this issue as it has been labeled with an integration (enphase_envoy) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `enphase_envoy` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign enphase_envoy` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


enphase_envoy documentation enphase_envoy source (message by IssueLinks)

cgarwood commented 6 months ago

Could you download the diagnostics for the integration and share those? image

Do you have both an Enpower/IQ System Controller and Encharge/IQ Batteries?

jmcollin78 commented 6 months ago

Here are the diagnostics. Yes I have Enpower (PV) and Encharge (battery) config_entry-enphase_envoy-a975d74ed60c497f703b35cc3b4e9aeb.json

cgarwood commented 6 months ago

Thanks!

First thing I notice is it lists the enphase_envoy_dev custom component being installed. I don't think it would cause a conflict in this case, but I'd still suggest removing it just to be safe.

The weirder part is /ivp/ensemble/inventory on your Envoy is only returning the Encharge device and not the Enpower/IQ System Controller device.

If you open the Enphase Enlighten app and go to Menu -> System -> Live Vitals does the app list an IQ System Controller?

catsmanac commented 6 months ago

The enphase_envoy_dev is probably the leftover from just dropping it from HACS and restarting HA to avoid data loss on the inverters. Verify is the /config/custom_components/enphase_envoy folder no longer exists and if so remove it.

(Removing the Envoy device in HA, removing Enphase_Envoy_dev from HACS and re-adding the Envoy dev again causes the inverter history to be lost as there's a difference in name scheme and the unique_id (serial) is blanked in the processes. Just deleting it in HACS while leaving the Envoy device in place avoids this as unique_id is kept.)

jmcollin78 commented 6 months ago

Hello @catsmanac ,

First thing I notice is it lists the enphase_envoy_dev custom component being installed. I don't think it would cause a conflict in this case, but I'd still suggest removing it just to be safe.

First I would thank ytou for your valuable answers. Yes I have previously the _dev release installed and I switch to the official integration last week. I have remove it now and the error is still there but you are right, it is now more clean.

2024-05-05 09:37:05.040 ERROR (MainThread) [homeassistant.components.number] Error while setting up enphase_envoy platform for number
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/usr/src/homeassistant/homeassistant/components/enphase_envoy/number.py", line 93, in async_setup_entry
    EnvoyStorageSettingsNumberEntity(coordinator, STORAGE_RESERVE_SOC_ENTITY)
  File "/usr/src/homeassistant/homeassistant/components/enphase_envoy/number.py", line 154, in __init__
    assert self.data.enpower is not None
AssertionError
2024-05-05 09:37:05.059 ERROR (MainThread) [homeassistant.components.select] Error while setting up enphase_envoy platform for select
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/usr/src/homeassistant/homeassistant/components/enphase_envoy/select.py", line 149, in async_setup_entry
    EnvoyStorageSettingsSelectEntity(coordinator, STORAGE_MODE_ENTITY)
  File "/usr/src/homeassistant/homeassistant/components/enphase_envoy/select.py", line 212, in __init__
    assert coordinator.envoy.data.enpower is not None
AssertionError

Note that I don't have this error with the dev release of the integration.

The weirder part is /ivp/ensemble/inventory on your Envoy is only returning the Encharge device and not the Enpower/IQ System Controller device.

If you open the Enphase Enlighten app and go to Menu -> System -> Live Vitals does the app list an IQ System Controller?

Here is what I have: Capture d’écran 2024-05-05 à 09 41 00

Only the battery is there curiously.

If I go to all Menu/Systems/devices I have that: Capture d’écran 2024-05-05 à 09 42 30

Capture d’écran 2024-05-05 à 09 42 56

And that is all.

I guess finally I don't have any "IQ System Controller". I have 9 micro inverters and one Envoy gateway. I thought the Envoy gateway was the "system controller". What is the purpose of a "IQ System controller" ?

catsmanac commented 6 months ago

The IQ system controller allows to go off-grid with batteries and solar. I'm not sure if it is already available in Europe and/or which specific European countries.

So missing Enpower may be an expected situation in Europe.

@cgarwood, maybe replacing the assert by a return None to not add it?

cgarwood commented 6 months ago

Interesting... I've never seen a system with batteries without the Enpower/IQ System Controller also.

The Enpower/IQ System Controller (hooray for Enphase changing names) is basically a fancy automatic transfer switch. Solar, batteries, and grid hit the Enpower, then one circuit from the Enpower hits your main panel. The Enpower handles disconnecting from the grid in an outage and helps direct/manager the flow of power between the various systems.

catsmanac commented 6 months ago

Off grid switching in pretty recent here. I think here you now can get IQ System controller 3 or 4.

Below picture is from the Dutch Battery 3t or 10T installation guide, no off-grid provisions. Drive here is more to self-consuming own produced power then issues with grid availability.

afbeelding

jmcollin78 commented 6 months ago

This is exactly what I have. IQ relay and IQ gateway, IQ battery 3T. I wish I could have an IQ system controller but I ask the Enphase support and it is not available in France. I'm very disappointed about that.

So it may be a common configuration (all EU configuration normally).

cgarwood commented 6 months ago

Trying to decide the best way to fix this...

Do you have the ability to change the storage mode on the battery or a reserve battery percentage? On my US system I can change the battery profile between Full Backup or Self Consumption, and on self Consumption I can set a reserve percentage that it won't allow the battery to go below if the grid is up.

I'm guessing you won't have the option to change these, but wanted to confirm.

jmcollin78 commented 6 months ago

No I don't have this (I guess you have this on the Enlighten app).

catsmanac commented 6 months ago

Not available in Europe again it seems, topic ranging from 9/2023 - 1/2024: https://support.enphase.com/s/question/0D53m00009SKlw4CAD/battery-3t-no-savings-mode