Page 1 of 1

As long motion detected, only write once a minute to log

Posted: Monday 25 October 2021 15:02
by BarryT
Hi, sorry for asking this but i couldnt find an answer for this on the forum.
i'm using a lot of motion script (if motion == on, turn lamp == on) and with a print to the log (motion detected in room x).
now, what i want is:
if motion detected it has to turn on the light and do a print only once a 60 or 120 seconds to the log.
what is does now is it writes to the log every couple seconds as long as we are in the room and there is motion.
i need this for the print output only.
is this possible?
thanks!

example:

Code: Select all

2021-10-25 14:59:12.048 Status: LUA: Verlichting badkamer AAN
2021-10-25 14:59:16.794 Status: LUA: Verlichting badkamer AAN
2021-10-25 15:00:14.529 Status: LUA: Verlichting badkamer AAN
2021-10-25 15:00:22.282 Status: LUA: Verlichting badkamer AAN
2021-10-25 15:01:21.425 Status: LUA: Verlichting badkamer AAN
this is my script to turn on @motion:

Code: Select all

commandArray = {}

if 
        devicechanged['BewegingBadkamer'] == 'On' -- and otherdevices['Het is Donker'] == 'On' 
then
        commandArray[#commandArray+1] = {['LampBadkamer-RFX'] ='Set Level 83' }
        print('Verlichting badkamer AAN')
end
return commandArray

Re: As long motion detected, only write once a minute to log

Posted: Monday 25 October 2021 15:28
by erem
if you port this to dzVents you can use the data section to store the last time you printed the message,
and if too long ago reprint

Code: Select all

return
{
	on =
	{
		timer = {'every 5 minutes'}
	},
	data =
	{
		previousHumidity = { initial = 100 }
	},
	execute = function(domoticz)
		local bathroomSensor = domoticz.devices('BathroomSensor')
		if (bathroomSensor.humidity - domoticz.data.previousHumidity) >= 5 then
			-- there was a significant rise
			domoticz.devices('Ventilator').switchOn()
		end
		-- store current value for next cycle
		domoticz.data.previousHumidity = bathroomSensor.humidity
	end
}
from here: https://github.com/domoticz/domoticz/bl ... /README.md

Re: As long motion detected, only write once a minute to log

Posted: Monday 25 October 2021 15:29
by BarryT
erem wrote: Monday 25 October 2021 15:28 if you port this to dzVents you can use the data section to store the last time you printed the message,
and if too long ago reprint

Code: Select all

return
{
	on =
	{
		timer = {'every 5 minutes'}
	},
	data =
	{
		previousHumidity = { initial = 100 }
	},
	execute = function(domoticz)
		local bathroomSensor = domoticz.devices('BathroomSensor')
		if (bathroomSensor.humidity - domoticz.data.previousHumidity) >= 5 then
			-- there was a significant rise
			domoticz.devices('Ventilator').switchOn()
		end
		-- store current value for next cycle
		domoticz.data.previousHumidity = bathroomSensor.humidity
	end
}
from here: https://github.com/domoticz/domoticz/bl ... /README.md
Really thanks for answering, but i need this for lua.. i disabled dventz for now.