Send "Off" command twice in a row

Moderator: leecollings

Post Reply
sammyke007
Posts: 204
Joined: Monday 08 May 2017 20:48
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Belgium
Contact:

Send "Off" command twice in a row

Post 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!
User avatar
Siewert308SW
Posts: 290
Joined: Monday 29 December 2014 15:47
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: Send "Off" command twice in a row

Post 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.
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
sion
Posts: 113
Joined: Friday 08 January 2016 12:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Send "Off" command twice in a row

Post 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
running domoticz 3.4834 on rpi2, with
Hue bridge / bulbs.
lightwave rf sockets, mood controlers, sensors & contacts.
Home bridge / Siri.
Ha bridge / echo Alexa.
Hard wired alarm system - setting home / away status.

Next: harmony hub.
sammyke007
Posts: 204
Joined: Monday 08 May 2017 20:48
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Belgium
Contact:

Re: Send "Off" command twice in a row

Post 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!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest