Page 1 of 1
Print counter to log
Posted: Thursday 12 September 2019 14:18
by zavjah
Hi,
I am trying to do something like this
loop something
If applicable then
x=x+1
end
end
log(i)
What seems to be an easy and straight forward task is making me nuts. Can someone please give me a hint? Thx
Cheers,
zavjah
Re: Print counter to log
Posted: Thursday 12 September 2019 21:22
by waaren
zavjah wrote: Thursday 12 September 2019 14:18
I am trying to do something like this
Code: Select all
loop something
If applicable then
x=x+1
end
end
log(i)
What seems to be an easy and straight forward task is making me nuts. Can someone please give me a hint? Thx
Don't know what you tried already and with what the specific part you are having difficulties. But this dzVents example uses a loop, counters and log statements .
Code: Select all
return
{
on =
{
timer =
{
'every minute', -- causes the script to be called every minute
},
},
execute = function(dz)
local otherCounter = 0
local onCounter = 0
dz.devices().forEach(function(dv)
if dv.state =='On' then
onCounter = onCounter + 1
else
otherCounter = otherCounter + 1
end
end)
dz.log('Number of active devices in domoticz : ' .. onCounter + otherCounter,dz.LOG_FORCE)
dz.log('Number of active devices in domoticz with state = "On" : ' .. onCounter,dz.LOG_FORCE)
dz.log('Number of active devices in domoticz with other state : ' .. otherCounter,dz.LOG_FORCE)
end
}
Re: Print counter to log [Solved]
Posted: Friday 13 September 2019 10:00
by zavjah
Hi waaren,
Thank you very much, it work's like a charm
Cheers,
zavjah