Openhab,make a light to flash

hello,i want to make a rule so when triggered one or a group of my yeelights will flash a color red.What is the simplest way to do that?

It depends on how long you want the light to be on and how many flashes you want them to flash.

If just one short flash then:

    Thread::sleep(1000) // nothing longer

If you want the light to stay on for longer than one second you need to get more complicated:

    createTimer(now.plusSeconds(5), [| MyLight.sendCommand(OFF)])

If you want to flash repeatedly for a long time see Loop rule (in OH2) which lets you flash Morse Code.


Thanx mate i made a loop rule so now i can flash whatever color i want ,i want to use it for home notifications,doorbell,alarm etc…

i see the HSBType command supports only red,green,blue and white colors.I tried other colors like cyan or yellow and not working.How can i use other colors?

You will have to figure out the HSB values for those colors or use the following to convert an RGB to HSB.

find it out my self ,i had to use Light.sendCommand(“x,x,x”) (x is a number from 0 to 360) to set what color i need. The sendCommand(HSBType::color) can only set directly RED,GREEN,BLUE and WHITE colors.