marq24 / ha-senec-v3

SENEC.Home V2.x/V3/V4 Integration for Home Assistant that will work with the recent changes introduced by SENEC (supporting https) - successfully tested with latest MCU Version: 0827 (Feb 2024).
Apache License 2.0
49 stars 4 forks source link

After update to home assistant 2024.8.1 WebAPI throws an error on initialization. #98

Closed KalleRau closed 1 month ago

KalleRau commented 1 month ago

With which version of the integration you have an issue?

SENEC.Home V3 hybrid/SENEC.Home V3 hybrid duo/SENEC.Home V2.1 (or older)

Multiple Systems Environment?

Checklist

Add a description

Today I updated home assistant to the newest version 2024.8.1.

After restarting HA the integration senec_WEBAPI throws an error on initialization.

Version Senec Integration

I am using the newest integration of the senec Integration( see Screenshot) .

I am using the same incredentials like in the Mein-Senec.de portal.

Konfiguration in GUI

In the debug output there are several division by zero errors because HA doesn't know the sensors from the WebAPI, but that doesn't really matter.

For the same reason there is also no information in the energy dashboard.

I have to mention that the system is in remote shutdown and therefore no values for storage are available, because I'm waiting for the new LFP Modules.

Mein-Senec de

Before the update to HA 2024.8.1 everything worked fine.

Please find the Debug output log attached.

Currently I'm switching back to the former Version of HA (2024.7.4x).

Good evening.

If you have any questions , please ask.

Add your DEBUG log output

.....

2024-08-13 14:26:41.464 INFO (MainThread) [custom_components.senec] Starting SENEC.Home Integration 'senec' with interval:0:00:30 - ConfigEntry: {'created_at': '1970-01-01T00:00:00+00:00', 'data': {'name': 'senec', 'host': '<MASKED>', 'use_https': True, 'scan_interval': 30, 'type': 'senec', 'dtype_int': 18, 'dtype': 'SENEC Main-Unit', 'dname': 'SENEC.Home V3 hybrid duo | SENEC.Inverter V3 LV', 'dserial': '<MASKED>', 'version': 'App:1827 FW:2307 NPU-Image:2310(v10)'}, 'disabled_by': None, 'domain': 'senec', 'entry_id': '133d0a87af51d8d7377669c181998445', 'minor_version': 1, 'modified_at': '1970-01-01T00:00:00+00:00', 'options': {}, 'pref_disable_new_entities': False, 'pref_disable_polling': False, 'source': 'user', 'title': 'senec', 'unique_id': None, 'version': 1}
2024-08-13 14:26:41.465 INFO (MainThread) [custom_components.senec] ***** QUERY_BMS-DATA ********
2024-08-13 14:26:41.465 INFO (MainThread) [custom_components.senec.pysenec_ha] restarting Senec lala.cgi integration... for host: '192.168.178.99' with options: {'ignore_system_state': False, 'query_wallbox_data': False, 'query_wallbox_data_via_app_api': False, 'query_bms_data': True, 'query_fan_data': False, 'query_sockets_data': False}
2024-08-13 14:26:41.468 INFO (MainThread) [custom_components.senec] Starting SENEC.Home Integration 'senec_WEBAPI' with interval:0:05:00 - ConfigEntry: {'created_at': '1970-01-01T00:00:00+00:00', 'data': {'name': 'senec_WEBAPI', 'host': '<MASKED>', 'username': 'k******@*****.de', 'password': '<MASKED>', 'scan_interval': 300, 'type': 'web', 'dtype_int': '', 'dtype': 'SENEC WebAPI', 'dname': 'SENEC.Home V3 hybrid duo | SENEC.Num: 784868110', 'dserial': '<MASKED>', 'version': 'App:1967 FW:1827 Inverter: v3.16.20', 'master_plant_number': 0, 'app_token': '<MASKED>', 'app_master_plant_id': '<MASKED>', 'app_wallbox_num_max': 0}, 'disabled_by': None, 'domain': 'senec', 'entry_id': 'd6d3097381bd1d907be8846f8c661462', 'minor_version': 1, 'modified_at': '1970-01-01T00:00:00+00:00', 'options': {}, 'pref_disable_new_entities': False, 'pref_disable_polling': False, 'source': 'user', 'title': 'senec_WEBAPI', 'unique_id': None, 'version': 1}
2024-08-13 14:26:41.468 INFO (MainThread) [custom_components.senec] ***** QUERY_PEAK_SHAVING! ********
2024-08-13 14:26:41.468 INFO (MainThread) [custom_components.senec.pysenec_ha] restarting MySenecWebPortal... for user: 'k******@*****.de' with options: {'query_wallbox_data': False, 'query_spare_capacity': False, 'query_peak_shaving': True, 'app_wallbox_num_max': 0, 'app_token': '<MASKED>', 'app_master_plant_id': '<MASKED>'}
2024-08-13 14:26:41.469 INFO (MainThread) [custom_components.senec.pysenec_ha] ***** update(self) ********
2024-08-13 14:26:41.469 DEBUG (MainThread) [custom_components.senec.pysenec_ha] ***** APP-API: app_update_now(self) ********
2024-08-13 14:26:41.469 DEBUG (MainThread) [custom_components.senec.pysenec_ha] ***** APP-API: app_get_data(self) ********
2024-08-13 14:26:41.469 DEBUG (MainThread) [custom_components.senec.pysenec_ha] APP-API get https://app-gateway.prod.senec.dev/v2/senec/systems/287927/dashboard
2024-08-13 14:26:41.740 DEBUG (MainThread) [custom_components.senec] Finished fetching senec data in 0.274 seconds (success: True)
2024-08-13 14:26:41.745 DEBUG (MainThread) [custom_components.senec.pysenec_ha] APP-API response: {'currently': {'powerGenerationInW': 3054.27221760797, 'powerConsumptionInW': 817.58, 'gridFeedInInW': 2242.5249, 'gridDrawInW': 1e-05, 'batteryChargeInW': 1e-05, 'batteryDischargeInW': 1e-05, 'batteryLevelInPercent': 1e-05, 'selfSufficiencyInPercent': 100.0, 'wallboxInW': 1e-05}, 'today': {'powerGenerationInWh': 5423.828125, 'powerConsumptionInWh': 8271.48, 'gridFeedInInWh': 2096.19140625, 'gridDrawInWh': 4943.359375, 'batteryChargeInWh': 0.0, 'batteryDischargeInWh': 0.0, 'batteryLevelInPercent': 1e-05, 'selfSufficiencyInPercent': 40.24, 'wallboxInWh': 0.0}, 'timestamp': '2024-08-13T12:21:44Z', 'electricVehicleConnected': False}
2024-08-13 14:26:41.745 DEBUG (MainThread) [custom_components.senec.pysenec_ha] ***** APP-API: app_update_total(self) ********
2024-08-13 14:26:41.746 DEBUG (MainThread) [custom_components.senec.pysenec_ha] ***** APP-API: app_get_data(self) ********
2024-08-13 14:26:41.746 DEBUG (MainThread) [custom_components.senec.pysenec_ha] APP-API get https://app-gateway.prod.senec.dev/v1/senec/monitor/287927/data/custom?startDate=2018-01-01&endDate=2024-09-01&locale=de_DE&timezone=GMT
2024-08-13 14:26:42.861 DEBUG (MainThread) [custom_components.senec.pysenec_ha] APP-API response: {'overviewMonitorCard': {'gridFeedInInKwh': {'value': 4467.0048828125, 'unit': 'kWh'}, 'gridFeedOutInKwh': {'value': 2418.169921875, 'unit': 'kWh'}, 'generatedElectricityInKwh': {'value': 7292.87060546875, 'unit': 'kWh'}, 'consumedElectricityInKwh': {'value': 5207.794921875, 'unit': 'kWh'}}, 'energySourcesMonitorCard': {'pvUsageInPercent': {'value': 71.21464254453542, 'unit': '%'}, 'batteryUsageInPercent': {'value': 5.184897813021035, 'unit': '%'}, 'gridUsageInPercent': {'value': 23.60045964244354, 'unit': '%'}}, 'pvStatsMonitorCard': {'selfConsumptionInPercent': {'value': 38.748332111325276, 'unit': '%'}, 'gridFeedInInPercent': {'value': 61.251667888674724, 'unit': '%'}, 'pvGeneration': {'value': 7292.87060546875, 'unit': 'kWh'}}, 'savingsMonitorCard': {'savedElectricityCosts': {'value': 2708.572142871094, 'unit': 'euro'}, 'avoidedCo2Emissions': {'value': 2924.441112792969, 'unit': 'kg'}, 'treesToBePlanted': 186.27013457280057}, 'aggregation': {'startDate': '2018-01-01T00:00:00Z', 'gridConsumption': {'value': 2418.169921875, 'unit': 'kWh'}, 'gridFeedIn': {'value': 4467.0048828125, 'unit': 'kWh'}, 'storageLoad': {'value': 565.8899536132812, 'unit': 'kWh'}, 'storageConsumption': {'value': 530.9692993164062, 'unit': 'kWh'}, 'storageLevel': {'value': 7.5471272468566895, 'unit': '%'}, 'generation': {'value': 7292.87060546875, 'unit': 'kWh'}, 'totalUsage': {'value': 5207.794921875, 'unit': 'kWh'}}, 'intervals': [{'startDate': '2018-01-01T00:00:00Z', 'gridConsumption': {'value': 0.0, 'unit': 'kWh'}, 'gridFeedIn': {'value': 0.0, 'unit': 'kWh'}, 'storageLoad': {'value': 0.0, 'unit': 'kWh'}, 'storageConsumption': {'value': 0.0, 'unit': 'kWh'}, 'storageLevel': {'value': 0.0, 'unit': '%'}, 'generation': {'value': 0.0, 'unit': 'kWh'}, 'totalUsage': {'value': 0.0, 'unit': 'kWh'}}, {'startDate': '2019-01-01T00:00:00Z', 'gridConsumption': {'value': 0.0, 'unit': 'kWh'}, 'gridFeedIn': {'value': 0.0, 'unit': 'kWh'}, 'storageLoad': {'value': 0.0, 'unit': 'kWh'}, 'storageConsumption': {'value': 0.0, 'unit': 'kWh'}, 'storageLevel': {'value': 0.0, 'unit': '%'}, 'generation': {'value': 0.0, 'unit': 'kWh'}, 'totalUsage': {'value': 0.0, 'unit': 'kWh'}}, {'startDate': '2020-01-01T00:00:00Z', 'gridConsumption': {'value': 0.0, 'unit': 'kWh'}, 'gridFeedIn': {'value': 0.0, 'unit': 'kWh'}, 'storageLoad': {'value': 0.0, 'unit': 'kWh'}, 'storageConsumption': {'value': 0.0, 'unit': 'kWh'}, 'storageLevel': {'value': 0.0, 'unit': '%'}, 'generation': {'value': 0.0, 'unit': 'kWh'}, 'totalUsage': {'value': 0.0, 'unit': 'kWh'}}, {'startDate': '2021-01-01T00:00:00Z', 'gridConsumption': {'value': 0.0, 'unit': 'kWh'}, 'gridFeedIn': {'value': 0.0, 'unit': 'kWh'}, 'storageLoad': {'value': 0.0, 'unit': 'kWh'}, 'storageConsumption': {'value': 0.0, 'unit': 'kWh'}, 'storageLevel': {'value': 0.0, 'unit': '%'}, 'generation': {'value': 0.0, 'unit': 'kWh'}, 'totalUsage': {'value': 0.0, 'unit': 'kWh'}}, {'startDate': '2022-01-01T00:00:00Z', 'gridConsumption': {'value': 0.0, 'unit': 'kWh'}, 'gridFeedIn': {'value': 0.0, 'unit': 'kWh'}, 'storageLoad': {'value': 0.0, 'unit': 'kWh'}, 'storageConsumption': {'value': 0.0, 'unit': 'kWh'}, 'storageLevel': {'value': 0.0, 'unit': '%'}, 'generation': {'value': 0.0, 'unit': 'kWh'}, 'totalUsage': {'value': 0.0, 'unit': 'kWh'}}, {'startDate': '2023-01-01T00:00:00Z', 'gridConsumption': {'value': 0.0, 'unit': 'kWh'}, 'gridFeedIn': {'value': 0.0, 'unit': 'kWh'}, 'storageLoad': {'value': 0.0, 'unit': 'kWh'}, 'storageConsumption': {'value': 0.0, 'unit': 'kWh'}, 'storageLevel': {'value': 0.0, 'unit': '%'}, 'generation': {'value': 0.0, 'unit': 'kWh'}, 'totalUsage': {'value': 0.0, 'unit': 'kWh'}}, {'startDate': '2024-01-01T00:00:00Z', 'gridConsumption': {'value': 0.0, 'unit': 'kWh'}, 'gridFeedIn': {'value': 0.0, 'unit': 'kWh'}, 'storageLoad': {'value': 0.0, 'unit': 'kWh'}, 'storageConsumption': {'value': 0.0, 'unit': 'kWh'}, 'storageLevel': {'value': 0.0, 'unit': '%'}, 'generation': {'value': 0.0, 'unit': 'kWh'}, 'totalUsage': {'value': 0.0, 'unit': 'kWh'}}]}
2024-08-13 14:26:42.861 DEBUG (MainThread) [custom_components.senec.pysenec_ha] ***** APP-API: app_update_tech_data(self) ********
2024-08-13 14:26:42.861 DEBUG (MainThread) [custom_components.senec.pysenec_ha] ***** APP-API: app_get_data(self) ********
2024-08-13 14:26:42.861 DEBUG (MainThread) [custom_components.senec.pysenec_ha] APP-API get https://app-gateway.prod.senec.dev/v1/senec/systems/287927/technical-data
2024-08-13 14:26:43.454 DEBUG (MainThread) [custom_components.senec.pysenec_ha] APP-API response: {'systemOverview': {'systemId': 287927, 'hid': None, 'productName': 'SENEC.Home V3 hybrid duo', 'installationDate': 1689862846000}, 'casing': {'serial': 'DE-V3-HD-04LI10-201687', 'temperatureInCelsius': 33.55098342895508}, 'mcu': {'mainControllerSerial': 'S1048599808601357909455925', 'mainControllerState': {'name': 'FERNABSCHALTUNG', 'severity': 'WARNING'}, 'firmwareVersion': '827', 'guiVersion': 967}, 'warranty': {'endDate': 2005509600000, 'warrantyTermInMonths': 120}, 'batteryModules': [{'ordinal': 1, 'state': {'state': 'OK', 'severity': 'INFO'}, 'vendor': 'BMZ', 'serialNumber': '47024221', 'firmwareVersion': '3.96.37', 'mainboardHardwareVersion': '3002', 'mainboardExtensionHardwareVersion': '2', 'minTemperature': 20.0, 'maxTemperature': 21.0, 'lastContact': {'time': 1710062773000, 'timestamp': '2024-03-10T09:26:13Z', 'severity': 'WARNING'}, 'flags': []}, {'ordinal': 2, 'state': {'state': 'OK', 'severity': 'INFO'}, 'vendor': 'BMZ', 'serialNumber': '47024219', 'firmwareVersion': '3.96.37', 'mainboardHardwareVersion': '3002', 'mainboardExtensionHardwareVersion': '2', 'minTemperature': 20.0, 'maxTemperature': 21.0, 'lastContact': {'time': 1710062773000, 'timestamp': '2024-03-10T09:26:13Z', 'severity': 'WARNING'}, 'flags': []}, {'ordinal': 3, 'state': {'state': 'OK', 'severity': 'INFO'}, 'vendor': 'BMZ', 'serialNumber': '47024210', 'firmwareVersion': '3.96.37', 'mainboardHardwareVersion': '3002', 'mainboardExtensionHardwareVersion': '2', 'minTemperature': 21.0, 'maxTemperature': 21.0, 'lastContact': {'time': 1710062773000, 'timestamp': '2024-03-10T09:26:13Z', 'severity': 'WARNING'}, 'flags': []}], 'batteryInverter': {'state': {'name': None, 'severity': None}, 'vendor': None, 'firmware': {'firmwareVersion': None, 'firmwareVersionHumanMachineInterface': None, 'firmwareVersionPowerUnit': None, 'firmwareVersionBidirectionalDcConverter': None}, 'temperatures': {'amb': None, 'halfBridge1': None, 'halfBridge2': None, 'throttle': None, 'max': None}, 'lastContact': {'time': 61675682400000, 'timestamp': '3924-06-04T22:00:00Z', 'severity': 'ERROR'}, 'flags': []}, 'batteryPack': {'numberOfBatteryModules': 3, 'technology': 'LITHIUM_ION', 'maxCapacityInKwh': 7.5, 'maxChargingPowerInKw': 1.875, 'maxDischargingPowerInKw': 3.75, 'currentChargingLevelInPercent': 0.0, 'currentVoltageInV': 0.0, 'currentCurrentInA': 0.0, 'remainingCapacityInPercent': 99.0}, 'installer': {'companyName': 'Hatra Energie GmbH', 'email': 'info@hatrapv.de', 'phoneNumber': '+49 176 70929838', 'address': {'street': 'Unterreut', 'houseNumber': '6', 'postcode': '76135', 'city': 'Karlsruhe', 'countryCode': 'DE', 'region': 'Baden-Württemberg', 'longitude': 8.371176, 'latitude': 48.993487, 'timezone': 'Europe/Berlin'}, 'onlineMonitoringAllowed': True, 'website': 'www.hatrapv.de'}, 'slaveSystemInfoDtos': []}
2024-08-13 14:26:43.454 INFO (MainThread) [custom_components.senec.pysenec_ha] ***** authenticate(self) ********
2024-08-13 14:26:43.767 ERROR (MainThread) [custom_components.senec] Error fetching senec data: 
2024-08-13 14:26:43.768 DEBUG (MainThread) [custom_components.senec] Finished fetching senec data in 2.299 seconds (success: False)
marq24 commented 1 month ago

UPDATE - please ignore my initial reply - I was able to reproduce the problem locally and was able to fix the root cause of the issue - just update to the new Version - TIA

initial post:

ok - for now please be so kind and disable the following sensors (of the webAPI integration):

*_gridexport_limit *_peakshaving_mode *_peakshaving_capacitylimit *_peakshaving_enddate

and then restart HA... this should TEMP fix the issue (till I found the root cause)

marq24 commented 1 month ago

First of all sorry - for the "auto-close" (caused by my commit) - my normal procedure is, to release the fix and get the confirmation by the reporter, that the issue is solved before closing the issue - might be that it is just TOO LATE (and I should had gone to bed already)...

Thanks for reporting this issue. It is related to #95.

Unfortunately my update (to fix #95) was not tested enough (in all conditions) - There was still parts that failed (after the update of the aiohttp lib (that was done with the HA 2024.8.x update)). So when one of the peak-shaving sensors have been enabled, then the issue (you have reported) occur.

The reason for that is, that cause of a earlier bug in the aiohttp-lib my SENEC integration contains a aiohttp-lib patch - this patch should be (of course) only applied when the lib version is below 3.9 - this version comparison failed (cause I am a Python noob). All that is fixed with the release of 2024.8.3.

Please let me know, if the update will solve the issue also for you - TIA

KalleRau commented 1 month ago

Thanks for the quick response.

The update to version 8.3 did fix the issue.

The intergration works again like expected.

Thanks again for the your help. Keep up the good work.

👍 😄 👍