macxq / foxess-ha

Home Assistant & FoxESS integration. Monitor you photovoltaic installation directly from HA ☀️ ⚡️
120 stars 37 forks source link

Multiple inverters with the same agent account not working #202

Closed icecream42 closed 9 months ago

icecream42 commented 11 months ago

Describe the bug Configuring multiple inverters with the same agent account doesn't work. The data for one is pulled successfully, the other errors out. Using an end user account however works.

To Reproduce Steps to reproduce the behavior:

  1. Configure multiple inverters using the same account / password
  2. Restart HA
  3. Data for one inverter is pulled successfully, not for the other

Debug logs:


Nov 26 12:45:15 nanopi-r6c homeassistant[91179]: Traceback (most recent call last):

Nov 26 12:45:15 nanopi-r6c homeassistant[91179]:   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh

Nov 26 12:45:15 nanopi-r6c homeassistant[91179]:     self.data = await self._async_update_data()

Nov 26 12:45:15 nanopi-r6c homeassistant[91179]:                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Nov 26 12:45:15 nanopi-r6c homeassistant[91179]:   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 246, in _async_update_data

Nov 26 12:45:15 nanopi-r6c homeassistant[91179]:     return await self.update_method()

Nov 26 12:45:15 nanopi-r6c homeassistant[91179]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^

Nov 26 12:45:15 nanopi-r6c homeassistant[91179]:   File "/config/custom_components/foxess/sensor.py", line 144, in async_update_data

Nov 26 12:45:15 nanopi-r6c homeassistant[91179]:     if int(allData["addressbook"]["result"]["status"]) == 1 or int(allData["addressbook"]["result"]["status"]) == 2 or int(allData["addressbook"]["result"]["status"]) == 3:

Nov 26 12:45:15 nanopi-r6c homeassistant[91179]:            ~~~~~~~^^^^^^^^^^^^^^^

Nov 26 12:45:15 nanopi-r6c homeassistant[91179]: KeyError: 'addressbook'

Nov 26 12:45:15 nanopi-r6c homeassistant[91179]: 2023-11-26 11:45:15.942 ERROR (MainThread) [custom_components.foxess.sensor] FoxESS Cloud initializaction failed, fix error and restar ha

HA version:

2023.11.3

foxess-ha version:

v0.32

Veedrim commented 10 months ago

I have the same error, after restarting HA, it pulls data from Fox Cloud only few times for both inverters and then freezing again. There is few errors: 1- Unable to get Raw data from FoxESS Cloud 2- Error while processing template: Template<template=({{ states('sensor.foxess_pv1_power') | float + states('sensor.foxess_pv2_power') | float }}) renders=2> 3- TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{{ states('sensor.foxess_pv1_power') | float + states('sensor.foxess_pv2_power') | float }}' but no default was specified') while processing template 'Template<template=({{ states('sensor.foxess_pv1_power') | float + states('sensor.foxess_pv2_power') | float }}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.solar_power_now'

Configuration.yaml code:

#Fox Cloud

sensor:

logger: default: warning logs: custom_components.foxess: debug

Does anyone solve this already?

FozzieUK commented 10 months ago

The next release of this integration will use the new OpenAPI cloud access that FoxESS are developing - it operates differently in that rather than use the 'deviceID' in the platform, you instead have to specify the deviceSN which is the specific inverters serial number within your account that you want to get data from. I am hoping that once this next version is released with OpenAPI access this should work with an agent account.

FozzieUK commented 9 months ago

Actually just thinking this through, rather than use your agent account with multiple devices - you should be able to get this working simply by creating a user account for each of the inverters and then use the user account to gather the cloud data.

icecream42 commented 9 months ago

Actually just thinking this through, rather than use your agent account with multiple devices - you should be able to get this working simply by creating a user account for each of the inverters and then use the user account to gather the cloud data.

Yup, that does work and is what I did so far.