Timed device trigger not working...  [Solved]

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

Moderator: leecollings

Post Reply
User avatar
FearNaBoinne
Posts: 144
Joined: Tuesday 30 April 2019 10:08
Target OS: Linux
Domoticz version: 2021.1
Location: Sector 0
Contact:

Timed device trigger not working...

Post by FearNaBoinne »

I am trying to use a timed device trigger, but it's not working...

Can anyone tell me what I am doing wrong?

Code: Select all

return {
	on = {
	    devices = { ['Voordeur Entry Sensor'] = { 'at nighttime' } } 
	},
	execute = function(domoticz, device)
		domoticz.log('Hal licht aan/uit.', domoticz.LOG_INFO)
		if ( device.status == "open" ) then
		    -- turn light on
		    domoticz.devices('Ganglicht BG').setState("On")
	    	elseif ( device.status == 'closed' ) then
	       	    -- turn light off after one minute
		    domoticz.devices('Ganglicht BG').setState("Off").afterMin(1)
	    end
	end
}
It is not triggering at all, even though the device name is correct and the time is between sunset and sunrise...
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Timed device trigger not working...

Post by waaren »

FearNaBoinne wrote: Friday 04 October 2019 22:36 I am trying to use a timed device trigger, but it's not working...
It is not triggering at all, even though the device name is correct and the time is between sunset and sunrise...
I can't see anything wrong with your script. Just tested below (domoticz V4.11350 / dzVents 2.4.29

Code: Select all

return {
    on = {
        devices = { ['my Trigger'] = { 'at nighttime' } }
    },
    execute = function(dz, item)
        dz.log(item.name .. ' triggered this script.', dz.LOG_FORCE)
    end
}
Log
Spoiler: show

Code: Select all

]2019-10-04 23:18:41.149  Status: dzVents: Info: Handling events for: "my Trigger", value: "On"
2019-10-04 23:18:41.150  Status: dzVents: Info: ------ Start external script: dumper499 (combined trigger).lua: Device: "my Trigger (Virtual)", Index: 2355
2019-10-04 23:18:41.152  Status: dzVents: !Info: my Trigger triggered this script.
2019-10-04 23:18:41.156  Status: dzVents: Info: ------ Finished dumper499 (combined trigger).lua
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
BOverdevest
Posts: 23
Joined: Wednesday 28 March 2018 20:56
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11307
Location: Nederland
Contact:

Re: Timed device trigger not working...  [Solved]

Post by BOverdevest »

Hi

Is the use of "status" correct? I think it should be ".state"

Below my script for a similar situation. The OD's are the Open/Close devices.

Code: Select all

--Voordeur of zijdeur open

return {
	on = { devices = {['OD Voordeur'] = {'at nighttime'},['OD Zijdeur'] = {'at nighttime'}}},
	 
	    execute = function(domoticz, device)
        domoticz.devices('Voordeur Lamp').switchOn().checkFirst().forMin(10)
    
    end
}
HUE, Tradfri, Zwave, RFXCOM, rooted TOON, PS4
User avatar
FearNaBoinne
Posts: 144
Joined: Tuesday 30 April 2019 10:08
Target OS: Linux
Domoticz version: 2021.1
Location: Sector 0
Contact:

Re: Timed device trigger not working...

Post by FearNaBoinne »

BOverdevest wrote: Friday 04 October 2019 23:28 Is the use of "status" correct? I think it should be ".state"
Weird, I missed that, and as soon as I changed it, the script started triggering... Very strange that it didn't even trigger when it said .status instead of .state, but did not show any errors in the editor NOR in the logs!...
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Timed device trigger not working...

Post by waaren »

FearNaBoinne wrote: Friday 04 October 2019 23:48 Weird, I missed that, and as soon as I changed it, the script started triggering... Very strange that it didn't even trigger when it said .status instead of .state, but did not show any errors in the editor NOR in the logs!...
The triggering of the script should not be influenced by this. And

Code: Select all

 if ( device.status == "open" ) then
is formally not an error. It will just always evaluates to false because device.status is not equal to "open" (it is nil)
Can you check your dzVents loglevel ? Do you see other scripts being triggered if they do not have an explicit logging = section ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
FearNaBoinne
Posts: 144
Joined: Tuesday 30 April 2019 10:08
Target OS: Linux
Domoticz version: 2021.1
Location: Sector 0
Contact:

Re: Timed device trigger not working...

Post by FearNaBoinne »

waaren wrote: Friday 04 October 2019 23:58 The triggering of the script should not be influenced by this.
I know, and I was about to respond with that, but then I thought I'd try fixing that error anyway, and after that it worked... And the *only* thing I did was replace 'us' with 'e' (twice)...
waaren wrote: Friday 04 October 2019 23:58 Can you check your dzVents loglevel ? Do you see other scripts being triggered if they do not have an explicit logging = section ?
Yup, and once I changed the .status-es for .state-s, so did this one (even without the domoticz.log line), but not before that! I don't understand either...
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest