Creating more complex rules - getting started

I’d like to do severala different things with the existing rules but it’s not obvious how and it may not be possible. Is this the correct place to discuss?

  1. I’d like to have a rule so that any time I change the colour of a bulb, a second light changes to the same colour. At the moment, it appears that I’d have to set up a separate rule for each possible colour. Or I’ve completely missed some aspect of the rules :slightly_smiling_face:
  2. I’d like to set up a pattern so that a light gradually changes colour, with say, a change in colour every 2 seconds. It looks as if this is possible but extremely tedious
  3. As 2 but a loop. This looks not to be possible

I believe you’re right that none of these are possible right now.

  1. Covered by https://github.com/mozilla-iot/gateway/issues/805
  2. I believe @kgiori has done some things like this with a NeoPixel, but I may be wrong.
  3. Maybe @kgiori as well.

You also have the option of using the REST/WebSocket APIs and doing things in your own script. That might make more sense for this use case. @twobraids has a good example of that here.

Using the Rules page, to group lights I often use the “Pulse” add-on, and create a one-second pulse for each color combo I want to configure. I label the pulses “go blue”, “go red”, “rainbow”, … for every color or color combinations I want. I also create pulse names like “party mode” that will trigger a variety of colors. On LED strips, sometimes I create a “rainbow” rule so that when the first LED is set to red, the remaining ones are set to a rainbow of color variants thereafter. Same can work for other colors (if LED1 is blue, set all the rest to blue.)

But as Mike said, to do this dynamically you’d need to write a script.

If you can program the lights directly, then you could use the gateway to trigger complex color patterns, and trigger them all at the same time. When I did that for a big NeoPixel project, I created one complex rule, then copied it out of the database, modified it umpteen different ways, and processed the commands using CLI to “insert” the additional rules directly into the database. Using the UI would have been way too cumbersome.

thanks for this @mrstegeman ( and @kgiori )

Is there a tutorial or sample written in Javascript that would give me a base to start from? Ideally, complete enough so that I could trigger from the gateway

I don’t know anything off hand written in JS. I’ve been wanting to create some webthing client libraries, but haven’t had the time to do it.