CreasolTech / domoticz-hyundai-kia

9 stars 4 forks source link

Error: KIA: Counter Check of device EVENERGYCONSTOTAL failed. Postponing update till next time #21

Closed eekhoorn closed 1 month ago

eekhoorn commented 1 month ago

Since a couple of days I got this error in the domoticz log:

2024-07-27 20:59:19.769 Error: KIA: ERROR: unable to retrieve the value of device with IDX 1597 <Response [401]> 2024-07-27 20:59:19.769 Error: KIA: Counter Check of device EVENERGYCONSTOTAL failed. Postponing update till next time

Device IDX 1597 is: | NiroEV: EV energy Consumed | General | Counter Incremental | 0.000 kWh

I have already updated the api and plugin according the instructions.

CreasolTech commented 1 month ago

Do you have a device with IDX 1597 for the hyundai-kia plugin?

eekhoorn commented 1 month ago

Yes, this one: Device IDX 1597 is: | NiroEV: EV energy Consumed | General | Counter Incremental | 0.000 kWh this device was "auto created" by your plugin

eekhoorn commented 1 month ago

Similar error for device 1598 (also auto created): 2024-07-29 12:01:54.380 Error: KIA: ERROR: unable to retrieve the value of device with IDX 1597 <Response [401]> 2024-07-29 12:01:54.382 Error: KIA: Counter Check of device EVENERGYCONSTOTAL failed. Postponing update till next time 2024-07-29 12:01:54.395 Error: KIA: ERROR: unable to retrieve the value of device with IDX 1598 <Response [401]> 2024-07-29 12:01:54.396 Error: KIA: Counter Check of device EVENERGYREGENTOTAL failed. Postponing update till next time

Device chacteristics: 1598 | KIA | 001E00E7 | 231 | NiroEV: EV energy Regenerated | General | Counter Incremental | 0.000 kWh

CreasolTech commented 1 month ago

Please update the plugin (plugin.py): I've not fixed the error ( @WillemD61 is who can solve this), but an additional log line will be added with the called URL, so you can check by yourself using the web browser. In any case, check that in Setup -> Settings -> Security -> Trusted networks you have 127.0.0.1

WillemD61 commented 1 month ago

You are saying "since a couple of days" ? So was it running before and were those two devices update then?

What happened between "before"and "now" that could have triggered the error? Did you update domoticz? Did you update the plugin?

If you run http://DomoticzIP:DomoticzPort/json.htm?type=command&param=getdevices&rid=1597 in a brower, do you then get the status of the device or do you get the same error? (of course replacing DomoticzIP and DomoticzPort by the config of your installation)

eekhoorn commented 1 month ago

I did:

This is the output of the http call: { "ActTime" : 1722331141, "AstrTwilightEnd" : "00:40", "AstrTwilightStart" : "02:43", "CivTwilightEnd" : "22:12", "CivTwilightStart" : "05:11", "DayLength" : "15:37", "NautTwilightEnd" : "23:10", "NautTwilightStart" : "04:13", "ServerTime" : "2024-07-30 11:19:01", "SunAtSouth" : "13:41", "Sunrise" : "05:53", "Sunset" : "21:30", "app_version" : "2024.7", "result" : [ { "AddjMulti" : 1.0, "AddjMulti2" : 1.0, "AddjValue" : 0.0, "AddjValue2" : 0.0, "BatteryLevel" : 255, "Counter" : "0.000 kWh", "CounterToday" : "0.000 kWh", "CustomImage" : 0, "Data" : "0.000 kWh", "Description" : "", "Divider" : 1000.0, "Favorite" : 0, "HardwareDisabled" : false, "HardwareID" : 30, "HardwareName" : "KIA", "HardwareType" : "Hyundai Kia connect", "HardwareTypeVal" : 94, "HaveTimeout" : false, "ID" : "001E00E6", "LastUpdate" : "2024-07-24 12:02:23", "Name" : "NiroEV: EV energy Consumed", "Notifications" : "false", "PlanID" : "0", "PlanIDs" : [ 0 ], "Protected" : false, "ShowNotifications" : true, "SignalLevel" : "-", "SubType" : "Counter Incremental", "SwitchTypeVal" : 0, "Timers" : "false", "Type" : "General", "TypeImg" : "counter", "Unit" : 230, "Used" : 1, "ValueQuantity" : "Custom", "ValueUnits" : "", "XOffset" : "0", "YOffset" : "0", "idx" : "1597", "price" : "0.0000" } ], "status" : "OK", "title" : "Devices" }

WillemD61 commented 1 month ago

OK, so the devices were created but never updated so far.

The question was whether the errors started after one of the updates, so the answer is yes?

Please check your security settings, as suggested by CreasolTech. Error 401 means access is not authorized.

eekhoorn commented 1 month ago

indeed: it started after one of the updates and regarding the security settings: Setup -> Settings -> Security -> Trusted networks I have 127.0.0.1

WillemD61 commented 1 month ago

I noted in your response to a previous issue that you are not using port 8080? If so, you need to adapt line 78 of the plugin code to list the port that you are using.

eekhoorn commented 1 month ago

yes, port 9090. I change it manually in plugin.py everytime after an update of the plugin

WillemD61 commented 1 month ago

yes, port 9090. I change it manually in plugin.py everytime after an update of the plugin

and then you restart to make sure that the new code is actually used in domoticz, right?

Not sure what else we can do to analyse. I would first suggest you add some debug print statement in the code from line 800 to 820 to check the json that is created is correct and to get more detail on the response, if any. And check the log file for any additional info.

and, if you are running domoticz on a raspberry for example you could run: curl "http://127.0.0.1:9090/json.htm?type=command&param=getdevices&rid=1597" and curl "http://domotizIP:9090/json.htm?type=command&param=getdevices&rid=1597" on the command line to check the result

eekhoorn commented 1 month ago

1) curl "http://127.0.0.1:9090/json.htm?type=command&param=getdevices&rid=1597" gives: { "ActTime" : 1722506409, "AstrTwilightEnd" : "00:29", "AstrTwilightStart" : "02:54", "CivTwilightEnd" : "22:08", "CivTwilightStart" : "05:14", "DayLength" : "15:31", "NautTwilightEnd" : "23:05", "NautTwilightStart" : "04:18", "ServerTime" : "2024-08-01 12:00:09", "SunAtSouth" : "13:41", "Sunrise" : "05:56", "Sunset" : "21:27", "app_version" : "2024.7", "result" : [ { "AddjMulti" : 1.0, "AddjMulti2" : 1.0, "AddjValue" : 0.0, "AddjValue2" : 0.0, "BatteryLevel" : 255, "Counter" : "0.000 kWh", "CounterToday" : "0.000 kWh", "CustomImage" : 0, "Data" : "0.000 kWh", "Description" : "", "Divider" : 1000.0, "Favorite" : 0, "HardwareDisabled" : false, "HardwareID" : 30, "HardwareName" : "KIA", "HardwareType" : "Hyundai Kia connect", "HardwareTypeVal" : 94, "HaveTimeout" : false, "ID" : "001E00E6", "LastUpdate" : "2024-07-24 12:02:23", "Name" : "NiroEV: EV energy Consumed", "Notifications" : "false", "PlanID" : "0", "PlanIDs" : [ 0 ], "Protected" : false, "ShowNotifications" : true, "SignalLevel" : "-", "SubType" : "Counter Incremental", "SwitchTypeVal" : 0, "Timers" : "false", "Type" : "General", "TypeImg" : "counter", "Unit" : 230, "Used" : 1, "ValueQuantity" : "Custom", "ValueUnits" : "", "XOffset" : "0", "YOffset" : "0", "idx" : "1597", "price" : "0.0000" } ], "status" : "OK", "title" : "Devices"

2) curl "http://192.168.2.xxx:9090/json.htm?type=command&param=getdevices&rid=1597" gives: { "ActTime" : 1722506191, "AstrTwilightEnd" : "00:29", "AstrTwilightStart" : "02:54", "CivTwilightEnd" : "22:08", "CivTwilightStart" : "05:14", "DayLength" : "15:31", "NautTwilightEnd" : "23:05", "NautTwilightStart" : "04:18", "ServerTime" : "2024-08-01 11:56:31", "SunAtSouth" : "13:41", "Sunrise" : "05:56", "Sunset" : "21:27", "app_version" : "2024.7", "result" : [ { "AddjMulti" : 1.0, "AddjMulti2" : 1.0, "AddjValue" : 0.0, "AddjValue2" : 0.0, "BatteryLevel" : 255, "Counter" : "0.000 kWh", "CounterToday" : "0.000 kWh", "CustomImage" : 0, "Data" : "0.000 kWh", "Description" : "", "Divider" : 1000.0, "Favorite" : 0, "HardwareDisabled" : false, "HardwareID" : 30, "HardwareName" : "KIA", "HardwareType" : "Hyundai Kia connect", "HardwareTypeVal" : 94, "HaveTimeout" : false, "ID" : "001E00E6", "LastUpdate" : "2024-07-24 12:02:23", "Name" : "NiroEV: EV energy Consumed", "Notifications" : "false", "PlanID" : "0", "PlanIDs" : [ 0 ], "Protected" : false, "ShowNotifications" : true, "SignalLevel" : "-", "SubType" : "Counter Incremental", "SwitchTypeVal" : 0, "Timers" : "false", "Type" : "General", "TypeImg" : "counter", "Unit" : 230, "Used" : 1, "ValueQuantity" : "Custom", "ValueUnits" : "", "XOffset" : "0", "YOffset" : "0", "idx" : "1597", "price" : "0.0000" } ], "status" : "OK", "title" : "Devices"

Domoticz network settings are: 192.168.2.;10.58.3.;10.8.0.*;127.0.0.1

CreasolTech commented 1 month ago

Try to put in your Domoticz -> Setup -> Settings -> Security 127.0.0.1;::1;192.168.2.*;10.58.3.*;10.8.0.*

WillemD61 commented 1 month ago

Strange, in my mail I got your message that 127.0.0.1 did result in error 401 but here on-line I see that it gave the data? What is it?

There is another domoticz security setting. I am not sure whether this is needed but in my installation the Allow Basic-Auth authentication over plain HTTP (API only). is set to green. How is it in yours? Worth a try.

As a workaround you could untimately replace 127.0.0.1 in the code with your actual domoticzIP number but then we will never know the real cause.

eekhoorn commented 1 month ago

Strange, in my mail I got your message that 127.0.0.1 did result in error 401 but here on-line I see that it gave the data? What is it? I was on the wrong raspberry server first, therefore I got an error for localhost. After logging in on the domoticz server, I changed the network settings on the domoticz server to 127.0.0.1;::1;192.168.2.;10.58.3.;10.8.0.* I'll wait further.

eekhoorn commented 1 month ago

Update: topic can be closed: both devices are now updated! Changing network settings was probably the solution. Thanks for your support!