lokonli / domoticz-wallbox

1 stars 2 forks source link

Total Energy Wrong #3

Closed sincze closed 1 year ago

sincze commented 1 year ago

After noticing an increase in my Domoticz error.log i started an investigation. I noticed the newly created device is trying to write this in my Database.

image

2023-08-16 22:35:41.540 Status: LUA: Calling URL: Printing values d=Wallbox Total Energy s=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;347733

Any ideas on why it tries with so many 0;s in front of the real usage??

This is the LUA script I use to look at the data.

-- LUA Script adapted on 25-06-2023

--print ('Script NEW lua called')

commandArray={}
local function isRealSensor(name)
        return otherdevices_idx[name]
end

for d, s in pairs(devicechanged) do
--      print ("Calling URL: Printing values d="..d.." s="..s)
        if isRealSensor(d) then
                os.execute('wget -O /dev/null -o /dev/null "http://127.0.0.1/secure2/pass2php.php?d='..d..'&s='..s..'" &')
--              print ("URL HAS BEEN CALLED for: "..d.." with value s="..s)
        end
end
return commandArray
sincze commented 1 year ago

Seems like with the new plugin version the Domoticz DB has been growing rapidly as well. Normally steady at 60 now up to 90 MB.

-rw-r----- 1 pi pi 61794304 Aug  1 00:00 backup-day-01-Domoticz.db
-rw-r----- 1 pi pi 61873152 Aug  2 00:00 backup-day-02-Domoticz.db
-rw-r----- 1 pi pi 62081024 Aug  3 00:00 backup-day-03-Domoticz.db
-rw-r----- 1 pi pi 62280704 Aug  4 00:00 backup-day-04-Domoticz.db
-rw-r----- 1 pi pi 62288896 Aug  5 00:00 backup-day-05-Domoticz.db
-rw-r----- 1 pi pi 62138368 Aug  6 00:00 backup-day-06-Domoticz.db
-rw-r----- 1 pi pi 61468672 Aug  7 00:00 backup-day-07-Domoticz.db
-rw-r----- 1 pi pi 62426112 Aug  8 00:00 backup-day-08-Domoticz.db
-rw-r----- 1 pi pi 62354432 Aug  9 00:00 backup-day-09-Domoticz.db
-rw-r----- 1 pi pi 63623168 Aug 10 00:00 backup-day-10-Domoticz.db
-rw-r----- 1 pi pi 67091456 Aug 11 00:00 backup-day-11-Domoticz.db
-rw-r----- 1 pi pi 70584320 Aug 12 00:00 backup-day-12-Domoticz.db
-rw-r----- 1 pi pi 73987072 Aug 13 00:00 backup-day-13-Domoticz.db
-rw-r----- 1 pi pi 77767680 Aug 14 00:00 backup-day-14-Domoticz.db
-rw-r----- 1 pi pi 82747392 Aug 15 00:00 backup-day-15-Domoticz.db
-rw-r----- 1 pi pi 85959680 Aug 16 00:00 backup-day-16-Domoticz.db
-rw-r----- 1 pi pi 90005504 Aug 17 00:00 backup-day-17-Domoticz.db
-rw-r----- 1 pi pi 61428736 Jul 18 00:00 backup-day-18-Domoticz.db

On the 9th of august the plugin had the following devices:

Wallbox Charger Lock
Wallbox Status
Wallbox Resume Charging
Wallbox Pause Charging
Wallbox Charging  (A)
Wallbox Charging start stop
Wallbox Session (kWh)

On the 10th of august the plugin had the following devices:

Wallbox Charger Lock
Wallbox Status
Wallbox Resume Charging
Wallbox Pause Charging
Wallbox Charging  (A)
Wallbox Charging start stop
Wallbox Session (kWh)
Wallbox Total Energy

Wallbox Total Energy device already contained the 000000 in the sValue table.

sincze commented 1 year ago

First I modified the Database value, (removing all the 0000 except 1). but after domoticz restart the 00000 were returned.

Then I removed the hardware item 'wallbox total energy' to have the plugin create a new version. image The 0000 returned instantly as sValue..

So there must be something wrong in the code.

myUnit.sValue = f"{chargingCurrent * 1000};{str(newValue)

Current used to be in A, but then again this sensor expects Watt / kWh.

sincze commented 1 year ago

After modification, size of Domoticz.DB went down with 1/3 (from 90 to 60 DB), of the size we had seen earlier..

64583680 Aug 17 22:45 domoticz.db

sincze commented 1 year ago

Merged.