Re: API update
Posted: Wed Feb 21, 2024 3:18 pm
by leonb
It looks like to be both.
In the app, my battery capacity was showing as 203Wh so I have used the manual input option.
In HA it is showing as 0.1306kWh.
For HA, I had a peek and looks like my raw data value is in kWh and the sensor is then using 're / 100' for it.
Thanks.
Re: API update
Posted: Wed Feb 21, 2024 3:56 pm
by Dave Foster
Dave Foster wrote: ↑Wed Feb 21, 2024 3:25 pm
leonb wrote: ↑Wed Feb 21, 2024 3:18 pm
It looks like to be both.
In the app, my battery capacity was showing as 203Wh so I have used the manual input option.
In HA it is showing as 0.1306kWh.
For HA, I had a peek and looks like my raw data value is in kWh and the sensor is then using 're / 100' for it.
Thanks.
Ok, thanks i’ll take a look and see if I can see anything - the residual is a new feature we requested so there may be something still not as we expected (like the unit specifier can be different)
@leonb Can you add some debugging if you get 5 minutes,
You will need to add these lines to your configuration.yaml
Code: Select all
logger:
default: warn
logs:
custom_components.foxess: debug
And then restart HA, leave it for 10 minutes have a look in your full logs, i’m looking for a long line of text that has OA Device Variables followed by a long list of variables -
Somewhere in there will be the entry that looks like {'unit': '10Wh', 'name': 'Battery Residual Energy', 'variable': 'ResidualEnergy', 'value': 1766.0}
We are expecting the unit to be 10Wh but i’m suspecting yours might be different - can you post what you are seeing please.
Afterwards remove the code to turn on logs (or change ‘debug’ to ‘warning’) and restart HA or it will create massive logs
Code: Select all
logger:
default: warn
logs:
custom_components.foxess: warning
Re: API update
Posted: Wed Feb 21, 2024 4:23 pm
by leonb
Here you go.
{'report': {'feedin': 0.1, 'generation': 12.6, 'gridConsumption': 25.7, 'chargeEnergyToTal': 20.0, 'dischargeEnergyToTal': 11.3, 'loads': 17.5}, 'reportDailyGeneration': {'value': 12.5}, 'raw': {'ambientTemp
eration': 37.7, 'batChargePower': 0.0, 'batCurrent': -1.4, 'batDischargePower': 0.376, 'batTemperature': 28.0, 'batVolt': 232.8, 'epsCurrentR': 0.7, 'epsPower': 0.0, 'epsPowerR': 0.0, 'epsVoltR': 226.7, 'feedinPower': 0.0, 'generationPower': 0.488, 'gridConsumptionPower': 0.006, 'inv
BatCurrent': 1.6, 'invBatPower': 0.376, 'invBatVolt': 234.3, 'invTemperation': 34.1, 'loadsPower': 0.496, 'meterPower': 0.006, 'meterPower2': 0.0, 'pv1Current': 0.3, 'pv1Power': 0.069, 'pv1Volt': 185.1, 'pv2Current': 0.3, 'pv2Power': 0.062, 'pv2Volt': 170.0, 'pv3Current': 0.4, 'pv3Po
wer': 0.088, 'pv3Volt': 209.7, 'pv4Current': 0.0, 'pv4Power': 0.0, 'pv4Volt': 1.7, 'pvPower': 0.219, 'RCurrent': 2.4, 'RFreq': 50.13, 'RPower': 0.488, 'RVolt': 227.2, 'SoC': 62.0, 'ResidualEnergy': 12.75}, 'battery': {'minSoc': 14, 'minSocOnGrid': 14}, 'addressbook': {'deviceType': '
KH10.5', 'masterVersion': '1.16', 'afciVersion': '', 'hasPV': True, 'deviceSN': '', 'slaveVersion': '1.01', 'hasBattery': True, 'function': {'scheduler': False}, 'hardwareVersion': '--', 'managerVersion': '1.11', 'stationName': '', 'moduleSN': '', 'productType': 'KH', 'stationID': '', 'status': 1, 'plantName': ''}, 'online': True}
edit to put in what you actually asked!
{'unit': '10Wh', 'name': 'Battery Residual Energy', 'variable': 'ResidualEnergy', 'value': 12.34}
so looks like my data is coming through wrong....
Re: API update
Posted: Wed Feb 21, 2024 4:45 pm
by Dave Foster
leonb wrote: ↑Wed Feb 21, 2024 4:23 pm
Here you go.
, 'ResidualEnergy': 12.75}, 'battery': {'minSoc': 14, 'minSocOnGrid': 14}, 'addressbook': {'deviceType': '
KH10.5', 'masterVersion': '1.16', 'afciVersion': '', 'hasPV': True, 'deviceSN': '', 'slaveVersion': '1.01', 'hasBattery': True, 'function': {'scheduler': False}, 'hardwareVersion': '--', 'managerVersion': '1.11', 'stationName': '', 'moduleSN': '', 'productType': 'KH', 'stationID': '', 'status': 1, 'plantName': ''}, 'online': True}
Ahh it’s a KH trust that to be different
It definitely thinks the residual energy is 12.75 so it’s a scaling problem - would you mind doing that one more time but see if you can find the line where it receives it’s ‘scale’ it happens every 5 mins when the integration polls the openapi and will have all the variables with their definitions something like this-
2024-02-21 09:45:32.988 DEBUG (MainThread) [custom_components.foxess.sensor] OA Device Variables Good Response: [{'unit': '℃', 'name': 'AmbientTemperature', 'variable': 'ambientTemperation', 'value': 34.3}, {'unit': 'kW', 'name': 'Charge Power', 'variable': 'batChargePower', 'value': 0.0}, {'unit': 'A', 'name': 'BatCurrent', 'variable': 'batCurrent', 'value': -0.8}, {'unit': 'kW', 'name': 'Discharge Power', 'variable': 'batDischargePower', 'value': 0.322}, {'unit': '℃', 'name': 'batTemperature', 'variable': 'batTemperature', 'value': 24.5}, {'unit': 'V', 'name': 'BatVolt', 'variable': 'batVolt', 'value': 424.9}, {'unit': '℃', 'name': 'ChargeTemperature', 'variable': 'chargeTemperature', 'value': 0.0}, {'unit': 'A', 'name': 'EPS-RCurrent', 'variable': 'epsCurrentR', 'value': 0.0}, {'unit': 'kW', 'name': 'EPSPower', 'variable': 'epsPower', 'value': 0.0}, {'unit': 'kW', 'name': 'EPS-RPower', 'variable': 'epsPowerR', 'value': 0.0}, {'unit': 'V', 'name': 'EPS-RVolt', 'variable': 'epsVoltR', 'value': 0.0}, {'unit': 'kW', 'name': 'Feed-in Power', 'variable': 'feedinPower', 'value': 0.0}, {'unit': 'kW', 'name': 'Output Power', 'variable': 'generationPower', 'value': 0.444}, {'unit': 'kW', 'name': 'GridConsumption Power', 'variable': 'gridConsumptionPower', 'value': 0.002}, {'unit': 'A', 'name': 'InvBatCurrent', 'variable': 'invBatCurrent', 'value': 0.7}, {'unit': 'kW', 'name': 'invBatPower', 'variable': 'invBatPower', 'value': 0.322}, {'unit': 'V', 'name': 'InvBatVolt', 'variable': 'invBatVolt', 'value': 427.1}, {'unit': '℃', 'name': 'InvTemperation', 'variable': 'invTemperation', 'value': 25.5}, {'unit': 'kW', 'name': 'Load Power', 'variable': 'loadsPower', 'value': 0.446}, {'unit': 'kW', 'name': 'MeterPower', 'variable': 'meterPower', 'value': 0.002}, {'unit': 'kW', 'name': 'Meter2Power', 'variable': 'meterPower2', 'value': 0.0}, {'unit': 'A', 'name': 'PV1Current', 'variable': 'pv1Current', 'value': 0.5}, {'unit': 'kW', 'name': 'PV1Power', 'variable': 'pv1Power', 'value': 0.108}, {'unit': 'V', 'name': 'PV1Volt', 'variable': 'pv1Volt', 'value': 216.7}, {'unit': 'A', 'name': 'PV2Current', 'variable': 'pv2Current', 'value': 0.4}, {'unit': 'kW', 'name': 'PV2Power', 'variable': 'pv2Power', 'value': 0.059}, {'unit': 'V', 'name': 'PV2Volt', 'variable': 'pv2Volt', 'value': 146.6}, {'unit': 'kW', 'name': 'PVPower', 'variable': 'pvPower', 'value': 0.16699999999999998}, {'unit': 'A', 'name': 'RCurrent', 'variable': 'RCurrent', 'value': 1.9}, {'unit': 'Hz', 'name': 'RFreq', 'variable': 'RFreq', 'value': 49.89}, {'unit': 'kW', 'name': 'RPower', 'variable': 'RPower', 'value': 0.444}, {'unit': 'V', 'name': 'RVolt', 'variable': 'RVolt', 'value': 250.6}, {'unit': '%', 'name': 'SoC', 'variable': 'SoC', 'value': 86.0}, {'unit': '10Wh', 'name': 'Battery Residual Energy', 'variable': 'ResidualEnergy', 'value': 1763.0}]
And right there at the end will be ResidualEnergy - in this case being scaled at unit = ‘10Wh’ - I think yours will say ‘1kWh’ but it would be really helpful to see the string.
Re: API update
Posted: Wed Feb 21, 2024 4:56 pm
by leonb
I did realise and edited my post... here is the whole thing... seems like the scaling is right but my data being returned is wrong....
custom_components.foxess.sensor] OA Device Variables Good Response: [
{'unit': '℃', 'name': 'AmbientTemperature', 'variable': 'ambientTemperation', 'value': 36.0},
{'unit': 'kW', 'name': 'Charge Power', 'variable': 'batChargePower', 'value': 0.0},
{'unit': 'A', 'name': 'BatCurrent', 'variable': 'batCurrent', 'value': -9.9},
{'unit': 'kW', 'name': 'Discharge Power', 'variable': 'batDischargePower', 'value': 2.37},
{'unit': '℃', 'name': 'batTemperature', 'variable': 'batTemperature', 'value': 27.9},
{'unit': 'V', 'name': 'BatVolt', 'variable': 'batVolt', 'value': 229.6},
{'unit': 'A', 'name': 'EPS-RCurrent', 'variable': 'epsCurrentR', 'value': 0.7},
{'unit': 'kW', 'name': 'EPSPower', 'variable': 'epsPower', 'value': 0.0},
{'unit': 'kW', 'name': 'EPS-RPower', 'variable': 'epsPowerR', 'value': 0.0},
{'unit': 'V', 'name': 'EPS-RVolt', 'variable': 'epsVoltR', 'value': 228.9},
{'unit': 'kW', 'name': 'Feed-in Power', 'variable': 'feedinPower', 'value': 0.0},
{'unit': 'kW', 'name': 'Output Power', 'variable': 'generationPower', 'value': 2.329},
{'unit': 'kW', 'name': 'GridConsumption Power', 'variable': 'gridConsumptionPower', 'value': 0.012},
{'unit': 'A', 'name': 'InvBatCurrent', 'variable': 'invBatCurrent', 'value': 10.2},
{'unit': 'kW', 'name': 'invBatPower', 'variable': 'invBatPower', 'value': 2.37},
{'unit': 'V', 'name': 'InvBatVolt', 'variable': 'invBatVolt', 'value': 230.7},
{'unit': '℃', 'name': 'InvTemperation', 'variable': 'invTemperation', 'value': 31.5},
{'unit': 'kW', 'name': 'Load Power', 'variable': 'loadsPower', 'value': 2.356},
{'unit': 'kW', 'name': 'MeterPower', 'variable': 'meterPower', 'value': 0.012},
{'unit': 'kW', 'name': 'Meter2Power', 'variable': 'meterPower2', 'value': 0.0},
{'unit': 'A', 'name': 'PV1Current', 'variable': 'pv1Current', 'value': 0.0},
{'unit': 'kW', 'name': 'PV1Power', 'variable': 'pv1Power', 'value': 0.017},
{'unit': 'V', 'name': 'PV1Volt', 'variable': 'pv1Volt', 'value': 176.5},
{'unit': 'A', 'name': 'PV2Current', 'variable': 'pv2Current', 'value': 0.1},
{'unit': 'kW', 'name': 'PV2Power', 'variable': 'pv2Power', 'value': 0.023},
{'unit': 'V', 'name': 'PV2Volt', 'variable': 'pv2Volt', 'value': 168.5},
{'unit': 'A', 'name': 'PV3Current', 'variable': 'pv3Current', 'value': 0.1},
{'unit': 'kW', 'name': 'PV3Power', 'variable': 'pv3Power', 'value': 0.041},
{'unit': 'V', 'name': 'PV3Volt', 'variable': 'pv3Volt', 'value': 223.5},
{'unit': 'A', 'name': 'PV4Current', 'variable': 'pv4Current', 'value': 0.0},
{'unit': 'kW', 'name': 'PV4Power', 'variable': 'pv4Power', 'value': 0.0},
{'unit': 'V', 'name': 'PV4Volt', 'variable': 'pv4Volt', 'value': 1.7},
{'unit': 'kW', 'name': 'PVPower', 'variable': 'pvPower', 'value': 0.081},
{'unit': 'A', 'name': 'RCurrent', 'variable': 'RCurrent', 'value': 10.2},
{'unit': 'Hz', 'name': 'RFreq', 'variable': 'RFreq', 'value': 49.98},
{'unit': 'kW', 'name': 'RPower', 'variable': 'RPower', 'value': 2.329},
{'unit': 'V', 'name': 'RVolt', 'variable': 'RVolt', 'value': 229.4},
{'unit': '%', 'name': 'SoC', 'variable': 'SoC', 'value': 60.0},
{'unit': '10Wh', 'name': 'Battery Residual Energy', 'variable': 'ResidualEnergy', 'value': 12.3}]
Re: API update
Posted: Sat Feb 24, 2024 5:48 pm
by Dave Foster
Dave Foster wrote: ↑Wed Feb 21, 2024 5:41 pm
leonb wrote: ↑Wed Feb 21, 2024 5:30 pm
I've put this into the sensor for now and it seems to be displaying correctly..
if 50 > re > 0:
re = re
elif re > 50:
re = re / 100
I was going to use 100 rather than 50, but yes exactly that
I’ve got a few minor mods being tested so i’ll roll them, and this into the next release, thanks
@leon_b - just as a quick update, I reported the problem with the KH (openAPI) to the FoxESS dev team -
Here is their response:
----------------------------------
Dear Dave
Thank you for your email, the issue is logged by our API and KH project team, we have already found the cause and will try to amend it as earlier as possible,
I will keep you posted
-------------------------------------
I'm not sure if that will be a KH firmware update, or an internal fix in their data storage servers - but i'll update when I hear more.