beginner question

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

Moderator: leecollings

Post Reply
adval40
Posts: 14
Joined: Sunday 28 May 2017 18:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11528
Location: Eindhoven (The netherlands)
Contact:

beginner question

Post by adval40 »

I started with dzvents since 2 days.
I want to switch a device with 'between 00:47 and 00:48',
this is of course an example

Code: Select all


return {
	on = {
		timer = {

		    'between 00:47 and 00:48' ,                                                          
	            },
         },
	execute = function(domoticz, timer)
	    domoticz.devices('Printer voorkamer')   .switchOn()
	end
       }

the .switchOn () command is wrong I don't know what the correct command is
thank you in advance
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: beginner question

Post by besix »

Hello
switchOn command is Ok
only in execute you have to say when it should be On

Code: Select all

return {
	on = {
		timer = {

		    'between 00:47 and 00:48'                                                           
	            },
         },
	execute = function(domoticz, timer)
	    if domoticz.time.matchesRule('between 00:47 and 00:48') then
	    domoticz.devices( ' Printer voorkamer ' ).switchOn()
    end
end
} 
salvacalatayud
Posts: 112
Joined: Monday 26 June 2017 21:16
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Spain
Contact:

Re: beginner question

Post by salvacalatayud »

Why don't just put a timer to the switch instead? It is easy and you don't need any coding

Enviado desde mi Mi A2 mediante Tapatalk

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

Re: beginner question

Post by waaren »

adval40 wrote: Wednesday 29 January 2020 1:23 I want to switch a device with 'between 00:47 and 00:48',
the .switchOn () command is wrong I don't know what the correct command is
The switchOn() method is ok but you have spaces before .switchOn() that should not be there. Try this one.

Code: Select all

return 
{
    on = 
    {
        timer = 
        {
            'at 08:31-08:33',
        },
    },

    execute = function(dz)
        dz.devices('Printer voorkamer').switchOn()
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: beginner question

Post by waaren »

besix wrote: Wednesday 29 January 2020 6:48 switchOn command is Ok
only in execute you have to say when it should be On
I am sorry but no. In this script the matchesRule does not add any value. The script will only be executed 'at 00:47-00:48' so the matchesRule will always evaluate to true.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest