Fibaro rgbw sequence


#1

Hi guys

I have fibaro rgbw strip. Im trying to use webcore to create a sequence of colours operated by a virtual switch (a bit like fibaros programmes )

I’ve got this far but I don’t know how to make the sequence repeat untill I switch off the virtual switch.

Can anyone help?


#2

You need to use a ‘while’ loop. (Turn on advanced statements in the piston editor settings)

Here’s how I get random changes every 3 seconds using a Fibaro RGBW:

For set colours just change the contents of the ‘with’ block.

You’ll get very unreliable results with 1 second waits due to cloud lag… I find the minimum reliable setting is 3 seconds.

Never use a while loop without a wait… it executed too fast as is basically a DDOS on your home!


#3

Thanks Robin . I’m not clear what part of that code is causing it to loop until turned off or what the ‘n’ and ‘cp’ i see does. Is the 3 secs between each colour or at the end of th e sequence ?

Could you help me understand ? Thanks


#4

Yes, the actions are in the ‘do’ section of the piston… so you would change that part to:

set color to x
wait 3 seconds
set color to y
wait 3 seconds
set color to z
wait 3 seconds

The part at the top of the piston just turns the RGB bulb(s) on / off depending on the state of the trigger switch (switch 10).

Just read it through logically:

while switch 10 is on, set color, wait

(and the while just keeps looping until switch 10 is turned off)


#5

Hmm. No luck. What am I doing wrong?


#6

You deleted the loop… so it will only work its way through the actions once and then the piston will stop.


#7

Hmm. But it isnt doing it even once.

ps. not sure which bit I’ve deleted either but will take another look


#8

You should know that ‘transition to color’ is an emulated feature, not a ST command or device command. WC has to send a series of color change commands to simulate the transition, with as many steps as possible across the specified duration.

Trying to transition over a short duration like 5 seconds is hardly worth doing… webCoRE will only send a step command every 3 seconds of so, and therefore the transiton will not be smooth.

Just use set color.


#9

Thank you. Will set colour still do it gradually and smoothly?

Also i’ve had a look at the code and not sure what 'loop I’ve deleted ?


#10

Yes, the Fibaro in RGBW mode defaults to a 3 second fade. This can be adjusted via parameter 11 on the device handler.

It’s the ‘while’ loop shown in my example in post 2.


#11

Thanks Robin.

I’m not sure which bit you mean ? I still have ‘execute while’ at the start.

Sorry for stupid question


#12

This is what my piston looks like now. But it just turns on at blue (no idea why since blue isnt one of the colours i’ve put in this piston) and doesnt change. If i open the bulb’s screen on smartthings app i can see the colour wheel and brightness shifting from one thing to another as I’ve programmed but the bulb doesnt actually change colour. Any ideas?


#13

sorry, was replying on my phone before and missed that :crazy_face:


#14

Hmmmm… thinking back I had similar issues with my Fibaro RGBW not respecting webcore preset commands… I had to change something on the DTH… give me a sec and I’ll try to find what I changed lol


#15

Ok… If you’re using the handler I assume you’re using, it has a very weird (and unsafe) method of figuring out what method to use for setColor…

Find this line:

if (( value.size() == 1) && (value.hex)) { //being called from outside of device (App) with only hex

and comment it out and replace it with

if (value.hex) { //being called from outside of device (App) with only hex

Save and publish


#16

Ha. I wondered if the problem was the presets so I tried with just standard colour values and it still didn’t work :frowning:


#17

To comment it out do I just put // at the start of it ? Or do I need one at the end of that line too ? Should there be a space between the slash and the first character of th e line ?


#18

for just a single line // at the start is all you need. (space or no space makes no difference)

for multiple lines /* at the start and */ at the end works best.


#19

Tried to do that, dry code now says the below but on trying to save/publish I get this error

def setColor(value) {
log.debug “setColor: ${value}”

if (value.size() < 8)
	toggleTiles("off")

if (( value.size() == 2) && (value.hue != null) && (value.saturation != null)) { //assuming we're being called from outside of device (App)
	def rgb = hslToRGB(value.hue, value.saturation, 0.5)
    value.hex = rgbToHex(rgb)
    value.rh = hex(rgb.r)
    value.gh = hex(rgb.g)
    value.bh = hex(rgb.b)
}

if ((value.size() == 3) && (value.hue != null) && (value.saturation != null) && (value.level)) { //user passed in a level value too from outside (App)
	def rgb = hslToRGB(value.hue, value.saturation, 0.5)
    value.hex = rgbToHex(rgb)
    value.rh = hex(rgb.r * value.level/100)
    value.gh = hex(rgb.g * value.level/100)
    value.bh = hex(rgb.b * value.level/100)       
}

//if (( value.size() == 1) && (value.hex)) { //being called from outside of device (App) with only hex
	def rgbInt = hexToRgb(value.hex)
    value.rh = hex(rgbInt.r)
    value.gh = hex(rgbInt.g)
    value.bh = hex(rgbInt.b)
}

if (( value.size() == 2) && (value.hex) && (value.level)) { //being called from outside of device (App) with only hex and level

    def rgbInt = hexToRgb(value.hex)
    value.rh = hex(rgbInt.r * value.level/100)
    value.gh = hex(rgbInt.g * value.level/100)
    value.bh = hex(rgbInt.b * value.level/100)
}

if (( value.size() == 1) && (value.colorName)) { //being called from outside of device (App) with only color name
    def colorData = getColorData(value.colorName)
    value.rh = colorData.rh
    value.gh = colorData.gh
    value.bh = colorData.bh
    value.hex = "#${value.rh}${value.gh}${value.bh}"
}

if (( value.size() == 2) && (value.colorName) && (value.level)) { //being called from outside of device (App) with only color name and level

#20

you commented out the correct line but didn’t replace it with the new line :wink: