Strange evt.value after upgrade to 2.3.8.117

Yesterday I upgraded one of my c-7 hubs to the latest software version 2.3.8.117
Since the upgrade I am getting a strange evt.value in a subscription to “motion” event.

Basically I have a switch which looks at the evt.value from a subscription to motion sensors “motion” attribute.
The only possible results should be
“active”
Or
“inactive”
My switch case caters for both of these possible values and has been working 100% for years now.

Since upgrading to the latest software I am now getting an evt.value of:
“[97, 99, 116, 105, 118, 101]”

Obviously I have changed the switch code so it ignores this because the errors were stacking up fairly quick, but I was wondering if anyone else is getting similar errors or knows the reason for this peculiar value under a motion subscription.

All the motion sensors in question are ‘Philips Hue’ sensors using the built in ‘Hue Motion Sensor’ Driver.

Thanks in advance for any help. :+1:t3:

you're getting the character array for active, i.e. 97 = a, 99 = c, 116 = t, 105 = i 118 = v, 101 = e

6 Likes

I do apologise. Where were my manners!

Thank you for pointing that out.

Do you happen to know if this intentional because of the Java update?

Would there be a reason why I only get active in the char array and never inactive?

Not sure it's intentional, but could definitely be a side effect.

1 Like

So I’ve just updated my main hub and I’m also getting char arrays for most of my switch cases.

Is this going to be a permanent thing now or will this be fixed in a future update.? Tagging some staff for their views on the matter. :+1:t3: @mike.maxwell @bravenel @gopher.ny

Show the Events from the device page.

Here's an example from one of my devices:

This is how it should normally look, and these event values are correct and apps are responding to them correctly.

I think you misunderstood what I mean.

The device events page shows the correct information.
It’s the evt.value that is received by a subscription to an event that is receiving the character array representing the value.

def motionStatusChanged(evt) {
switch(“$evt.value”) {
case “active” :
//DO SOMETHING
break
case “inactive” :
// DO SOMETHING
break
default:
log.error “Motion value not valid. Value was: $evt.value”
break
return
}
}

Then I receive an error of: Motion value not valid. Value was: “[97, 99, 116, 105, 118, 101]"

This happens with all my switch cases now regardless of what the values could be I seem to sometimes get a value of “active” / “inactive” yet other times I get “[97, 99, 116, 105, 118, 101”] / “[105, 110, 97, 99, 116, 105, 118, 101”] etc.

This means I now have to include the char array value in the case statement so it can still perform as usual.

def motionStatusChanged(evt) {
switch(“$evt.value”) {
case “active” :
case “[97, 99, 116, 105, 118, 101]" :
//DO SOMETHING
break
case “inactive” :
case “[105, 110, 97, 99, 116, 105, 118, 101”] :
// DO SOMETHING
break
default:
log.error “Motion value not valid. Value was: $evt.value”
break
return
}
}

Docs say event object's value attribute type is String, so you can probably go with switch (evt.value)

Not sure why the variable interpolation fails that way though... not a Groovy wonk.

What driver is this?

Can you post the result of adding this as the first line in your motionStatusChanged method:
log.debug(evt.value)

Sure. Here’s a screen grab.

It’s not a driver.
It’s an app I wrote to manage my house.
Never had an issue with the switch code until the latest update.
Seems like sometimes it’s sending a string value
Other times it’s sending a string array of ascii characters.

Where are the motion.active events coming from?

A subscription to hue motion sensors. ‘motion’ event Using the built in hue motion sensor driver.

It’s not just motion.
I also get the same result randomly from any switch event.
I have one for doors opening and closing.
One for presence present and not present.

I would suggest that instead of

switch(“$evt.value”) {

you do

switch(evt.value) {

Or, force the issue with this:

switch(evt.value as String) {

I don't know what's going on with your app, but if this were a platform problem / change, we'd be seeing it all over, but we're not. On the other hand, I'm not aware of any code in apps that uses switch() on an event value.

evt.value is a String.

1 Like

This is the subscription code.

if (entryMotionSensors) subscribe(entryMotionSensors, "motion", entryMotionEventHandler)

Nothing untoward…

This is the first 2 lines of the entryMotionEventHandler

def entryMotionEventHandler(evt) {
log.debug(evt.value)

That randomly gives this in the logs.

I’ll change the switch to evt.value but I can’t see it making a difference seeing as the logs are referencing evt.value and still output a random array of numbers sometimes

Where is the log.warn coming from? All of the log.debug show the string.

Why even use a switch() ?

if(evt.value == "active") xxx
else yyy

There is no chance of any other value for motion, by definition.