Page 1 of 1

Trigger 10 minutes, execution every 45 seconds

Posted: Tuesday 14 May 2019 1:40
by HvdW
Hi,
In my script timer is set to 'every 10 minutes'
The log tells me that that is understood.
How come the script is executed every 45 seconds?

Code: Select all

 2019-05-14 01:30:00.425 Status: dzVents: Info: ------ Start internal script: Verwarming:, trigger: every 10 minutes
2019-05-14 01:30:00.444 Status: dzVents: Info: Average: 20.60000038147
2019-05-14 01:30:00.444 Status: dzVents: Info: Setpoint: 14.2
2019-05-14 01:30:00.445 Status: dzVents: Info: Current boiler state: Off
2019-05-14 01:30:00.445 Status: dzVents: Info: Switch-on temperature: 13.7
2019-05-14 01:30:00.445 Status: dzVents: Info: ------ Finished Verwarming
2019-05-14 01:30:09.327 Status: Incoming connection from: 192.168.2.7
2019-05-14 01:30:34.749 Status: dzVents: Info: Handling events for: "Kamer-temp", value: "20.6;48;1"
2019-05-14 01:30:34.749 Status: dzVents: Info: ------ Start internal script: Verwarming: Device: "Kamer-temp (RFXtfx)", Index: 3
2019-05-14 01:30:34.752 Status: dzVents: Info: Average: 20.60000038147
2019-05-14 01:30:34.752 Status: dzVents: Info: Setpoint: 14.2
2019-05-14 01:30:34.752 Status: dzVents: Info: Current boiler state: Off
2019-05-14 01:30:34.752 Status: dzVents: Info: Switch-on temperature: 13.7
2019-05-14 01:30:34.753 Status: dzVents: Info: ------ Finished Verwarming
2019-05-14 01:31:19.858 Status: dzVents: Info: Handling events for: "Kamer-temp", value: "20.6;48;1"
2019-05-14 01:31:19.858 Status: dzVents: Info: ------ Start internal script: Verwarming: Device: "Kamer-temp (RFXtfx)", Index: 3
2019-05-14 01:31:19.861 Status: dzVents: Info: Average: 20.60000038147
2019-05-14 01:31:19.861 Status: dzVents: Info: Setpoint: 14.2
2019-05-14 01:31:19.861 Status: dzVents: Info: Current boiler state: Off
2019-05-14 01:31:19.861 Status: dzVents: Info: Switch-on temperature: 13.7
2019-05-14 01:31:19.861 Status: dzVents: Info: ------ Finished Verwarming
2019-05-14 01:32:04.754 Status: dzVents: Info: Handling events for: "Kamer-temp", value: "20.6;48;1"
2019-05-14 01:32:04.754 Status: dzVents: Info: ------ Start internal script: Verwarming: Device: "Kamer-temp (RFXtfx)", Index: 3
2019-05-14 01:32:04.757 Status: dzVents: Info: Average: 20.60000038147
2019-05-14 01:32:04.757 Status: dzVents: Info: Setpoint: 14.2
2019-05-14 01:32:04.757 Status: dzVents: Info: Current boiler state: Off
2019-05-14 01:32:04.757 Status: dzVents: Info: Switch-on temperature: 13.7
2019-05-14 01:32:04.758 Status: dzVents: Info: ------ Finished Verwarming
2019-05-14 01:32:49.707 Status: dzVents: Info: Handling events for: "Kamer-temp", value: "20.6;48;1"
2019-05-14 01:32:49.707 Status: dzVents: Info: ------ Start internal script: Verwarming: Device: "Kamer-temp (RFXtfx)", Index: 3
2019-05-14 01:32:49.709 Status: dzVents: Info: Average: 20.60000038147
2019-05-14 01:32:49.709 Status: dzVents: Info: Setpoint: 14.2
2019-05-14 01:32:49.710 Status: dzVents: Info: Current boiler state: Off
2019-05-14 01:32:49.710 Status: dzVents: Info: Switch-on temperature: 13.7
2019-05-14 01:32:49.710 Status: dzVents: Info: ------ Finished Verwarming 
It is the script from this thread.

Re: Trigger 10 minutes, execution every 45 seconds

Posted: Tuesday 14 May 2019 7:19
by waaren
HvdW wrote: Tuesday 14 May 2019 1:40 In my script timer is set to 'every 10 minutes'
How come the script is executed every 45 seconds?

Code: Select all

01:30:00 trigger: every 10 minutes
01:30:34 Device: "Kamer-temp (RFXtfx)"
14 01:31 Device: "Kamer-temp (RFXtfx)"
14 01:32 Device: "Kamer-temp (RFXtfx)"
01:32:49 Device: "Kamer-temp (RFXtfx)"
If you look at these lines, you see that the script starts at 01:30:00, triggered by the set timer of 'every 10 minutes'
The other starts are triggered by the device 'KLamer-temp (RFXtfx)' as requested in the 'device =' section.

Code: Select all

local TEMPERATURE_SENSOR = 'Kamer-temp (RFXtfx)' -- or (3)

		devices = { TEMPERATURE_SENSOR,}

Re: Trigger 10 minutes, execution every 45 seconds

Posted: Wednesday 15 May 2019 10:39
by HvdW
Hi,
There was an answer here that the author deleted.
Anyway, he was right.
The script is activated by the incoming connection from the thermometer that is plotting every 45 seconds.

Two ways to resolve this:
- Include a wait/sleep/pause into the script
- Change the plotting time from the sensor either in Domoticz or in RFXtfx

Both options are something that I don't know how to achieve.
I would be gratefull for solutions.

Re: Trigger 10 minutes, execution every 45 seconds

Posted: Wednesday 15 May 2019 12:19
by waaren
HvdW wrote: Wednesday 15 May 2019 10:39 I would be gratefull for solutions.
The way the script works depends on the value from the thermometer coming in and there is no harm that it executes every couple of seconds. That's just how the event system in domoticz works.
Anyway introducing a sleep in an event script is in general a bad idea because it will block the complete event system for the duration of that sleep. (event system is single threaded)

Re: Trigger 10 minutes, execution every 45 seconds

Posted: Wednesday 15 May 2019 15:33
by gajotnt
Dzvents code to turn on every hour

Code: Select all

 return {
        
    on = { timer = {"every hour"} },
    
	execute = function(domoticz, _)
		local myDevice = domoticz.devices("Fonte")
			myDevice.switchOn()
	end		
}
Lua code (Trigger Device) to turn off after 120seconds

Code: Select all

 commandArray = {}
 if (devicechanged['Fonte'] == 'On') then
     commandArray['Fonte']='Off AFTER 120'
 end
 return commandArray
FONTE is the name of the device i want to turn on every hour and just run for 2 minutes.
Hope this helps