I need some help on this, I guess my LUA knowledge runs short here.
I try to do this:
Code: Select all
return {
active = true,
on = {
timer = {
'every 1 minutes'
}
},
data = {
prevPresenceRalph = {initial='Off'},
prevPresenceAnneke = {initial='Off'},
prevPresenceKim = {initial='Off'}
},
logging = {
level= domoticz.LOG_DEBUG,
marker = 'Wifi presence check'
},
execute = function(domoticz)
local assetName
local gVirtHome = domoticz.devices('VirtualPresence') -- variable for Virtual presence switch
local presence = 'VirtualAtHome'
local oldPresence = 'prevPresence'
local wifiPresence = 'VirtualArping'
local presenceSwitch
local _members = domoticz.devices().filter(function(device)
return (device.name:sub(1,13) == wifiPresence)
end).forEach(function(_members)
domoticz.log (_members.name)
assetName = _members.name:sub(14)
presenceSwitch = domoticz.devices(presence..assetName)
prevWifiSwitch = (oldPresence..assetName)
domoticz.log (domoticz.data.prevWifiSwitch)
domoticz.data.prevWifiSwitch = _members.state
end)
end
}
Code: Select all
domoticz.log (domoticz.data.prevWifiSwitch)
I believe this has to do with the fact that I tried to concat two variables and us that as part of the domoticz.data.prevWifiSwitch. If I replace it with a hard pesistent variable it works, but obviously I want it to run with all variables in the loop.
How do I solve this is correct LUA.
I'm using V2.2.0.
The total code might not be working as I stripped out a large part of the code for readability.
Thx for your suggestions,
Ralph