Blink light

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

Blink light

Post by Gergg » Thursday 26 June 2014 11:43

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: 751
Joined: Thursday 11 July 2013 17:28
Target OS: -
Domoticz version:
Location: Outer Heaven
Contact:

Re: Blink light

Post by CopyCatz » Thursday 26 June 2014 14:42

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: 9
Joined: Tuesday 17 June 2014 17:24
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blink light

Post by Gergg » Thursday 26 June 2014 16:39

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='
...

User avatar
Derik
Posts: 1973
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Blink light

Post by Derik » Sunday 27 July 2014 23:20

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: 319
Joined: Thursday 21 May 2015 9:08
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Blink light

Post by Justintime » Monday 07 September 2015 19:56

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: 2513
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: Beta
Location: Beitem, BE
Contact:

Re: Blink light

Post by Egregius » Monday 07 September 2015 22:34

Could be easy in php. A simple loop that executes x times with sleeps in between.

User avatar
Egregius
Posts: 2513
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: Beta
Location: Beitem, BE
Contact:

Re: Blink light

Post by Egregius » Tuesday 08 September 2015 7:24

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: 544
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version:

Re: Blink light

Post by BakSeeDaa » Wednesday 11 November 2015 18:21

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)
Admins, please delete my profile. Thanks.

Xroads
Posts: 31
Joined: Thursday 25 February 2016 11:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blink light

Post by Xroads » Saturday 26 March 2016 18:57

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: 78
Joined: Wednesday 16 September 2015 22:10
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Paris area, France
Contact:

Re: Blink light

Post by oliviers » Saturday 26 March 2016 19:21

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 2B - RFXComm 433 - IrTrans - Zwave

Xroads
Posts: 31
Joined: Thursday 25 February 2016 11:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blink light

Post by Xroads » Saturday 26 March 2016 20:53

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: 31
Joined: Thursday 25 February 2016 11:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blink light

Post by Xroads » Sunday 27 March 2016 15:28

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: 2
Joined: Thursday 11 August 2016 18:41
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Blink light

Post by davewins » Thursday 11 August 2016 18:43

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: 85
Joined: Wednesday 25 March 2015 11:46
Target OS: Linux
Domoticz version: v3.8153
Location: France
Contact:

Re: Blink light

Post by chatainsim » Saturday 13 January 2018 0:06

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests