flopp999 / NIBEmyUplink-Domoticz

0 stars 0 forks source link

Error each time after pulling in data #4

Open artenverho opened 2 months ago

artenverho commented 2 months ago

Hi,

I followed the instructions and it seems the plug-in pulls in data but then gives me these errors:

2024-06-07 22:56:55.702 Error: Nibe: Call to function 'onMessage' failed, exception details:
2024-06-07 22:56:55.704 Error: Nibe: Traceback (most recent call last):
2024-06-07 22:56:55.704 Error: Nibe: File "~/domoticz/plugins/NIBEmyUplink/plugin.py", line 448, in onMessage
2024-06-07 22:56:55.704 Error: Nibe: _plugin.onMessage(Connection, Data)
2024-06-07 22:56:55.705 Error: Nibe: File “~/domoticz/plugins/NIBEmyUplink/plugin.py", line 232, in onMessage
2024-06-07 22:56:55.705 Error: Nibe: UpdateDevice(str(each["value"]), each["parameterUnit"], each["parameterName"], int(each["parameterId"]))
2024-06-07 22:56:55.705 Error: Nibe: File "~/domoticz/plugins/NIBEmyUplink/plugin.py", line 396, in UpdateDevice
2024-06-07 22:56:55.705 Error: Nibe: if (ID not in Devices):
2024-06-07 22:56:55.705 Error: Nibe: UnboundLocalError: local variable 'ID' referenced before assignment

No devices are listed yet but the log shows a lot of data from my heat pump just prior to the aforementioned errors: Nibe: [{'category': 'F1255-6 R PC', 'parameterId': '30200', 'parameterName': 'slave 1', 'parameterUnit': '(EB101)', 'writable': True, 'timestamp': '2024-06-06T20:06:06+00:00', 'value': 0.0, 'strVal': '0(EB101)', 'smartHomeCategories': [], 'minValue': 0.0, 'maxValue': 1.0, 'stepValue': 1.0, 'enumValues': [], 'scaleValue': '1', 'zoneId': None}, {'category': 'F1255-6 R PC', 'parameterId': '30201', 'parameterName': 'slave 2', 'parameterUnit': '(EB102)', 'writable': True, 'timestamp': '2024-06-06T20:06:06+00:00', 'value': 0.0, 'strVal': '0(EB102)', 'smartHomeCategories': [], 'minValue': 0.0, 'maxValue': 1.0, 'stepValue': 1.0, 'enumValues': [], 'scaleValue': '1', 'zoneId': None}, {'category': 'F1255-6 R PC', 'parameterId': '30 Etc…

Any idea what might be the cause?

artenverho commented 2 months ago

I made a (dodgy) fix:

if PID in locals():
        if (ID not in Devices):
            if Unit == "°C":
                Domoticz.Device(Name=Name, Unit=ID, TypeName="Temperature", Used=1, Description="ParameterID="+str(PID)).Create()
            else:
                Domoticz.Device(Name=Name, Unit=ID, TypeName="Custom", Options={"Custom": "0;"+Unit}, Used=1, Description="ParameterID="+str(PID)).Create()

        if (ID in Devices):
            if Devices[ID].sValue != sValue:
                Devices[ID].Update(0, str(sValue))

It does work now but only for one datapoint. After that it gives me the following error:

 2024-06-08 14:26:24.337 Error: Nibe: Status 400
2024-06-08 14:26:24.338 Error: Nibe: {'Status': '400', 'Headers': {'Date': 'Sat, 08 Jun 2024 12:26:24 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Request-Context': 'appId=cid-v1:18e838c9-6669-41ea-9b51-49d8afcfcb7f', 'Content-Security-Policy': "default-src 'none'; frame-ancestors 'none'", 'traceparent': '00-97a11a21e3e91b4d7ec678c8df10b42d-31df616992e2c798-00', 'Request-Id': '97a11a21e3e91b4d7ec678c8df10b42d', 'X-Frame-Options': 'SAMEORIGIN', 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'strict-origin-when-cross-origin'}, 'Data': b'{"error":"invalid_grant","error_description":"check authorization server configuration","code":"invalid_grant","description":"check authorization server configuration","timestamp":"2024-06-08T12:26:24.3065138+00:00"}'}