Need this: While Button Held, repeat every 2 seconds

I have this rule, but I want to modify it. I would like the action to repeat every couple seconds while the button is held. Is this possible? I tried... couldn't figure it out.

The first step would be to figure out what events your button sends. It looks like it can do held and doubleTapped (and probably pushed, which you aren't using). What you'd need to make it really work as you want is released. However, I'd ask what you're really trying to do. If it's manipulate a light that supports startLevelChange and stopLevelChange and you want a "dim while held" thing, using those commands (the former on hold, latter on release) would be a much better idea than a repeat of setLevels (which is possible using Rule Machine actions but, again, may not be the best idea).

1 Like

Unfortunately, the Hubduino dimmer does not support startLevelChange (yet). I tried that first, but it did nothing. I dug into the dimmer child driver, and found those attributes to be missing. I started editing the driver, but am a little rusty with Java. It will be a while before I can get that working. I am trying to do a temporary work around with rules. The button reports Held, Released, Double Tapped and Pushed. I am using Pushed already to turn the dimmer off and on to the previous dimmer setting. It is a Zooz Zen21 Gen3. It is working great as a scene controller, just need to learn how to use Rule Machine 4.

For now, until I can rework the driver and microcontroller code, I would just be happy to add repeat to the Held Actions.

OK, you said it was possible, so I was determined to figure it out! I am just getting my head wrapped around the Rule Machine. I was looking in the wrong spot (conditional). I am a little dense sometimes!

2 Likes

What type of button is this? You have a button device that supports Held and Double Tap? I've never seen a button that supports both of those. That is quite a complicated thing to bull off for the driver. The only way you can do this is if the button supports the release event. This is not going to work the way you want it to. The held event is a one-time thing. Not a state. The way that you get ramping in Hubitat through startLevelChange is by beginning the dimiming/brightening when the button is pushed/held and then using the stopLevelChange command when the button is released.

That is because the code doesn't exist in the Hubduino library on your board. It has less to do with the driver than it does with the device. The device has to support the level change capability. Basically, if you are brightening the bulb, you tell the bulb to go to 100% over a length of time and then when you stop the level change you basically tell the bulb to abort the chagne that it was making. Similar architecture is very difficult if your device software doesn't support that. It's a very complicated thing. I've not been able to find any ESP8266 LED software that supports "ramping" in the way Hubitat or Hue manages it. That includes DIYHue, who have a couple dozen sketches for ESP based lights. None of them support ramping in this way.

The SmartThings Button supports pushed, held, doubleTapped, and released. (As do a lot of in-wall Z-Wave scene switches.)

I believe the rule they posted above will work (working around the lack of the Change Level capability by a repeat on setLevel, which is definitely not the most reliable way to do this and why I advised against it--but probably the only way if you really want this to happen exactly in this way). I've actually never tried RM in "Button Device" mode with a "Stop Repeat" in a different action/button event than the actual repeat (so wasn't really sure if that was a thing you could do), but if they've tested it and it works...

1 Like

Already stated above:

Correct. I stated that as one of the attributes it reports:

It does. It is functioning perfectly. By using Repeat, it steps the dimmer. While you are correct that the held event only reports once, it is the Released event that doesn't fire until the Held action is over. This triggers Stop Repeating Actions.

Give me a few weeks, I already rewrote Dan's Dimmer code to ramp dimmer changes within the arduino sketch. It will not be hard to tweak it a bit to allow the attributes that HE uses, but the driver must also receive and pass those via the stAnything communication strings. So, the driver is actually just as important as the sketch.

I also created a 10k Thermistor sketch that I will share shortly. Once I have finished my tweak to the dimmer code, I will be sending them both to @ogiewon so he can review them and incorporate them into the main Hubduino GitHub. I may need his support on the dimmer driver, but I am going to take a stab at it first.

Yes it does! I am happy with it for now. It is just temporary, but I am satisfied to leave it for a while until I get my freezer temp sensor installed, and garage door opener controller. I typically use the Dashboard tile to contol that light anyway. The switch was to improve the WAF. :wink:

I had to create two other rules though. The Zen21 only reports On and Off when controlling it via a remote standard 3-way switch. So I have a rule that follows the state of the switch relay, and another to follow the hubduino state if I turn it on or off via a tile.

1 Like

Okay. Let me know what you come up with.

But if you already re-wrote it, then why do you need the repeat?

To implement dimmer fade duration command, and the other attributes mentioned above like startDimmerFade, stopDimmerFade, etc. I modified it a couple weeks ago to ramp to the setDimmerLevel value. It is a hard coded ramp for a fixed duration per step. I want it to have a default ramp, that is fairly quick, but also be able to accept a duration from a command in Hubitat. And I obviously just found out a couple days ago it didn't do those other things.

So....I'm not following. You did re-write it or you didn't re-write it?

Also, you're talking about PWM dimming in Hubduino. I was talking about ESP8266 LED dimming using addressable LEDs with something like the FastLED or NeoPixel Libraries. That is what I use for my DIYHue strips. I've not been able to figure out anything to build into them to get startChaning stopChaning to work. But if you can, I'm all ears! :slight_smile:

Yes, I am talking about a simple PWM dimmer controlling about 45ft of white 5050 led strips. I have a 12v 20A PSU going to a MOSFET.

To be specific, I modified, in the ST_Anything Library, the files called EX_Switch_Dim.cpp and its header file to become EX_PWM_Dim.cpp and its header file. I removed the switch part, since my MOSFET only needs the PWM input. I added a routine that ramps the given dimmer value from its previous state to the value it was set to.

Now, I see that it is missing other functions that I am willing to take the time to add to make it a more functional file.

Once I learn how to do all that, I will attempt tackle the ALED stuff. I have FastLED demo running on Mega 2560 right now, but not in Hubitat. It will need a custom child driver, and I will struggle with that part. The Arduino code I can write in my sleep.

I have the drivers for Hubitat. What I can't get is how to get the startLevelChange and stopLevelChange from NeoPixelBus. I have 5 strips running boards based on sketches developed for the DIYHue system. They incorporate into Hubitat just like Hue lights do. And those do support those commands. And i know exactly what the commands going to the board are. I just need to be able to know how to implement those actions using that library. Then we would be all set.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.