Blink light

Moderator: leecollings

Post Reply
Gergg
Posts: 2
Joined: Tuesday 17 June 2014 17:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Blink light

Post by Gergg »

hi,

i want to make a blink light to make a meeting reminder but i dont find the sleep command.

like :
commandArray = {}
if (devicechanged['blink_switsh'] == 'On') then
commandArray['blink_switsh']='Off'
commandArray['light']='On'
sleep(10000)
commandArray['light']='off'
end
return commandArray

Some one can help me ?

Ty
Greg
User avatar
CopyCatz
Developer
Posts: 123
Joined: Thursday 11 July 2013 17:28
Target OS: -
Domoticz version:
Location: Outer Heaven
Contact:

Re: Blink light

Post by CopyCatz »

You can't do it that way because the light is not controlled during the time the script runs; the script decides what needs to be done and puts the action in the commandarray which is executed on return. The commandarray does not support intervals. What you can do is "On FOR 1" or "On FOR 0.1" for 6 seconds. A more robust way to do this when the light is dedicated for the meeting signal: put an off delay in the light setting, and only switch it on using the script.
Gergg
Posts: 2
Joined: Tuesday 17 June 2014 17:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blink light

Post by Gergg »

ok thank you, I'll see to launch another script that will do what I want with curl.

like :

curl 'http://domoticz/json.htm?type=command&p ... &passcode='
...
Derik
Posts: 1602
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Blink light

Post by Derik »

Is this working??

Like this option to..
Do you please have a code to share?
And perhaps a little support?
Is there a options to switch a dummy so the script is blinking for x seconds?


Thanks...

Wife @ home al light blinking... :D :D :D
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
Justintime
Posts: 228
Joined: Thursday 21 May 2015 9:08
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Blink light

Post by Justintime »

Also in search how to let a device blink.

But every post is a dead end. Someone managed to do this?
User avatar
Egregius
Posts: 2590
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Blink light

Post by Egregius »

Could be easy in php. A simple loop that executes x times with sleeps in between.
User avatar
Egregius
Posts: 2590
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Blink light

Post by Egregius »

Voila, previous post was on smartphone.
Now on computer:

Code: Select all

<?php
$idx=153;
for ($k = 1 ; $k <= 3; $k++){
	file_get_contents('http://ip:port/json.htm?type=command&param=switchlight&idx='.$idx.'&switchcmd=On');
	sleep(1);
	file_get_contents('http://ip:port/json.htm?type=command&param=switchlight&idx='.$idx.'&switchcmd=Off');
	sleep(1);
}
This will switch the idx on for 1 sec en then of for one second. The loop runs 3 times.
Is a 1 second resolution isn't enough you can also use usleep(500000) for 0,5 sec.

If you're using my php functions it could be as easy as

Code: Select all

<?php
include secure/functions.php
for ($k = 1 ; $k <= 3; $k++){
	Schakel(153,'On');
	sleep(1);
	Schakel(153,'Off');
	sleep(1);
}
BakSeeDaa
Posts: 485
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi / ODroid
Domoticz version:

Re: Blink light

Post by BakSeeDaa »

Here is my implementation of a "blink light" function.

The function takes 2 parameters.
Parameter 1: The idx of the device to blink
Parameter 2: (Optional) Number of times the device shall blink.

The function also checks if the light is on before the blink occurs, hence the lights initial status won't be altered. The blink length is hard coded to 3 seconds and the time between the blinks is also 3 seconds.

I use it for example when someone pushes the door bell to blink the outdoor lights as a confirmation that the doorbell is working. Without confirmation some people tend to bang the door instead after 10 seconds.

Code: Select all

function blinkLight(light, times)
	times = times or 2
	local cmd1 = 'Off'
	local cmd2 = 'On'
	local pause = 0
	if (otherdevices[light] == 'Off') then
		cmd1 = 'On'
		cmd2 = 'Off'
	end	
	for i = 1, times do
		commandArray[#commandArray + 1]={[light]=cmd1..' AFTER '..pause }
		pause = pause + 3
		commandArray[#commandArray + 1]={[light]=cmd2..' AFTER '..pause }
		pause = pause + 3
	end
end
Use it like this:

Code: Select all

blinkLight(53, 3) -- blink device 53 3 times
or just like this:

Code: Select all

blinkLight(53) -- blink device 53 the default number of times (which is 2)
Xroads
Posts: 30
Joined: Thursday 25 February 2016 10:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blink light

Post by Xroads »

Hi
As a really new user of Domoticz, I would like to use BakSeeDaa's function to blink a light.
But where do I put the function, is it in a lua script or?
Raspberry pi 2
Razberry z-wave module with Fibaro dimmer, relay and pir and Dlink pir.
433mhz RFlink with 5 pcs. on/off switches
oliviers
Posts: 73
Joined: Wednesday 16 September 2015 22:10
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Paris area, France
Contact:

Re: Blink light

Post by oliviers »

Hi,

You could also just use a stroboscopic flash like this one:

http://www.conrad.fr/ce/fr/product/7531 ... archDetail

With a RFX433 or ZWAVE outlet ... You just need to turn it ON and OFF ... No scripts ! I use two of those personally.

Oliviers
Paris area
Raspberry Pi 4 - RFXComm 433 - IrTrans - Zwave
Xroads
Posts: 30
Joined: Thursday 25 February 2016 10:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blink light

Post by Xroads »

Yes I could, but its only for my doorbell, so maybee a bit overkill :D
Raspberry pi 2
Razberry z-wave module with Fibaro dimmer, relay and pir and Dlink pir.
433mhz RFlink with 5 pcs. on/off switches
Xroads
Posts: 30
Joined: Thursday 25 February 2016 10:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blink light

Post by Xroads »

Ok, found out that it's for a lua script.
But now the only thing i'm getting is a error message.
Error: EventSystem: commandArray in script /home/pi/domoticz/scripts/lua/script_device_doorbell.lua should only return ['string']='actionstring' or [integer]={['string']='actionstring'}

This is the code I'm using, please anyone

Code: Select all

commandArray = {}

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

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

return commandArray
Raspberry pi 2
Razberry z-wave module with Fibaro dimmer, relay and pir and Dlink pir.
433mhz RFlink with 5 pcs. on/off switches
davewins
Posts: 3
Joined: Thursday 11 August 2016 18:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blink light

Post by davewins »

I just got this working, and you need to change the device ID (75) to the name of the device e.g. "Lamp",

so you change the BlinkLight line to be:

blinkLight("Lamp")

hope it helps.
chatainsim
Posts: 101
Joined: Wednesday 25 March 2015 10:46
Target OS: Linux
Domoticz version: v4.11307
Location: France
Contact:

Re: Blink light

Post by chatainsim »

Just found this in the wiki:

Code: Select all

   commandArray['MyOtherDeviceName7'] = "On FOR 2 SECONDS REPEAT 9 INTERVAL 4 SECONDS" -- every 4 seconds and do that 9 times, put device On for 2 seconds
https://www.domoticz.com/wiki/LUA_commands

I don't know which version you need.
gemminiss
Posts: 3
Joined: Tuesday 06 March 2018 16:33
Target OS: Windows
Domoticz version:
Contact:

Re: Blink light

Post by gemminiss »

SOLVED

Hello everyone, I'm new to this forum and I would like to share something with you:

I just wanted to make a light blinking when another device was 'On'. As I have low programming skills, I tried to find an existing script in this forum already doing the job (LUA, Python, PHP), unfortunately, I got so many errors and problems, that I was close to give up.

Well, I did so much reading and testing that finally I learnt a little bit of LUA. Today I tried to do a script by myself, and it worked!! :D

The solution I found is so simple and easy that I have the impression that I'm missing something, it can not be so easy...(expert developer comments are welcomed)

HERE WE GO
Let's consider:
Device 'A' as trigger ( can be dummy switch, door Sensor, motion detector)
Device 'B' as the device we want it blinks (Another Dummy switch, a real siren, a Light dimmer...)

1st Step:
Go to Domoticz Event Editor, and create à new event with:
Event name: Blink Test
Second Box: Lua
Third box: device
Activate: Event Active (check box)

2nd Step
In the Left Editor, paste this:

Code: Select all

commandArray = {}
if (devicechanged['A'] == 'On') then
   
   if(otherdevices['B']== 'Off') then
    commandArray['B'] = "On FOR 3 SECONDS REPEAT 5 INTERVAL 6 SECONDS" 
    
    else
    commandArray['B'] = "Off FOR 3 SECONDS REPEAT 5 INTERVAL 6 SECONDS"
    end
    
end
return commandArray
3rd Step
Replace 'A' and 'B', by the Name's of your Device's you want to use instead. (We need the Name, NOT the Idx)
Save the Event and test it !!

For the test I did simple:
I created a Dummy switch (Switch 'A'), and I set as Switch 'B', my room's light (controlled by a Fibaro Dimmer 2), and It Works!,

The comment of chatainsim gave me the idea (Thanks!!), he was right: in https://www.domoticz.com/wiki/LUA_commands

There is a list of several possibilities of sending instructions with commandArray:

Code: Select all

commandArray['MyOtherDeviceName5']='Off RANDOM 30' -- random within x minutes
commandArray['MyOtherDeviceName6']='On REPEAT 5 INTERVAL 5' -- command will be repeated 5 times with 5 seconds interval
commandArray['MyOtherDeviceName7'] = "On FOR 2 SECONDS REPEAT 9 INTERVAL 4 SECONDS" -- every 4 seconds and do that 9 times, put device On for 2 seconds
For my test, I used the 3rd case but modifying the values. My dimmable LED bulbs need some time to get up 100% and then down to 0%. I've tried with:
"On FOR 1 SECONDS REPEAT 3 INTERVAL 2 SECONDS" , to have a Flash Effect...but it seems that it's too fast for the bulbs and/or the Fibaro Dimmers, they stay 'On' all along the cycle.

Regarding the code:
I had to add a 2nd IF: if(otherdevices['B']== 'Off') else , because of:
1 - I want than at the end of the cycle the light gets back to the original state.
2 - I experimented (With the Fibaro Dimmer 2) that if the light was already 'On', sending a cycle of several 'On' the light stayed ''physically'' always 'On' , that's why I'm sending a cycle of several 'Off'
3 - I do not know, if a dimmer at 30% it is considered as 'On'. That's why saying that whatever else than 'Off', it is 'On'.

Well, Try it and let me know, all comments are welcomed!
Eyedon
Posts: 4
Joined: Tuesday 28 November 2017 23:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Netherlands
Contact:

Re: Blink light

Post by Eyedon »

Hi,

What I want is to trigger multiple devices at once to blink. I made a dummy button and use the Lua script above as basic script. Unfortunately the blink frequency is very instable for each device. I want to trigger on/off all the lights at once with the same frequency.

Device: Zwave switches / Raspberry pi
Purpose: let all the lights in the house blink stable: the same time, the same frequency

Hope someone can give me an advice...

Script:

Code: Select all

commandArray = {}

if (devicechanged['Knipperen'] == 'On') then
   
   if(otherdevices['Verlichting_begane_grond_Woonkamer']== 'Off') then
    commandArray['Verlichting_begane_grond_Woonkamer'] = "On FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS" 

    else
    commandArray['Verlichting_begane_grond_Woonkamer'] = "Off FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS"

    end


   if(otherdevices['Verlichting_begane_grond_keuken']== 'Off') then
    commandArray['Verlichting_begane_grond_keuken'] = "On FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS" 

    else
    commandArray['Verlichting_begane_grond_keuken'] = "Off FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS"

    end

   if(otherdevices['Verlichting_eerste_verdieping_Overloop']== 'Off') then
    commandArray['Verlichting_eerste_verdieping_Overloop'] = "On FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS" 

    else
    commandArray['Verlichting_eerste_verdieping_Overloop'] = "Off FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS"

    end

   if(otherdevices['Verlichting_buitenlamp_achterdeur']== 'Off') then
    commandArray['Verlichting_buitenlamp_achterdeur'] = "On FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS" 

    else
    commandArray['Verlichting_buitenlamp_achterdeur'] = "Off FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS"

    end

   if(otherdevices['Verlichting_begane_grond_Hal']== 'Off') then
    commandArray['Verlichting_begane_grond_Hal'] = "On FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS" 

    else
    commandArray['Verlichting_begane_grond_Hal'] = "Off FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS"

    end


   if(otherdevices['Verlichting_tweede_verdieping_Overloop']== 'Off') then
    commandArray['Verlichting_tweede_verdieping_Overloop'] = "On FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS" 

    else
    commandArray['Verlichting_tweede_verdieping_Overloop'] = "Off FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS"

    end

   if(otherdevices['Verlichting_buitenlamp_schuur']== 'Off') then
    commandArray['Verlichting_buitenlamp_schuur'] = "On FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS" 

    else
    commandArray['Verlichting_buitenlamp_schuur'] = "Off FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS"

    end

   if(otherdevices['Verlichting_tweede_verdieping_Zolderkamer_Dakopbouw']== 'Off') then
    commandArray['Verlichting_tweede_verdieping_Zolderkamer_Dakopbouw'] = "On FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS" 

    else
    commandArray['Verlichting_tweede_verdieping_Zolderkamer_Dakopbouw'] = "Off FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS"

    end

   if(otherdevices['Verlichting_tweede_verdieping_Zolderkamer_Dakkapel']== 'Off') then
    commandArray['Verlichting_tweede_verdieping_Zolderkamer_Dakkapel'] = "On FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS" 

    else
    commandArray['Verlichting_tweede_verdieping_Zolderkamer_Dakkapel'] = "Off FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS"

    end


end
return commandArray


Eyedon
Posts: 4
Joined: Tuesday 28 November 2017 23:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Netherlands
Contact:

Re: Blink light

Post by Eyedon »

Hi,

I solved it myself using a group and the script below. The swithes don't work perfectly synch, but I can live with the result.

grtz

Code: Select all

commandArray = {}

if (devicechanged['Knipperen'] == 'On') then
   
   if(otherdevices['Verlichting_buitenlamp_schuur']== 'Off') then
    commandArray['Group:Knippergroep'] = "On FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS" 

    else
    commandArray['Group:Knippergroep'] = "Off FOR 2 SECONDS REPEAT 10 INTERVAL 4 SECONDS"
    end

end
return commandArray
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest