Page 1 of 1
problems with Persistent data when upgrading to 2.2.0 [SOLVED]
Posted: Wednesday 02 August 2017 9:10
by gus
Hi,
First of all, big thanks for your hard work on Dzvents!
Yesterday I upgraded my Domoticz to 3.8153 release. Then, after adjusted my scripts to 2.xx req I have problems with persistent data in my scripts. It seems like the _xxx.lua scripts not beeing created in the Data folder.
Would be glad if someone could help me getting forward in this matter, I don't want to fill up Domoticz variables with all of my data...
Error code on Domoticz:
Code: Select all
2017-08-02 09:05:00.280 Error: dzVents: Error: An error occured when calling event handler DisplayDevelopment_new
2017-08-02 09:05:00.280 Error: dzVents: Error: ...oticz/scripts/dzVents/scripts/DisplayDevelopment_new.lua:107: attempt to compare nil with number
Sample of my data section:
Code: Select all
data = {
barometer_old = {initial=0},
balja_old = {initial=0},
utetemp_old = {initial=0},
vindgust_old = {initial=0},
regn_old = {initial=0},
dorrar_old = {initial=0},
hour_old = {initial=0}
},
Re: problems with Persistent data when upgrading to 2.2.0
Posted: Wednesday 02 August 2017 9:22
by dannybloe
Can you paste the entire script here?
Re: problems with Persistent data when upgrading to 2.2.0
Posted: Wednesday 02 August 2017 9:31
by gus
Of course!
Code: Select all
-- ------------------------------------
-- Hantering av display --
-- ------------------------------------
return {
active = true,
on = {
timer = {
'every minute'
}
},
data = {
barometer_old = {initial=0},
balja_old = {initial=0},
utetemp_old = {initial=0},
vindgust_old = {initial=0},
regn_old = {initial=0},
dorrar_old = {initial=0},
hour_old = {initial=0}
},
execute = function(domoticz)
local function roundToNthDecimal(num, n)
local mult = 10^(n or 0)
return math.floor(num * mult + 0.5) / mult
end
local barometer = (domoticz.devices('Barometer').barometer)
local balja = (domoticz.devices('Temp to Pool').temperature)
local utetemp = (domoticz.devices('Temp Veranda Ute').temperature)
local vindgust = (domoticz.devices('Wind').windgust)
local regn = (domoticz.devices('Rain').rain)
local barometer_old = domoticz.data.barometer_old
local balja_old = domoticz.data.balja_old
local utetemp_old = domoticz.data.utetemp_old
local vindgust_old = domoticz.data.vindgust_old
local regn_old = domoticz.data.regn_old
local dorrar_old = domoticz.data.dorrar_old
local hour_old = domoticz.data.hour_old
domoticz.devices('Text 1').updateText('Klockan ar ' .. os.date("%R"))
domoticz.devices('Trigger request Text 1').switchOn()
--os.execute('curl http://192.168.17.82:5005/Matrum/say/Hej maten är klar/sv-se/20')
if ((barometer) ~= (barometer_old)) then
domoticz.devices('Text 2').updateText('Lufttrycket ar ' .. (barometer) .. ' hPa')
domoticz.devices('Trigger request Text 2').switchOn()
domoticz.data.barometer_old = (barometer)
end
if ((balja) ~= (balja_old)) then
domoticz.devices('Text 3').updateText('Temp Balja ' .. (balja) .. ' Grader')
domoticz.devices('Trigger request Text 3').switchOn()
domoticz.data.balja_old = (balja)
end
if ((utetemp) ~= (utetemp_old)) then
domoticz.devices('Text 4').updateText('Utetemp ar ' .. (utetemp) .. ' Grader')
domoticz.devices('Trigger request Text 4').switchOn()
domoticz.data.utetemp_old = (utetemp)
end
if ((domoticz.devices('Lockstatus').state) ~= (dorrar_old)) then
if domoticz.devices('Lockstatus').state == 'Closed' then
domoticz.devices('Text 5').updateText('Alla dorrar ar lasta')
domoticz.devices('Trigger request Text 5').switchOn()
else domoticz.devices('Text 5').updateText('Nagot ar oppet!')
domoticz.devices('Trigger request Text 5').switchOn()
end
domoticz.data.dorrar_old = (domoticz.devices('Lockstatus').state)
end
if ((vindgust) ~= (vindgust_old)) then
if (vindgust) <= 2 then
domoticz.devices('Text 6').updateText('Det ar vindstilla')
domoticz.devices('Trigger request Text 6').switchOn()
elseif (vindgust) >= 3 then
domoticz.devices('Text 6').updateText('Det blaser nu ' .. (vindgust) .. ' m/s')
domoticz.devices('Trigger request Text 6').switchOn()
end
domoticz.data.vindgust_old = (vindgust)
end
if ((regn) ~= (regn_old)) then
if (regn) == 0 then
domoticz.devices('Text 7').updateText('Inget regn idag!')
domoticz.devices('Trigger request Text 7').switchOn()
elseif (regn) > 0 then
domoticz.devices('Text 7').updateText('Det har regnat ' .. (regn) .. ' mm!')
domoticz.devices('Trigger request Text 7').switchOn()
end
domoticz.data.regn_old = (regn)
end
if ((domoticz.time.hour) ~= (hour_old)) then
if (domoticz.time.hour) >= 0 and (domoticz.time.hour) <= 4 then
domoticz.devices('Text 8').updateText('Natti Natti!')
domoticz.devices('Trigger request Text 8').switchOn()
elseif (domoticz.time.hour) >= 5 and (domoticz.time.hour) <= 9 then
domoticz.devices('Text 8').updateText('God Morgon!')
domoticz.devices('Trigger request Text 8').switchOn()
elseif (domoticz.time.hour) >= 10 and (domoticz.time.hour) <= 16 then
domoticz.devices('Text 8').updateText('God Dag!')
domoticz.devices('Trigger request Text 8').switchOn()
elseif (domoticz.time.hour) >= 17 and (domoticz.time.hour) <= 23 then
domoticz.devices('Text 8').updateText('God Afton!')
domoticz.devices('Trigger request Text 8').switchOn()
end
domoticz.data.hour_old = (domoticz.time.hour)
end
end
}
Re: problems with Persistent data when upgrading to 2.2.0
Posted: Wednesday 02 August 2017 9:57
by dannybloe
I guess your error will now happen on another line as 107 doesn't hold any code

Where does it exactly happen?
Re: problems with Persistent data when upgrading to 2.2.0
Posted: Wednesday 02 August 2017 10:15
by gus
Sorry, removed some uncomment code....
Code: Select all
-- ------------------------------------
-- Hantering av display --
-- ------------------------------------
return {
active = true,
on = {
timer = {
'every minute'
}
},
data = {
barometer_old = {initial=0},
balja_old = {initial=0},
utetemp_old = {initial=0},
vindgust_old = {initial=0},
regn_old = {initial=0},
dorrar_old = {initial=0},
hour_old = {initial=0}
},
execute = function(domoticz)
local function roundToNthDecimal(num, n)
local mult = 10^(n or 0)
return math.floor(num * mult + 0.5) / mult
end
local barometer = (domoticz.devices('Barometer').barometer)
local balja = (domoticz.devices('Temp to Pool').temperature)
local utetemp = (domoticz.devices('Temp Veranda Ute').temperature)
local vindgust = (domoticz.devices('Wind').windgust)
local regn = (domoticz.devices('Rain').rain)
local barometer_old = domoticz.data.barometer_old
local balja_old = domoticz.data.balja_old
local utetemp_old = domoticz.data.utetemp_old
local vindgust_old = domoticz.data.vindgust_old
local regn_old = domoticz.data.regn_old
local dorrar_old = domoticz.data.dorrar_old
local hour_old = domoticz.data.hour_old
--local barometer = roundToNthDecimal((domoticz.devices('Barometer').barometer), 0)
--local balja = roundToNthDecimal((domoticz.devices('Temp to Pool').temperature), 1)
--local utetemp = roundToNthDecimal((domoticz.devices('Temp Veranda Ute').temperature), 1)
--local vindgust = roundToNthDecimal((domoticz.devices('Wind').windgust), 1)
--local regn = roundToNthDecimal((domoticz.devices('Rain').rain), 1)
--local barometer_old = domoticz.data.barometer_old
--local balja_old = domoticz.data.balja_old
--local utetemp_old = domoticz.data.utetemp_old
--local vindgust_old = domoticz.data.vindgust_old
--local regn_old = domoticz.data.regn_old
--local dorrar_old = domoticz.data.dorrar_old
--local hour_old = domoticz.data.hour_old
domoticz.devices('Text 1').updateText('Klockan ar ' .. os.date("%R"))
domoticz.devices('Trigger request Text 1').switchOn()
--os.execute('curl http://192.168.17.82:5005/Matrum/say/Hej maten är klar/sv-se/20')
if ((barometer) ~= (barometer_old)) then
domoticz.devices('Text 2').updateText('Lufttrycket ar ' .. (barometer) .. ' hPa')
domoticz.devices('Trigger request Text 2').switchOn()
domoticz.data.barometer_old = (barometer)
end
if ((balja) ~= (balja_old)) then
domoticz.devices('Text 3').updateText('Temp Balja ' .. (balja) .. ' Grader')
domoticz.devices('Trigger request Text 3').switchOn()
domoticz.data.balja_old = (balja)
end
if ((utetemp) ~= (utetemp_old)) then
domoticz.devices('Text 4').updateText('Utetemp ar ' .. (utetemp) .. ' Grader')
domoticz.devices('Trigger request Text 4').switchOn()
domoticz.data.utetemp_old = (utetemp)
end
if ((domoticz.devices('Lockstatus').state) ~= (dorrar_old)) then
if domoticz.devices('Lockstatus').state == 'Closed' then
domoticz.devices('Text 5').updateText('Alla dorrar ar lasta')
domoticz.devices('Trigger request Text 5').switchOn()
else domoticz.devices('Text 5').updateText('Nagot ar oppet!')
domoticz.devices('Trigger request Text 5').switchOn()
end
domoticz.data.dorrar_old = (domoticz.devices('Lockstatus').state)
end
if ((vindgust) ~= (vindgust_old)) then
if (vindgust) <= 2 then
domoticz.devices('Text 6').updateText('Det ar vindstilla')
domoticz.devices('Trigger request Text 6').switchOn()
elseif (vindgust) >= 3 then
domoticz.devices('Text 6').updateText('Det blaser nu ' .. (vindgust) .. ' m/s')
domoticz.devices('Trigger request Text 6').switchOn()
end
domoticz.data.vindgust_old = (vindgust)
end
if ((regn) ~= (regn_old)) then
if (regn) == 0 then
domoticz.devices('Text 7').updateText('Inget regn idag!')
domoticz.devices('Trigger request Text 7').switchOn()
elseif (regn) > 0 then
domoticz.devices('Text 7').updateText('Det har regnat ' .. (regn) .. ' mm!')
domoticz.devices('Trigger request Text 7').switchOn()
end
domoticz.data.regn_old = (regn)
end
if ((domoticz.time.hour) ~= (hour_old)) then
if (domoticz.time.hour) >= 0 and (domoticz.time.hour) <= 4 then
domoticz.devices('Text 8').updateText('Natti Natti!')
domoticz.devices('Trigger request Text 8').switchOn()
elseif (domoticz.time.hour) >= 5 and (domoticz.time.hour) <= 9 then
domoticz.devices('Text 8').updateText('God Morgon!')
domoticz.devices('Trigger request Text 8').switchOn()
elseif (domoticz.time.hour) >= 10 and (domoticz.time.hour) <= 16 then
domoticz.devices('Text 8').updateText('God Dag!')
domoticz.devices('Trigger request Text 8').switchOn()
elseif (domoticz.time.hour) >= 17 and (domoticz.time.hour) <= 23 then
domoticz.devices('Text 8').updateText('God Afton!')
domoticz.devices('Trigger request Text 8').switchOn()
end
domoticz.data.hour_old = (domoticz.time.hour)
end
end
}
Re: problems with Persistent data when upgrading to 2.2.0
Posted: Wednesday 02 August 2017 10:21
by dannybloe
But I need to know the line at which the error occurs. You error in your first post says 107 but that doesn't have any code (end-statement).
Re: problems with Persistent data when upgrading to 2.2.0 [SOLVED]
Posted: Wednesday 02 August 2017 10:57
by gus
I found the problem!
It turned out to be a change of the API how to get windgust!
Old:
Code: Select all
local vindgust = (domoticz.devices('Wind').windgust)
New:
Code: Select all
local vindgust = (domoticz.devices('Wind').gust)
When the script has run without any fault, then the _xxx.lua is created in data folder!
Thanks for your support!
Re: problems with Persistent data when upgrading to 2.2.0
Posted: Wednesday 02 August 2017 11:15
by dannybloe
Ah, cool, yeah.. Sorry about that. Forgot to mark that as a breaking change I guess. I found that gust is better than windgust as it is already a wind device. Good that it works now. Good luck with it.