Page 1 of 1

Switch turns on/off every 15 min.

Posted: Wednesday 11 January 2017 15:38
by nedde
I want the switch to turn of after 15 minutes after it is turend on but it keeps
turning on/off every 15 min instead. What's am I doing wrong? Picture Attached.

Re: Switch turns on/off every 15 min.

Posted: Wednesday 11 January 2017 15:41
by anasazi
Shouldn't you be using "Off AFTER 15" instead of FOR.

Re: Switch turns on/off every 15 min.

Posted: Wednesday 11 January 2017 15:45
by jumbotroll
Try this :-)

If Kaffe = On
Do
Set Kaffe = On For 15 minutes

Re: Switch turns on/off every 15 min.

Posted: Wednesday 11 January 2017 15:52
by emme
I think you cannot do that with blocky....
the script will loop all the time....

try LUA instead:

Code: Select all

commandArray = {}
     if devicechanged['Kaffe'] and otherdevices['Kaffe'] == 'On' then
          commandArray['Kaffe'] = 'On FOR 900'     -- the FOR instance works in secs
     end
return commandArray

Re: Switch turns on/off every 15 min.

Posted: Wednesday 11 January 2017 16:00
by Egregius
Or pass2php:

Code: Select all

<?php
if(apcu_fetch('sKaffe')=='On'&&apcu_fetch('tKaffe')<time-900) sw(apcu_fetch('iKaffe'),'Off');
 

Re: Switch turns on/off every 15 min.

Posted: Wednesday 11 January 2017 17:14
by StanHD
There is an "Off After X Seconds" block (900 seconds) ;)

Re: RE: Re: Switch turns on/off every 15 min.

Posted: Friday 13 January 2017 23:10
by nedde
anasazi wrote:Shouldn't you be using "Off AFTER 15" instead of FOR.
Worked a lot better :) thx

Sent from my Nexus 6 using Tapatalk

Re: Switch turns on/off every 15 min.

Posted: Tuesday 21 February 2017 11:35
by gielie
I have a question, i have this code.

Code: Select all

commandArray = {}
     if devicechanged['Koffie'] and otherdevices['Koffie'] == 'On' then
          commandArray['Koffie'] = 'On FOR 600'     -- the FOR instance works in secs
    if devicechanged['Koffie'] and otherdevices['Koffie'] == 'Off' then
          commandArray['SendNotification']='Koffie machine is uitgeschakeld'
     end
return commandArray
But when de koffie is Off Domoticz will spam me with messages, i only want to recieve 1 message after the event took place.
How can i do this?

Re: Switch turns on/off every 15 min.

Posted: Tuesday 21 February 2017 12:27
by Nautilus
gielie wrote:I have a question, i have this code.

Code: Select all

commandArray = {}
     if devicechanged['Koffie'] and otherdevices['Koffie'] == 'On' then
          commandArray['Koffie'] = 'On FOR 600'     -- the FOR instance works in secs
    if devicechanged['Koffie'] and otherdevices['Koffie'] == 'Off' then
          commandArray['SendNotification']='Koffie machine is uitgeschakeld'
     end
return commandArray
But when de koffie is Off Domoticz will spam me with messages, i only want to recieve 1 message after the event took place.
How can i do this?
The syntax is bit incorrect, not sure if this is the reason. Try:

Code: Select all

commandArray = {}
if devicechanged['Koffie'] == 'On' then
    commandArray['Koffie'] = 'On FOR 600'     -- the FOR instance works in secs
elseif devicechanged['Koffie'] == 'Off' then
    commandArray['SendNotification']='Koffie machine is uitgeschakeld'
end
return commandArray

Re: Switch turns on/off every 15 min.

Posted: Tuesday 21 February 2017 12:31
by emme
could it be that the ON FOR 600 keep the device in the devicechanged table for 600 seconds?!

Re: Switch turns on/off every 15 min.

Posted: Tuesday 21 February 2017 12:35
by Nautilus
emme wrote:could it be that the ON FOR 600 keep the device in the devicechanged table for 600 seconds?!
Not sure about this, but agreed that more logical would be:

Code: Select all

commandArray = {}
if devicechanged['Koffie'] == 'On' then
    commandArray['Koffie'] = 'Off AFTER 600' 
elseif devicechanged['Koffie'] == 'Off' then
    commandArray['SendNotification']='Koffie machine is uitgeschakeld'
end
return commandArray

Re: Switch turns on/off every 15 min.

Posted: Tuesday 21 February 2017 15:47
by gielie
U guys are great, it works, thanks a lot.

Is there also a way to create a countdown?

Re: Switch turns on/off every 15 min.

Posted: Tuesday 21 February 2017 16:03
by Nautilus
gielie wrote:Is there also a way to create a countdown?
Sure, with a time script (they run once each minute) you can at least have a once per minute count down timer...