Page 1 of 1

timer does not work

Posted: Sunday 17 February 2019 17:35
by pvklink
Hi i made a selector switch with 10 options. When i select 10Second the device is turned on and off after 10 seconds again and again.
What am i doing wrong? i used the checkFirst?
Also the logging gives multiple ON commands

0 Uit
10 10seconds
20 20seconds
30 30seconds
etc.

Code: Select all

return {
	on = {devices = {'Tuinirrigatie_borders'}},

    logging = { level   = domoticz.LOG_DEBUG ,marker  = actOnIdleDevices },

    execute = function(dz, device, info)
    local waarde = tonumber(device.state)

    if device.state == '0' then
        device.switchOff()
        dz.log("Script: " .. info.scriptName .. " Device uitgezet....", dz.LOG_INFO)    
    else 
        device.switchOn().checkFirst().forSec(waarde)
        dz.log("Script: " .. info.scriptName .. " Device voor " .. tostring(waarde) .. "secondes aangezet....", dz.LOG_INFO)    
    end

end
}
logging

Code: Select all

2019-02-17 17:32:41.091 Status: dzVents: Info: ------ Start internal script: DZ_Irrigatie: Device: "Tuinirrigatie_borders (dummydevices)", Index: 1188
2019-02-17 17:32:41.091 Status: dzVents: Debug: Constructed timed-command: On
2019-02-17 17:32:41.091 Status: dzVents: Debug: Constructed timed-command: On FOR 10 SECONDS
2019-02-17 17:32:41.091 Status: dzVents: Info: Script: DZ_Irrigatie Device voor 10secondes aangezet....
2019-02-17 17:32:41.092 Status: dzVents: Info: ------ Finished DZ_Irrigatie
2019-02-17 17:32:41.093 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2019-02-17 17:32:41.217 Status: dzVents: Info: ------ Start internal script: DZ_Irrigatie: Device: "Tuinirrigatie_borders (dummydevices)", Index: 1188
2019-02-17 17:32:41.217 Status: dzVents: Debug: Constructed timed-command: On
2019-02-17 17:32:41.218 Status: dzVents: Debug: Constructed timed-command: On FOR 10 SECONDS
2019-02-17 17:32:41.218 Status: dzVents: Info: Script: DZ_Irrigatie Device voor 10secondes aangezet....
2019-02-17 17:32:41.218 Status: dzVents: Info: ------ Finished DZ_Irrigatie
2019-02-17 17:32:41.220 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2019-02-17 17:32:41.428 Status: dzVents: Info: ------ Start internal script: DZ_Irrigatie: Device: "Tuinirrigatie_borders (dummydevices)", Index: 1188
2019-02-17 17:32:41.429 Status: dzVents: Debug: Constructed timed-command: On
2019-02-17 17:32:41.429 Status: dzVents: Debug: Constructed timed-command: On FOR 10 SECONDS
2019-02-17 17:32:41.429 Status: dzVents: Info: Script: DZ_Irrigatie Device voor 10secondes aangezet....
2019-02-17 17:32:41.429 Status: dzVents: Info: ------ Finished DZ_Irrigatie
2019-02-17 17:32:41.430 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2019-02-17 17:32:41.541 Status: dzVents: Info: ------ Start internal script: DZ_Irrigatie: Device: "Tuinirrigatie_borders (dummydevices)", Index: 1188
2019-02-17 17:32:41.541 Status: dzVents: Debug: Constructed timed-command: On
2019-02-17 17:32:41.541 Status: dzVents: Debug: Constructed timed-command: On FOR 10 SECONDS
2019-02-17 17:32:41.541 Status: dzVents: Info: Script: DZ_Irrigatie Device voor 10secondes aangezet....
2019-02-17 17:32:41.541 Status: dzVents: Info: ------ Finished DZ_Irrigatie
2019-02-17 17:32:41.543 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2019-02-17 17:32:41.667 Status: dzVents: Info: ------ Start internal script: DZ_Irrigatie: Device: "Tuinirrigatie_borders (dummydevices)", Index: 1188
2019-02-17 17:32:41.667 Status: dzVents: Debug: Constructed timed-command: On
2019-02-17 17:32:41.667 Status: dzVents: Debug: Constructed timed-command: On FOR 10 SECONDS
2019-02-17 17:32:41.667 Status: dzVents: Info: Script: DZ_Irrigatie Device voor 10secondes aangezet....
2019-02-17 17:32:41.667 Status: dzVents: Info: ------ Finished DZ_Irrigatie
2019-02-17 17:32:41.669 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2019-02-17 17:32:41.793 Status: dzVents: Info: ------ Start internal script: DZ_Irrigatie: Device: "Tuinirrigatie_borders (dummydevices)", Index: 1188
2019-02-17 17:32:41.793 Status: dzVents: Debug: Constructed timed-command: On
2019-02-17 17:32:41.794 Status: dzVents: Debug: Constructed timed-command: On FOR 10 SECONDS
2019-02-17 17:32:41.794 Status: dzVents: Info: Script: DZ_Irrigatie Device voor 10secondes aangezet....
2019-02-17 17:32:41.794 Status: dzVents: Info: ------ Finished DZ_Irrigatie
2019-02-17 17:32:41.795 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2019-02-17 17:32:41.917 Status: dzVents: Info: ------ Start internal script: DZ_Irrigatie: Device: "Tuinirrigatie_borders (dummydevices)", Index: 1188
2019-02-17 17:32:41.917 Status: dzVents: Debug: Constructed timed-command: On
2019-02-17 17:32:41.917 Status: dzVents: Debug: Constructed timed-command: On FOR 10 SECONDS
2019-02-17 17:32:41.917 Status: dzVents: Info: Script: DZ_Irrigatie Device voor 10secondes aangezet....
2019-02-17 17:32:41.917 Status: dzVents: Info: ------ Finished DZ_Irrigatie
2019-02-17 17:32:41.919 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2019-02-17 17:32:42.070 (dummydevices) Light/Switch (Tuinirrigatie_borders)
2019-02-17 17:32:42.044 Status: dzVents: Info: ------ Start internal script: DZ_Irrigatie: Device: "Tuinirrigatie_borders (dummydevices)", Index: 1188
2019-02-17 17:32:42.044 Status: dzVents: Debug: Constructed timed-command: On
2019-02-17 17:32:42.044 Status: dzVents: Debug: Constructed timed-command: On FOR 10 SECONDS

Re: timer does not work

Posted: Sunday 17 February 2019 18:10
by waaren
pvklink wrote: Sunday 17 February 2019 17:35 Hi i made a selector switch with 10 options. When i select 10Second the device is turned on and off after 10 seconds again and again.
What am i doing wrong? i used the checkFirst?
Also the logging gives multiple ON commands
checkFirst() is a short for: if (device.state == 'Off') then device.switchOn() end
Maybe you intend silent() ?: do not trigger follow up events

Code: Select all

return {
            on = {
                    devices = {
                                'Tuinirrigatie_borders'
                              },
                 },

    logging = { 
                    level   = domoticz.LOG_INFO,
                    marker  = "Tuinirrigatie_borders",
              },

    execute = function(dz, device, info)
    local waarde = device.level

    if waarde == 0 then
        device.switchOff().silent()
        dz.log("Script: " .. info.scriptName .. " Device uitgezet....", dz.LOG_INFO)    
    else 
        device.switchOn().silent()
        device.switchOff().afterSec(waarde).silent()
        
        dz.log("Script: " .. info.scriptName .. " Device " .. device.name .. " voor " .. waarde .. " seconden aangezet....", dz.LOG_INFO)    
    end

end
}

Re: timer does not work

Posted: Sunday 17 February 2019 18:16
by pvklink
thanksssssssssssssssssssssssssssssssssssssssssssssssssssssssss

Now i can manage my irrigation system by voice.... Water the garden for 10, 20, 30 etc. minutes
( i know i have to change the forSec in forMIn (this was for testing)

i was strugling for an hour to solve this myself....
i needed dr. Waaren, thanks again...

Re: timer does not work

Posted: Sunday 17 February 2019 19:02
by pvklink
Hi rens,

I made three selectors, ('Tuinirrigatie_borders','Tuinirrigatie_grasveld','Tuinirrigatie_plantenbakken) and they are all the same
0 = Uit, level id 10, description 10, 20,30 - 90 . I use the buttongroup and i dont hide the first level

I connected a 3-way kaku device (RF) with these three and they work perfect!
Only thing that worked before i made those three and connected them to RF kaku is that when:

i select by example 20, is isnt visible as selected in the user interfase of domoticz. When i click, the device goes on, i see a notice "Schakel 20" , it does turn on the device and after 20 seconds it goes off. But in the meantime i cant see that the button 20 is selected. So when i use minutes instead of seconds i cant see that 20 minutes is selected for 20 minutes...

Code: Select all

return {
    on = {devices = {'Tuinirrigatie_borders','Tuinirrigatie_grasveld','Tuinirrigatie_plantenbakken'},
        },

    logging = { 
                    level   = domoticz.LOG_INFO,
                    marker  = "Tuinirrigatie_borders",
              },

    execute = function(dz, device, info)
    local waarde = device.level

    if waarde == 0 then
        device.switchOff().silent()
        dz.log("Script: " .. info.scriptName .. " Device uitgezet....", dz.LOG_INFO)    
    else 
        device.switchOn().silent()
        device.switchOff().afterSec(waarde).silent()
        
        dz.log("Script: " .. info.scriptName .. " Device " .. device.name .. " voor " .. waarde .. " seconden aangezet....", dz.LOG_INFO)    
    end

end
}

Re: timer does not work

Posted: Sunday 17 February 2019 21:05
by waaren
pvklink wrote: Sunday 17 February 2019 19:02 I made three selectors, ('Tuinirrigatie_borders','Tuinirrigatie_grasveld','Tuinirrigatie_plantenbakken) and they are all the same
0 = Uit, level id 10, description 10, 20,30 - 90 . I use the buttongroup and i dont hide the first level
I connected a 3-way kaku device (RF) with these three and they work perfect!
Only thing that worked before i made those three and connected them to RF kaku is that when:
i select by example 20, is isnt visible as selected in the user interfase of domoticz. When i click, the device goes on, i see a notice "Schakel 20" , it does turn on the device and after 20 seconds it goes off. But in the meantime i cant see that the button 20 is selected. So when i use minutes instead of seconds i cant see that 20 minutes is selected for 20 minutes...
I don't think I understand. How did you connect the KlikAan KlikUit switched to the selector ?

Re: timer does not work

Posted: Sunday 17 February 2019 21:41
by pvklink
Learn mode, and then i changed the devices to selectors with buttons.
problem is that when i click the device, say 20, it does switch on for 20 seconds... but during those 20 seconds it does not lightup the 20 button with the color that usually is used when selecting a button...
Also ON/OFF is not the right value during those 20 seconds...
I think it is because off teh script with both an off and a on event
So its more an UX (i=usability thing)
see attachments

Re: timer does not work

Posted: Sunday 17 February 2019 23:41
by waaren
pvklink wrote: Sunday 17 February 2019 21:41 Learn mode, and then i changed the devices to selectors with buttons.
problem is that when i click the device, say 20, it does switch on for 20 seconds... but during those 20 seconds it does not lightup the 20 button with the color that usually is used when selecting a button...
Also ON/OFF is not the right value during those 20 seconds...
I think it is because off teh script with both an off and a on event
So its more an UX (i=usability thing)
see attachments
Still no clue how this could work but can you try this ?

Code: Select all

return {
    on = {devices = {'Tuinirrigatie_borders','Tuinirrigatie_grasveld','Tuinirrigatie_plantenbakken'},
        },

    logging = { 
                    level   = domoticz.LOG_INFO,
                    marker  = "Tuinirrigatie_borders",
              },

    execute = function(dz, device, info)
    local waarde = device.level

    if waarde == 0 then
        device.switchOff().silent()
        dz.log("Script: " .. info.scriptName .. " Device uitgezet....", dz.LOG_INFO)    
    else 
        device.switchOn().silent()
		device.dimTo(waarde).silent()
        device.switchOff().afterSec(waarde).silent()
        
        dz.log("Script: " .. info.scriptName .. " Device " .. device.name .. " voor " .. waarde .. " seconden aangezet....", dz.LOG_INFO)    
    end

end
}

Re: timer does not work

Posted: Monday 18 February 2019 7:27
by pvklink
i wiil try it this evening.i have another solution less beautiful by creating an on off switch and a sepatete selector switch for value 10-90
this works well.
i will post that too!

Re: timer does not work

Posted: Monday 18 February 2019 7:28
by pvklink
i wiil try it this evening.i have another solution less beautiful by creating an on off switch and a sepatete selector switch for value 10-90
this works well.
i will post that too!

Re: timer does not work

Posted: Monday 18 February 2019 19:04
by pvklink
Hi Waaren,

I solved the problem that the selected button (the seconds) is not selected by splitting the selector device in two parts: the on/off button and the different periods in a selectordevice... works ok now...

Code: Select all

return {
    on = {devices = {'Tuinirrigatie_grasveld','Tuinirrigatie_borders','Tuinirrigatie_plantenbakken'},
        },

    logging = { 
                    level   = domoticz.LOG_INFO,
                    marker  = "Tuinirrigatie_borders",
              },

    execute = function(dz, device, info)
    local waarde1 = dz.devices('Tuinirrigatie_grasveld_waarde').level
    local waarde2 = dz.devices('Tuinirrigatie_borders_waarde').level
    local waarde3 = dz.devices('Tuinirrigatie_plantenbakken_waarde').level

    if device.name == 'Tuinirrigatie_grasveld' then
        waarde = waarde1
    elseif device.name == 'Tuinirrigatie_borders' then
        waarde = waarde2
    elseif device.name == 'Tuinirrigatie_plantenbakken' then
        waarde = waarde3
    end
    
    if device.state == 'Off' then
        switch.switchOff()
        dz.log("Script: " .. info.scriptName .. " Device uitgezet....", dz.LOG_INFO)    
    else 
        device.switchOn().silent()
        device.switchOff().afterSec(waarde).silent()
        
        dz.log("Script: " .. info.scriptName .. " Device " .. device.name .. " voor " .. waarde .. " seconden aangezet....", dz.LOG_INFO)    
    end

end
}