grzegorz914 / homebridge-enphase-envoy

Homebridge plugin for Photovoltaic Energy System manufactured by Enphase. Supported Envoy-IQ, Envoy-S and all peripheral devices.
MIT License
52 stars 9 forks source link

Error 401 after power cut #112

Closed zoic21 closed 11 months ago

zoic21 commented 11 months ago

Hello,

To begin thank for your plugin and your time on it. I find maybe an issue, when there is a power cut, after Envoy restart token is invalid (401 error on hombridge plugin log) and I need to restart plugin to make it work again.

Maybe it's possible when there is a 401 unauthorized to test a renew of token and retry ?

Thank in advance.

grzegorz914 commented 11 months ago

can you post the log with this error?

zoic21 commented 11 months ago

Hello,

Yes of course :

2023/11/29 08:30:01 stdout  [11/29/2023, 8:30:01 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update production data error: AxiosError: Request failed with status code 401. Trying again in: in: 30 sec.
2023/11/29 08:29:37 stdout  [11/29/2023, 8:29:37 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update meters data error: AxiosError: Request failed with status code 401. Trying again in: 30 sec.
2023/11/29 08:29:31 stdout  [11/29/2023, 8:29:31 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update production data error: AxiosError: Request failed with status code 401. Trying again in: in: 30 sec.
2023/11/29 08:29:31 stdout  [11/29/2023, 8:29:31 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update inventory data error: AxiosError: Request failed with status code 401. Trying again in: 60 sec.
2023/11/29 08:29:22 stdout  [11/29/2023, 8:29:22 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update microinverters data error: AxiosError: Request failed with status code 401. Trying again in: 70 sec.
2023/11/29 08:29:07 stdout  [11/29/2023, 8:29:07 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update meters data error: AxiosError: Request failed with status code 401. Trying again in: 30 sec.
2023/11/29 08:29:01 stdout  [11/29/2023, 8:29:01 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update production data error: AxiosError: Request failed with status code 401. Trying again in: in: 30 sec.
2023/11/29 08:28:37 stdout  [11/29/2023, 8:28:37 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update meters data error: AxiosError: Request failed with status code 401. Trying again in: 30 sec.
2023/11/29 08:28:31 stdout  [11/29/2023, 8:28:31 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update production data error: AxiosError: Request failed with status code 401. Trying again in: in: 30 sec.
2023/11/29 08:28:29 stdout  [11/29/2023, 8:28:29 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update inventory data error: AxiosError: Request failed with status code 401. Trying again in: 60 sec.
2023/11/29 08:28:12 stdout  [11/29/2023, 8:28:12 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update microinverters data error: AxiosError: Request failed with status code 401. Trying again in: 70 sec.
2023/11/29 08:28:07 stdout  [11/29/2023, 8:28:07 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update meters data error: AxiosError: Request failed with status code 401. Trying again in: 30 sec.
2023/11/29 08:28:01 stdout  [11/29/2023, 8:28:01 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update production data error: AxiosError: Request failed with status code 401. Trying again in: in: 30 sec.
2023/11/29 08:27:37 stdout  [11/29/2023, 8:27:37 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update meters data error: AxiosError: Request failed with status code 401. Trying again in: 30 sec.
2023/11/29 08:27:31 stdout  [11/29/2023, 8:27:31 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update production data error: AxiosError: Request failed with status code 401. Trying again in: in: 30 sec.
2023/11/29 08:27:28 stdout  [11/29/2023, 8:27:28 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update inventory data error: AxiosError: Request failed with status code 401. Trying again in: 60 sec.
2023/11/29 08:27:07 stdout  [11/29/2023, 8:27:07 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update meters data error: AxiosError: Request failed with status code 401. Trying again in: 30 sec.
2023/11/29 08:27:02 stdout  [11/29/2023, 8:27:02 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update microinverters data error: AxiosError: Request failed with status code 401. Trying again in: 70 sec.
2023/11/29 08:27:01 stdout  [11/29/2023, 8:27:01 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update production data error: AxiosError: Request failed with status code 401. Trying again in: in: 30 sec.
2023/11/29 08:26:37 stdout  [11/29/2023, 8:26:37 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update meters data error: AxiosError: Request failed with status code 401. Trying again in: 30 sec.
2023/11/29 08:26:31 stdout  [11/29/2023, 8:26:31 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update production data error: AxiosError: Request failed with status code 401. Trying again in: in: 30 sec.
2023/11/29 08:26:27 stdout  [11/29/2023, 8:26:27 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update inventory data error: AxiosError: Request failed with status code 401. Trying again in: 60 sec.
2023/11/29 08:26:07 stdout  [11/29/2023, 8:26:07 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update meters data error: AxiosError: Request failed with status code 401. Trying again in: 30 sec.
2023/11/29 08:26:01 stdout  [11/29/2023, 8:26:01 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update production data error: AxiosError: Request failed with status code 401. Trying again in: in: 30 sec.
2023/11/29 08:25:52 stdout  [11/29/2023, 8:25:52 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update microinverters data error: AxiosError: Request failed with status code 401. Trying again in: 70 sec.
2023/11/29 08:25:37 stdout  [11/29/2023, 8:25:37 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update meters data error: AxiosError: Request failed with status code 401. Trying again in: 30 sec.
2023/11/29 08:25:31 stdout  [11/29/2023, 8:25:31 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update production data error: AxiosError: Request failed with status code 401. Trying again in: in: 30 sec.
2023/11/29 08:25:25 stdout  [11/29/2023, 8:25:25 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update inventory data error: AxiosError: Request failed with status code 401. Trying again in: 60 sec.
2023/11/29 08:25:07 stdout  [11/29/2023, 8:25:07 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update meters data error: AxiosError: Request failed with status code 401. Trying again in: 30 sec.
2023/11/29 08:25:01 stdout  [11/29/2023, 8:25:01 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update production data error: AxiosError: Request failed with status code 401. Trying again in: in: 30 sec.
2023/11/29 08:24:42 stdout  [11/29/2023, 8:24:42 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update microinverters data error: AxiosError: Request failed with status code 401. Trying again in: 70 sec.
2023/11/29 08:24:37 stdout  [11/29/2023, 8:24:37 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update meters data error: AxiosError: Request failed with status code 401. Trying again in: 30 sec.
2023/11/29 08:24:31 stdout  [11/29/2023, 8:24:31 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update production data error: AxiosError: Request failed with status code 401. Trying again in: in: 30 sec.
2023/11/29 08:24:24 stdout  [11/29/2023, 8:24:24 AM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update inventory data error: AxiosError: Request failed with status code 401. Trying again in: 60 sec.
grzegorz914 commented 11 months ago

try 7.7.3-beta.1 and let me know

zoic21 commented 11 months ago

Hello,

No problem, just where can found this version ? I check on this git but I don't any new commit or release...

grzegorz914 commented 11 months ago

In config ui select install another version.

grzegorz914 commented 11 months ago

or just in terminal

npm install -g homebridge-enphase-envoy@v7.7.3-beta.1

zoic21 commented 11 months ago

Ok thanks it's seem ok but I am not sure in the way you want :

[11/29/2023, 6:20:03 PM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update meters data error: AxiosError: Request failed with status code 401. Trying again in: 30 sec.

/homebridge/node_modules/homebridge-enphase-envoy/index.js:53
            const validateToken = error.response.status == 401 ? envoyDevice.start() : false;
                                                 ^
TypeError: Cannot read properties of undefined (reading 'status')
    at EnvoyDevice.<anonymous> (/homebridge/node_modules/homebridge-enphase-envoy/index.js:53:50)
    at EnvoyDevice.emit (node:events:517:28)
    at EnvoyDevice.updateMeters (/homebridge/node_modules/homebridge-enphase-envoy/src/envoydevice.js:440:18)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
[11/29/2023, 6:20:03 PM] [homebridge-enphase-envoy] Child bridge process ended
[11/29/2023, 6:20:03 PM] [homebridge-enphase-envoy] Process Ended. Code: 1, Signal: null
[11/29/2023, 6:20:10 PM] [homebridge-enphase-envoy] Restarting Process...
[11/29/2023, 6:20:11 PM] [homebridge-enphase-envoy] Launched child bridge with PID 1499
[11/29/2023, 6:20:11 PM] Registering platform 'homebridge-enphase-envoy.enphaseEnvoy'
[11/29/2023, 6:20:11 PM] [homebridge-enphase-envoy] Loaded homebridge-enphase-envoy v7.7.3-beta.1 child bridge successfully
[11/29/2023, 6:20:11 PM] Loaded 0 cached accessories from cachedAccessories.XXXXXX.
[11/29/2023, 6:20:11 PM] Homebridge v1.7.0 (HAP v0.11.1) (homebridge-enphase-envoy) is running on port 53335.
[11/29/2023, 6:20:11 PM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, MQTT Connected.
grzegorz914 commented 11 months ago

Fixed in beta 2

zoic21 commented 11 months ago

Perfect it's work now. Thank a lot for your support and fast correction.

zoic21 commented 11 months ago

I speak too fast, I think there is another issue link to this fix. Now no more error in log but data this wrong (consumption at 9329.0 kWh for exemple) and in log it's seem start not complete :

[11/29/2023, 6:52:43 PM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Update production data error: AxiosError: Request failed with status code 503. Reconnect in 15s.
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] -------- Envoy --------
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] Manufacturer: Enphase
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] Model: ENV-S-WM-230
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] Firmware: D7.6.175
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] SerialNr: XXXXX
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] Time: 11/29/2023, 6:52:40 PM
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] ------------------------------
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] Q-Relays: 2
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] Inverters: 16
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] Batteries: 0
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] --------------------------------
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] Meters: Yes
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] Production: Enabled
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] Consumption: Enabled
[11/29/2023, 6:52:49 PM] [homebridge-enphase-envoy] --------------------------------
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] -------- Envoy --------
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] Manufacturer: Enphase
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] Model: ENV-S-WM-230
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] Firmware: D7.6.175
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] SerialNr: XXXXXX
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] Time: 11/29/2023, 6:52:40 PM
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] ------------------------------
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] Q-Relays: 2
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] Inverters: 16
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] Batteries: 0
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] --------------------------------
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] Meters: Yes
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] Production: Enabled
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] Consumption: Enabled
[11/29/2023, 6:52:54 PM] [homebridge-enphase-envoy] --------------------------------
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] -------- Envoy --------
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] Manufacturer: Enphase
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] Model: ENV-S-WM-230
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] Firmware: D7.6.175
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] SerialNr: XXXXXXX
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] Time: 11/29/2023, 6:52:58 PM
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] ------------------------------
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] Q-Relays: 2
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] Inverters: 16
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] Batteries: 0
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] --------------------------------
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] Meters: Yes
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] Production: Enabled
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] Consumption: Enabled
[11/29/2023, 6:53:02 PM] [homebridge-enphase-envoy] --------------------------------

No more line after that, If I restart plugin it's ok and I have this line :

[11/29/2023, 6:56:05 PM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Envoy: XXXXX, production power state: Not active
[11/29/2023, 6:56:05 PM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Envoy: XXXXX, production power level: 0 %
[11/29/2023, 6:56:05 PM] [homebridge-enphase-envoy] Device: 192.168.1.46 Envoy, Envoy: XXXXX, alerts: No alerts

I see your fix maybe since you launch start from multiple sub function there is collision.

grzegorz914 commented 11 months ago

OK, try 7.7.4-beta.1

zoic21 commented 11 months ago

Ok I start the test but I think it's not you but a bug in envoy firmware, after 10min all it's ok....

zoic21 commented 11 months ago

It's good now on log, still errors on the values ​​during the few minutes following the restart but I think it is due to the send itself.

grzegorz914 commented 11 months ago

im pushed 7.7.4