Page 1 of 1
Question about multiple persistant variables
Posted: Wednesday 25 April 2018 15:59
by schulpr
Hi,
I want to use multiple persistent variables with a default value but I can't find the right syntax.
This works: data = { v_regen = { initial = 0 } },
But when I add an extra variable I get an error: data = { v_regen = { initial = 0 }, v_alarm = { initial = 0 } },
Also adding quotes, as mentioned in the DZvents manual, doesn't help.
Does anyone know the right syntax? (And want to share it

)
Kind regards, Rob
Re: Question about multiple persistant variables
Posted: Wednesday 25 April 2018 16:26
by dannybloe
It helps if tell what the error is

Re: Question about multiple persistant variables
Posted: Wednesday 25 April 2018 18:02
by schulpr
Hi Dannybloe
I'm building this script that notifies me when rain is expected. (It's not finished yet)
-- Test1
return {
active = true,
on = {
devices = { 'Regenalarm', 'Regenhoeveelheid 1u' }
},
data = { v_regen = { initial = 0, v_alarm = { initial = 0 }
},
execute = function(domoticz, device)
local buienkans = tonumber(domoticz.devices('Regenhoeveelheid 1u').state)
local alarmkleur = domoticz.devices('Regenalarm').color
print('<font color="red">Buienkans: '..buienkans..'</font>')
print('<font color="red">Alarmkleur: '..alarmkleur..'</font>')
if buienkans > 0 and buienkans ~= domoticz.data.v_regen then
domoticz.notify('Regen verwacht binnen 1 uur.', 'Het gaat binnen een uur regenen. De verwachte regenintensiteit is '..buienkans..' mm/h','0','magic','iPhoneRob',domoticz.NSS_PUSHOVER)
domoticz.data.v_regen = buienkans
print('<font color="red">Alarmkleur: '..domoticz.data.v_regen..'</font>')
elseif alarmkleur > 1 then
domoticz.notify('Regen verwacht binnen 15 min.!', 'Het gaat regenen. De verwachte regenintensiteit is code '..alarmkleur..' !','0','magic','iPhoneRob',domoticz.NSS_PUSHOVER)
end
end
}
This is the error:
Error (2.4.5): error loading module 'Test1' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/Test1.lua':<br> .../pi/domoticz/scripts/dzVents/generated_scripts/Test1.lua:29: '}' expected (to close '{' at line 3) near <eof>
I was just wandering if I use the correct syntax.
Thanks for your help!
PS: it works now. Just forgot an '}'
Kind regards, Rob