They are not technically the same. Ive had the exact issue…you need to use a string comparison. So try:
event.device.equals(motionKMS)
And it should work.
Source: the internet:
To compare Strings for equality, don’t use ==. The == operator checks to see if two objects are exactly the same object. In Java there are many string comparisons:
String s = “something”, t = “maybe something else”;
if (s == t) // Legal, but usually WRONG.
if (s.equals(t)) // RIGHT
if (s > t) // ILLEGAL
if (s.compareTo(t) > 0) // also CORRECT>
although since you can name a device anything (including an existing name) you should be comparing the device ID or network ID (both should be unique):
I believe that all of the above will be faster than the suggested use of equals() because they directly compare two strings without need to convert the entire device objects into strings.
Oh yeah…I didn’t even realize it was the device “object” when I wrote my reply. I’m so used to comparing actual literal strings in my devices (blahblah.equals(“Yes”)) that I didn’t notice. I mean it should work but probably isn’t the best way.