Determining If Button Push Trigger Caused Rule to Awaken

So, I just got some Hue Smart Buttons, and they activate my washer and dryer rules when pushed. However, I cannot figure out how to do something in the rule based upon the button push. That is, I need to know if it was the button push that triggered the rule. I tried "Last Device Event" and that seemed to work at first, but as the power is changing on my power monitor, I am seeing that my Last Device Event is true even when no button push. See part of the rule below. I could set up a separate rule that only triggers on the button, then set a variable and map it to a switch and have my dryer rule trigger off of the virtual switch. However, before I do that and break one rule into two, I wondered if there isn't an easier way to detect the button push was the reason for the trigger.

Triggers

As an aside, if I try to edit the rule with "display current values" on then I get the error:

Unexpected Error

#### An unexpected error has occurred trying to load the app. Check [Logs](http://192.168.1.140/logs) for more information.

Error: Command 'toLong' is not supported by device 855.

and this in the log:

2022-01-16 10:02:54.138 errorjava.lang.IllegalArgumentException: Command 'toLong' is not supported by device 855. on line 7201 (method selectActions)

I think this is because of the comparison of pushed to a real number rather than integer.

If you want to do different things based on different triggers, that's a good sign the rule might be better split in two (and then you don't have to worry about why it triggered--you already know). While we can't see your actions in their entirety and provide more targeted advice, that's still generally my preference.

That being said, your "Last Event Device" line will read, in this case, the pushed attribute value from whatever the triggering device was. If that device does not have a pushed attribute (which, presumably, nothing besides the button would), I am not sure what it will do, but I wouldn't be surprised if that caused the error you see when turning on "Display current values" if the last event device was not the button.

That being said, if you want to continue with a single rule, my advice would be to take a different approach: temporarily assign a (local) variable the value of the built-in %device% or %event% variables, which will be either "Laundry Button—Dryer" (for %device%) or 1 (for %value%). Because they cannot be accessed directly in a conditional, you'll need to assign them to an actual variable first. Both are a bit hack-y; the first depends on you never changing the display name of the device (device label, if specified, or device name), whereas the latter exploits the fact that 1 is likely to only come from your button as the event value (though it could come from the Dryer Power reading, too, I suppose...so maybe not as good).

Gotcha. I'll keep the built in variables idea for another time. I broke the rule into two, it really didn't take long, and it works well. Thanks for the response.

Download the Hubitat app