Problem with script not working with some of the triggers

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
wayfinder
Posts: 4
Joined: Friday 06 September 2019 1:40
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11005
Contact:

Problem with script not working with some of the triggers

Post by wayfinder »

This script triggers but the light will only switch with the 'at 9:08' trigger.
I can tell its triggering at sunset and sunrise buy the dz.log('V mode OFF ' ) output in the log.

Any clues appreciated. Thanks in advance.

Code: Select all

return {
	
	on = {
		['timer'] = {
			'at sunset',
			'at sunrise',
			'at 9:08'
			
		}
	},
	logging = {
            level = domoticz.INFO,
            marker = "FFL Random"
       },
	execute = function(dz, trigger)

			local FFL = dz.devices(67)
			local RANDOM = 20
            local ON_MIN = 70
		    FFL.cancelQueuedCommands()

		if (dz.devices(34).state == 'Off') then  
		    dz.log('V mode OFF ' )
				FFL.switchOn().withinMin(RANDOM).forMin(ON_MIN)
		
			end

		
	end
}
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Problem with script not working with some of the triggers

Post by waaren »

wayfinder wrote: Saturday 21 September 2019 18:29 This script triggers but the light will only switch with the 'at 9:08' trigger.
I can tell its triggering at sunset and sunrise buy the dz.log('V mode OFF ' ) output in the log.
Any clues appreciated. Thanks in advance.
Don't see any reason in this script why it should not do the random switchOn at sunset and at sunrise. Could be that the cancelQueuedCommands() at 9:08 or from another script kiks in before the withinMin() timer ends but hard to tell without analyzing the complete log and other scripts.
You can test that the switchOn() is activated at sunset / sunrise by removing the withinMin() part. If really important you can also switch on Debug mode in dzVents and domoticz.

BTW domoticz.INFO should domoticz.LOG_INFO
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
wayfinder
Posts: 4
Joined: Friday 06 September 2019 1:40
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11005
Contact:

Re: Problem with script not working with some of the triggers

Post by wayfinder »

I think you are correct on the cancelQueuedCommands(). I'll see tonight. I had it in another script I started by copying this one and never removed it.

Thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest