Attribute - Bug in documentation or platform or implementation

( - Make your home your butler!) #1

@jody.albritton and @Jim - request your inputs here please.

According to the documentation

Attribute can be string, number or enum. So define a type number according to the documentation one must use

attribute “myCustomAttribute”, “number”

So in the DH I use this to defined a customer attribute:

attribute “someEvent”, “number”

And I assigned a value using:

sendEvent(name: “someEvent”, value: now(), descriptionText: “$device.displayName event”, displayed: true, isStateChange: true)

However in the SmartApp when subscribing to someEvent I try to do this operation

new Date(evt.value)

it throws an exception and the reason I figured out was that the “in” operator shows evt.value is to type “String” and NOT “long” or “int” (i.e. not a number)

So is the documentation incorrect or am I using this incorrectly or is it a bug in the platform implementation?

( I hate Mondays) #2

evt.value is not the same as device.currentValue(attribute). In other words, you are not reading the attribute value, you are reading an event value.

Look at evt and it should also have a .longValue property… Look up the documentation for Event