JasperE84 / PyFusionSolarDataRelay

Interface to relay PV inverter data from FusionSolar public kiosk mode to InfluxDB/VictoriaMetrics, PVOutput.org, MQTT and Home Assistant
MIT License
20 stars 2 forks source link

Docker errors #12

Closed jonas1015119 closed 10 months ago

jonas1015119 commented 10 months ago

Docker gives me this error message every time the script runs. I've only configured it for pvoutput and can't really understand what the issue is.

2023-11-05 14:30:00 2023-11-05 13:30:00,001 - root - INFO - Requesting data from FusionSolar Kiosk API... 2023-11-05 14:30:00 2023-11-05 13:30:00,001 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): region04eu5.fusionsolar.huawei.com:443 2023-11-05 14:30:00 2023-11-05 13:30:00,990 - urllib3.connectionpool - DEBUG - https://region04eu5.fusionsolar.huawei.com:443 "GET /pvmswebsite/nologin/assets/build/index.html HTTP/1.1" 200 None 2023-11-05 14:30:01 2023-11-05 13:30:01,001 - root - ERROR - Uncaught exception in FusionSolar data processing loop. 2023-11-05 14:30:01 Traceback (most recent call last): 2023-11-05 14:30:01 File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 971, in json 2023-11-05 14:30:01 return complexjson.loads(self.text, *kwargs) 2023-11-05 14:30:01 File "/usr/local/lib/python3.10/json/init.py", line 346, in loads 2023-11-05 14:30:01 return _default_decoder.decode(s) 2023-11-05 14:30:01 File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode 2023-11-05 14:30:01 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 2023-11-05 14:30:01 File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode 2023-11-05 14:30:01 raise JSONDecodeError("Expecting value", s, err.value) from None 2023-11-05 14:30:01 json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 2023-11-05 14:30:01 2023-11-05 14:30:01 During handling of the above exception, another exception occurred: 2023-11-05 14:30:01 2023-11-05 14:30:01 Traceback (most recent call last): 2023-11-05 14:30:01 File "/code/pvfusionsolar.py", line 29, in fetch_fusionsolar_status 2023-11-05 14:30:01 response_json = response.json() 2023-11-05 14:30:01 File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 975, in json 2023-11-05 14:30:01 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) 2023-11-05 14:30:01 requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 2023-11-05 14:30:01 2023-11-05 14:30:01 During handling of the above exception, another exception occurred: 2023-11-05 14:30:01 2023-11-05 14:30:01 Traceback (most recent call last): 2023-11-05 14:30:01 File "/code/pvrelay.py", line 34, in process_fusionsolar_request 2023-11-05 14:30:01 fusionsolar_json_data = self.pvfusionsolar.fetch_fusionsolar_status() 2023-11-05 14:30:01 File "/code/pvfusionsolar.py", line 31, in fetch_fusionsolar_status 2023-11-05 14:30:01 raise Exception( 2023-11-05 14:30:01 Exception: Error while parsing JSON response from Kiosk API: 'Expecting value: line 1 column 1 (char 0)' 2023-11-05 14:30:01 2023-11-05 13:30:01,002 - root - DEBUG - Waiting for next FusionSolar interval... 2023-11-05 14:30:01 2023-11-05 13:30:01,002 - apscheduler.executors.default - INFO - Job "PvRelay.process_fusionsolar_request (trigger: cron[hour='', minute='0,30'], next run at: 2023-11-05 14:00:00 UTC)" executed successfully

JasperE84 commented 10 months ago

The relevant bit here is "Error while parsing JSON response from Kiosk API: 'Expecting value: line 1 column 1 (char 0)'". PyFusonSolar is trying to json decode the output from your Fusionsolar kiosk API and fails to decode the json.

Most likely your fusionsolarkkid config parameter does not have the correct value, the public kiosk in fusionsolar somehow got disabled, or there's something wrong with your fusionsolarurl (like for instance you're in a different region).

Check the kiosk URL you get from fusionsolar to see if the fusionsolarurl matches the configured setting, then check the kkid.

JasperE84 commented 10 months ago

I added some more descriptive exception logging in commit 7d1699f4c55b2216038eab869ab3f234d38a8ab0 and version 1.0.6 ( https://github.com/JasperE84/PyFusionSolarDataRelay/releases/tag/1.0.6 ) Docker container has been updated

jonas1015119 commented 10 months ago

updated. just to make sure, these are the only variables in pvconfig I changed

I noticed the MQTT config and some other require the fusion solar login and password, does PVOutput work with just the api key? Does the pvsysname matter to PVOutput?

new log: looks like it pulled the kiosk data successfully, so the wrong region was the issue earlier, but theres an error when sending it to pvoutput, something about a header ("Header part (100) from ('X-Pvoutput-SystemId', 100) must be of type str or bytes, not <class 'int'>") and my pvoutput id and something about timezones? the default pvoutputsystemid is not written in quotes (self.pvoutputsystemid = 123456), does it need to be when I change it? do I have to changed the timezone from UTC or does PVOutput just use the one I set there? whats the correct format? "etc/UTC+1" or "etc/Europe/Berlin"?

sorry to take up your time with this.

2023-11-06 02:29:12 2023-11-06 01:29:12,883 - root - INFO - Requesting data from FusionSolar Kiosk API... 2023-11-06 02:29:12 2023-11-06 01:29:12,885 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): region04eu5.fusionsolar.huawei.com:443 2023-11-06 02:29:15 /usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py:1100: InsecureRequestWarning: Unverified HTTPS request is being made to host 'region04eu5.fusionsolar.huawei.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings 2023-11-06 02:29:15 warnings.warn( 2023-11-06 02:29:16 2023-11-06 01:29:16,201 - urllib3.connectionpool - DEBUG - https://region04eu5.fusionsolar.huawei.com:443 "GET /rest/pvms/web/kiosk/v1/station-kiosk-file?kk= HTTP/1.1" 200 None 2023-11-06 02:29:16 2023-11-06 01:29:16,437 - root - DEBUG - FusionSolar API data: {'realTimePower': 0.0, 'cumulativeEnergy': 77190.0, 'monthEnergy': 77190.0, 'dailyEnergy': 0.0, 'yearEnergy': 77190.0} [clearly its pulling the correct data from PVOutput] 2023-11-06 02:29:16 2023-11-06 01:29:16,438 - root - DEBUG - Writing PV data to InfluxDB skipped, InfluxDB client was not initialized yet. 2023-11-06 02:29:16 2023-11-06 01:29:16,438 - root - INFO - Writing to PVOutput. Header: {'X-Pvoutput-Apikey': ' ', 'X-Pvoutput-SystemId': 10_ 0} Data: {'d': '20231106', 't': '01:29', 'v1': 77190.0, 'v2': 0.0, 'c1': 2} [the time seems to be off by an hour, so I guessI need to change that] 2023-11-06 02:29:16 2023-11-06 01:29:16,439 - root - ERROR - Error writing PV data to PVOutput.org 2023-11-06 02:29:16 Traceback (most recent call last): 2023-11-06 02:29:16 File "/code/pvoutputorg.py", line 30, in write_pvdata_to_pvoutput 2023-11-06 02:29:16 api_response = requests.post( 2023-11-06 02:29:16 File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 115, in post 2023-11-06 02:29:16 return request("post", url, data=data, json=json, kwargs) 2023-11-06 02:29:16 File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request 2023-11-06 02:29:16 return session.request(method=method, url=url, kwargs) 2023-11-06 02:29:16 File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 575, in request 2023-11-06 02:29:16 prep = self.prepare_request(req) 2023-11-06 02:29:16 File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 486, in prepare_request 2023-11-06 02:29:16 p.prepare( 2023-11-06 02:29:16 File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 369, in prepare 2023-11-06 02:29:16 self.prepare_headers(headers) 2023-11-06 02:29:16 File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 491, in prepare_headers 2023-11-06 02:29:16 check_header_validity(header) 2023-11-06 02:29:16 File "/usr/local/lib/python3.10/site-packages/requests/utils.py", line 1040, in check_header_validity 2023-11-06 02:29:16 _validate_header_part(header, value, 1) 2023-11-06 02:29:16 File "/usr/local/lib/python3.10/site-packages/requests/utils.py", line 1049, in _validate_headerpart 2023-11-06 02:29:16 raise InvalidHeader( 2023-11-06 02:29:16 requests.exceptions.InvalidHeader: Header part (100) from ('X-Pvoutput-SystemId', 10_0) must be of type str or bytes, not <class 'int'> 2023-11-06 02:29:16 2023-11-06 02:29:16 During handling of the above exception, another exception occurred: 2023-11-06 02:29:16 2023-11-06 02:29:16 Traceback (most recent call last): 2023-11-06 02:29:16 File "/code/pvrelay.py", line 52, in write_pvdata_to_pvoutput 2023-11-06 02:29:16 self.pvoutput.write_pvdata_to_pvoutput(fusionsolar_json_data) 2023-11-06 02:29:16 File "/code/pvoutputorg.py", line 37, in write_pvdata_to_pvoutput 2023-11-06 02:29:16 raise Exception( 2023-11-06 02:29:16 Exception: Exception while posting data to PVOutput: 'Header part (10__0) from ('X-Pvoutput-SystemId', 100) must be of type str or bytes, not <class 'int'>' 2023-11-06 02:29:16 2023-11-06 01:29:16,440 - root - DEBUG - MQTT PV data publishing disabled 2023-11-06 02:29:16 2023-11-06 01:29:16,440 - root - DEBUG - Waiting for next FusionSolar interval... 2023-11-06 02:29:16 2023-11-06 01:29:16,440 - tzlocal - DEBUG - /etc/timezone found, contents: 2023-11-06 02:29:16 Etc/UTC 2023-11-06 02:29:16 2023-11-06 02:29:16 2023-11-06 01:29:16,440 - tzlocal - DEBUG - /etc/localtime found 2023-11-06 02:29:16 2023-11-06 01:29:16,441 - tzlocal - DEBUG - 2 found: 2023-11-06 02:29:16 {'/etc/timezone': 'Etc/UTC', '/etc/localtime is a symlink to': 'Etc/UTC'} 2023-11-06 02:29:16 2023-11-06 01:29:16,444 - apscheduler.scheduler - INFO - Adding job tentatively -- it will be properly scheduled when the scheduler starts 2023-11-06 02:29:16 2023-11-06 01:29:16,444 - apscheduler.scheduler - INFO - Added job "PvRelay.process_fusionsolar_request" to job store "default" 2023-11-06 02:29:16 2023-11-06 01:29:16,444 - apscheduler.scheduler - INFO - Scheduler started 2023-11-06 02:29:16 2023-11-06 01:29:16,444 - apscheduler.scheduler - DEBUG - Looking for jobs to run 2023-11-06 02:29:16 2023-11-06 01:29:16,444 - apscheduler.scheduler - DEBUG - Next wakeup is due at 2023-11-06 01:30:00+00:00 (in 43.555061 seconds)