Page 1 of 1

Send "Off" command twice in a row

Posted: Wednesday 17 May 2017 11:14
by sammyke007
Hi guys

I'm kind off new to Domoticz, but I'm already able to control all of my lights, Somfy shutters, make some Blocky scripts, ...

The one thing that won't work for now is activating my alarmsystem. I made an "Off" switch that's sending the right IR code, however I need to press the Off button twice in a row to get my alarm to listen to it.

I tried this:

Code: Select all

commandArray = {}

function blinkLight(light, times)
   times = times or 2
   local pause = 0
   for i = 1, times do
      commandArray[#commandArray + 1]={[light]='On AFTER '..pause }
      pause = pause + 3
      commandArray[#commandArray + 1]={[light]='Off AFTER '..pause }
      pause = pause + 3
   end
end

-- if (devicechanged['AlarmOff'] == 'Off') then
   blinkLight("AlarmOff") -- blink device 75 the default number of times (which is 2)
   
-- end

return commandArray
And it's working, however it's looping (I understand why...)

The second script I tried was

Code: Select all

commandArray = {}

-- if (deviceName=='AlarmOff') then
if devicechanged['AlarmOff'] == 'Off' then
            commandArray['AlarmOff']='On'
            commandArray[1]={['AlarmOff']='Off'}
            commandArray[2]={['AlarmOff']='On'}
            commandArray[3]={['AlarmOff']='Off'}
            commandArray[4]={['AlarmOff']='On'}
end

return commandArray
That aint working either...

Do I need to use a variabel?
Anyone that can help me out please?

Kind regards!

Re: Send "Off" command twice in a row

Posted: Wednesday 17 May 2017 23:20
by Siewert308SW
Why not using the following commandArray?

commandArray["Dummy"]='On AFTER 5 REPEAT 2 INTERVAL 10'

where:
AFTER = Switch device after 5 seconds
REPEAT = How many times the command has to be repeated
INTERVAL = When to start the new command when the first commandArray is finished.

Re: Send "Off" command twice in a row

Posted: Thursday 18 May 2017 1:28
by sion
It's probably neater using code as a above, you you could possibly add a group. And add you alarm switch twice. With a second off or on delay on the 2nd one

Re: Send "Off" command twice in a row

Posted: Thursday 18 May 2017 14:04
by sammyke007
Siewert308SW wrote:Why not using the following commandArray?

commandArray["Dummy"]='On AFTER 5 REPEAT 2 INTERVAL 10'

where:
AFTER = Switch device after 5 seconds
REPEAT = How many times the command has to be repeated
INTERVAL = When to start the new command when the first commandArray is finished.
It's working!
I use

Code: Select all

commandArray = {}

if devicechanged['AlarmOff'] == 'On' then
        commandArray["AlarmOff"]='Off REPEAT 2 INTERVAL 0.5'
end

return commandArray
Tnx a LOT!