Bug - Set Variable from Device Attribute

Hey folks, I'm trying to set a variable based upon a device attribute, but the "Select Device" button doesn't list any devices. It's the same as this issue reported in Sept 2020: [BUG] Cannot Add Action to Set Variable to Device Attribute

Ultimately, I'm trying to set a dimmer to the attribute of another device, so I was going to set a variable when the dimmer changes, then use that variable to read into another device (unless there's a way to access a different device's attributes when setting a dimmer value).

Steps:

  1. Create Rule
  2. Click "Select Actions to Run"
  3. Select option "Set Mode, Variables or File, Run Custom Action"
  4. Under "Select Action" click "Set Variable"
  5. Under "Select Variable to Set" click a variable (I'm using a "Number" variable, if it matters)
  6. Under "Select operation" click "device attribute"
  7. Click "Select device" -> Nothing opens in the list

Seems like an issue since 2019:

I just tried it with a local variable and it worked for me. So maybe its globals only?

Yes, it's definitely related to Global Variables.

I'm not able to replicate this behavior; the device list populates for me, even replicating this as closely as possible by choosing a global variable of type "Number." I assume you're not using any JavaScript blockers, have tried a cacheless refresh (e.g., Shift+F5) of the page, and maybe a different browser just to be sure?

(I was going to say that the bug linked to in the second post looks different, but there was related discussion there about issues with spaces in variable names. That much works fine for me now, and I can't replicate the rest of the problems either way.)

I think it may be related to having a single quote in the variable name, like Test's Test. Try using that as the variable name in step 5 above. I was able to replicate it with the single quote, but it works fine with a variable without a single quote.

You also cannot delete a Global Variable created with a single quote in it. (spaces work fine)

I should also note I'm on 2.2.5.131

:open_mouth: Therefor you should instantly go to hell! :wink:

Yep, the single quote is the problem. Another 'special' character to be avoided, along with [, ] and ~.

You could filter such characters while entering the variable name... :wink:

Or escape them

Yeah, but I don't yet know why they are failing...

Would it be helpful if I add this to a bug tracker, or is this sufficient? (If a bug tracker, just point me in the right direction and I'll add the details/repro steps)

I'm replying to this old problem, mine is a little different.
I want to set a global variable from an 'action', in 'Basic rules' why can't I do this?
If anyone has a work around I'd appreciate a suggestion. I don't understand why it's not there??
Thanks!

If the option isn't there, which I was also not able to find, then it is likely that Basic Rules was seen as for those with simpler requirements than those utilising Global Variables. Happy to be proven wrong, but that would be my guess. So not likely a bug as such, just a feature that is satisfied elsewhere....

It looks like you can import a Basic Rule into Rule Machine. I would suggest looking at doing that and adding the necessary Action to set your Global / Hub Variable.

1 Like

Thank you!!
Great suggestion. I would be nice if it could be done in 'Basic Rules' cause I like the format.
I learned something new.
Thanks Again.

1 Like