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

Moderator: leecollings

Post Reply
BarryT
Posts: 371
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

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

Post 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
Last edited by BarryT on Monday 25 October 2021 15:29, edited 5 times in total.
User avatar
erem
Posts: 230
Joined: Tuesday 27 March 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Amsterdam/netherlands
Contact:

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

Post 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
Regards,

Rob
BarryT
Posts: 371
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

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

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

Who is online

Users browsing this forum: No registered users and 1 guest