Announcement

Collapse
No announcement yet.

Error with expression calculation if one value is 0

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Error with expression calculation if one value is 0

    Hi spud

    I tried to use your plugin to update one of my VD by using a basic expression to add the value of VD1 to VD2 and update VD1 with the new value.
    The expression works fine unless the dynamic value of VD1 is ever 0, in which case the expression fails and the log states:
    Code:
    ERROR SetDeviceValueToVariable: Cannot parse variable 0 + 13.839 to a numerical value
    Clearly the sum should have resulted in 13.839 but it doesn't like it.

    Anyway, I'm just using an immediate script now to do it e.g. &hs.setdevicevaluebyref(1234, (hs.devicevalueex(1234) + hs.devicevalueex(4321)), True) which works fine with 0 values.

    Thought you may like to know?

    Cheers

    #2
    Sorry for the delay, it looks like you used a "Set Device to Variable" action, this type of action cannot contain any mathematical operator, but only HS replacement variables.
    I think you want to use the "Set Device to Expression" instead. This action type is much more powerful and supersedes the "Set Device to Variable" action, which is only still there for backward compatibility.

    Comment


      #3
      Originally posted by spud View Post
      Sorry for the delay, it looks like you used a "Set Device to Variable" action, this type of action cannot contain any mathematical operator, but only HS replacement variables.
      I think you want to use the "Set Device to Expression" instead. This action type is much more powerful and supersedes the "Set Device to Variable" action, which is only still there for backward compatibility.
      Hi Spud,

      That's odd because I've been using the set device to expression option. I'll double check.

      Comment

      Working...
      X