briancmpbll / home_assistant_custom_envoy

173 stars 76 forks source link

Sensors Unavailable / Repeatedly requesting tokens from Enphase - "Found empty token" #112

Closed dh99999 closed 11 months ago

dh99999 commented 1 year ago

I have an issue whereby it appears the integration is restarting during the processing of data.

It does not do it every time - it can work fine for 6 hours, but then fail 3 times in 10 minutes.

From the log I can see data being extracted from the envoy, but then as the processing should kick in, it appears to be reset and immediately request a new token from enphase. ie: It looks like it is crashing or otherwise restarting processing.

Simultaneously with this I see any template sensors that I have which use the enphase values receive an "unavailable" state for the sensors, which again makes me think the integration is restarting.

There are no stack traces that I can see in the home-assistant.log, or anything else that seems to indicate that the integration was restarted by HA, so at this point I am unsure how to identify the issue.

Is there another log I should be looking at to find this information?

2023-07-17 23:43:49.699 DEBUG (MainThread) [custom_components.enphase_envoy] Retrieved data from API: {'production': -9, 'daily_production': 12041, 'seven_days_production': 96181, 'lifetime_production': 14678023, ..... 2023-07-17 23:43:49.699 DEBUG (MainThread) [custom_components.enphase_envoy] Finished fetching envoy Envoy XXXXXXX data in 9.250 seconds (success: True)
... 2023-07-17 23:43:49.816 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Checking Token value:
2023-07-17 23:43:49.816 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Found empty token:
2023-07-17 23:43:54.091 DEBUG (MainThread) [custom_components.enphase_envoy.envoy_reader] Commissioned Token valid for 364.9999873635338 days

This may very well be an issue with my setup, but no other integrations seem to be impacted.

Any ideas?

image

catsmanac commented 12 months ago

Looks indeed like a restart of some kind. I see a scan took almost 10 seconds. Is that always the case?

To see more details in the log you can change logging level in configuration.yaml in the config folder by adding a logger section to display all information.

logger:
  default: info

But it will create a huge log file with lots of details.

dh99999 commented 12 months ago

Looks indeed like a restart of some kind. I see a scan took almost 10 seconds. Is that always the case?

No, not always 10 seconds - it was generally around 5, with the call to home.json taking most of the time.

I am now running the "main" branch without the call to home.json and the scan is now taking less than 2 seconds.

I have also added some debugging around the calls to async_setup_entry and async_unload_entry to see if that shows anything associated with the integration being restarted.

I have not seen the issue since I have updated to the main branch about 24 hours ago - I will continue to monitor and report back.

I was previously on v0.0.13, but I was seeing the issue in v0.0.12 as well.

posixx commented 12 months ago

How is your envoy connected to the network? Through WiFi? If so, switch to an Ethernet connection as that will be much more stable and probably much faster..

dh99999 commented 12 months ago

Envoy and HA are all connected via gigabit Ethernet... router and HA logs do not show any disconnects that I can see. Also not seeing any connection issues to other devices monitored by HA. Envoy is not reporting connectivity issues that I can see (though I must admit I don't have a good way to monitor this - I will setup a pingplotter if the issues recur)

I would have expected log entries from the integration if it was a connectivity issue?

Not sure if 5s was a long time for a scan to complete (3 phase, consumption + production CT metering, 17 micro inverters, no battery), but now that home.json isn't being called the scan is much faster.

dh99999 commented 11 months ago

Closing.

Issue has not recurred since running the "main?" branch with home.json not being called.

Thanks for the help!