briancmpbll / home_assistant_custom_envoy

177 stars 77 forks source link

Working (mostly) offline? #159

Closed barry-me closed 11 months ago

barry-me commented 1 year ago

Hi,

Can the integration work offline post retrieving the auth token from the enphase website? I'm a bit sensitive about my data (and ability to control) being sent to a Chinese website so what I'd like to know is if the integration will keep working with the cached token if I block the IQ Gateway from accessing the internet after the integration retrieves the token? In other words will the gateway keep collecting data and expose it to the API if it's disconnected from the internet?

I'm about to invest big bucks in a solar system and an open system, working offline (or 99.99% offline in this case) is a hard requirement for me.

Cheers!

catsmanac commented 1 year ago

Hi @barry-me, the integration is storing the token locally after first retrieval and using it from local store thereafter. It will reach out to Enphase website again when the token is expired (after 1 year) or the token store is deleted.

I have never tested this with the Envoy blocked from the internet for extended time and have no experience how it reacts in such a case. Prime driver for the token caching has always been the Enphase Website being slow or unavailable and the ability for the integration to start up correctly under these circumstances.

barry-me commented 1 year ago

Thanks @catsmanac . I'm hoping someone has tested it (intentionally or not) for long periods of time and can reply here. I spent a few hours today researching other potential inverters but it looks like most vendors just provide a cloud service with a cloud API (and if there's a local API then it's barely documented and doesn't feel like it's here to stay)

madbrain76 commented 1 year ago

The legacy Envoy (Envoy-R LCD) does not need any token, BTW, and should work fine when blocked from the Internet. You are probably not looking for an old model, though, unless you are after a deal on some used equipment (the -R is for M series micro-inverters).

The newer Envoys (S, IQ) all require token login. I have not tried blocking either of my 3 Envoys in my pfSense. It's a bit involved since I would have to block both IPv4 and IPv6 for each of them, and I have never done either.

catsmanac commented 1 year ago

Just out of curiosity I blocked the envoy in my router yesterday. It's now just over 24 hours and Enphase web-site states last update is from yesterday, The integration is still providing data to HA and I can access the Envoy with my 4 month old token or from my SIM HA with a fresh token. On the Envoy, the top led is blinking green to indicate there's no connection to Enphase. The local Envoy webpage states 'Not connected to Enphase'.

As the saying goes: 'results from the past are no guarantee for the future'. This is a simple ENVOY-S Standard EU model. I know it has a db as it used to report % db full in the past. But it seems that's gone with the new firmware as well. Wanted to check if the db would start fill up while blocked. That is one thing I can think of that may play a role. When db 100% full it could simply start dumping old data, reboot, or crash. Who knows...

catsmanac commented 1 year ago

F.w.i.w., I got an email from Enphase after 24 hours signalling my device was not communicating anymore to them. It said not to worry if it was a local issue as the system can continue producing power and registering data. When connection is restored, buffered data will be forwarded according to that mail message. How long that will last without issues is not clear.

barry-me commented 1 year ago

Thx again @catsmanac ! So it comes down to how long it would take the DB to fill up. Appreciate you trying this out.

catsmanac commented 1 year ago

So it comes down to how long it would take the DB to fill up

@barry-me, if that would cause an issue yes, but I just don't know. Could very well be it handles it neatly by just dropping old data. Extremes like this may cause issue, or are handled well. My Envoy just passed the 48 hours point with flying colors, but that's hardly a landmark.

catsmanac commented 1 year ago

Yesterday the offline time passed the 14 day mark without any issues. I then restored the Envoy internet connection. In 15 min or so it updated Enphase web-site with the active-day and previous day data, but left the other 12 days blank. Somewhere over night it back filled the other days as well.