Question about multiple persistant variables

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
schulpr
Posts: 137
Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Question about multiple persistant variables

Post 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
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Question about multiple persistant variables

Post by dannybloe »

It helps if tell what the error is :)
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
schulpr
Posts: 137
Joined: Thursday 01 January 2015 9:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Question about multiple persistant variables

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest