[solved] Checking persistent data with history, while the script initializes, gives an error
Posted: Wednesday 20 June 2018 23:05
Checking persistent data with history, while the script initializes, gives an error. The result is that the script stops and doesn't create the __data xyz file with a fresh first data point.
This part of the script makes it stop when I try to run it for the first time. With 'history true' you can't give an initial value
This is a real pity, because the script can't check the value of the data, because it might be 'nil' which still causes the script to quit. On the other hand when I simply .add (0) I might overwrite an existing value every minute, while that is not wanted.
Luckily I had an other device that I could check the 'latest update' from and use that as a decision whether it was safe to put a '0' value in there. Now the __data file is created, I could use the above code again (but of course it doesn't make sense anymore).
This part of the script makes it stop when I try to run it for the first time. With 'history true' you can't give an initial value
Code: Select all
local counter = domoticz.data.showerCounter
if counter.getLatest().data == nil then
counter.add(0)
domoticz.log('ShowerCounter op 0 gezet, initial')
endLuckily I had an other device that I could check the 'latest update' from and use that as a decision whether it was safe to put a '0' value in there. Now the __data file is created, I could use the above code again (but of course it doesn't make sense anymore).