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: 2182
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: 322
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: 2738
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: 2738
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: 551
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)

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: 93
Joined: Wednesday 25 March 2015 11:46
Target OS: Linux
Domoticz version: v3.9439
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.

gemminiss
Posts: 2
Joined: Tuesday 06 March 2018 17:33
Target OS: Windows
Domoticz version:
Contact:

Re: Blink light

Post by gemminiss » Wednesday 04 July 2018 13:49

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!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest