I want to start by saying that this function itself works relatively well, but there is one small issue - the long-press tends to confuse the system. The long-press itself works all right, but when I release, it's interpreted as a "click" and the function associated with that (toggle light) fires. That's the primary issue I need help with.
Other than that, I'm looking for ideas to improve this rule-set, if it can be optimised in any way. I'm still a beginner so I'm certain there are things that I haven't thought of / discovered yet.
The reason this set exists is that I have only one WallMote and I would like to be able to control my lights' brightness with a physical controller. With three lights and only four buttons, I had to get a bit creative. Here's what I came up with:
I started off by setting up a few Hub Variables:
Most of these should be obvious, but you may be wondering why I have "Number of Lights" as a variable. This provides a bit of scalability. You'll see how in a moment.
The first step was creating a rule that would flash a light based on the variable "Selected Light" - this tells me which light's brightness I am about to control.
If I ever add lights to my living room, I simply need to add another copy of the "Else If" block with a new number and assign it to that light, and update the "Number of Lights" I have.
Next, I wrote a rule that will let me select a specific light. This rule also runs the actions of the previous one to show me which light is selected. This is where the "Number of Lights" is useful - using this variable, I can cycle through each light.
I don't NEED to use a variable here, but I prefer using variables wherever possible because changing values becomes a bit easier - I don't need to dig in to rules and mess aroud with editing specific statements (which is really quite clunky and annoying).
Then, I wrote rules for increasing and decreasing the brightness of the selected light:
Again, if I add more lights, I simply need to duplicate an "Else-If" Block. Speaking of, is there an easy way to copy a few rule lines? I know I can cut and move them, but there doesn't seem to be a way to copy-paste.
One potential optimisation I can think of is somehow defining which Selected Light
corresponds to which light. If there's any way to create a table where this is defined, then perhaps I won't need to update every rule every time I add a light. I have no idea how to write this and if at all it is even possible!