[SOLVED] Convert HEX to INT to String in Rules

Hi,
Trying to setup a switch case on some json data. The data that comes back is actually an integer in DEC, but comes as a string surrounded in “”.
I want to specify a HEX number in the rule (for good readability as the manual references in HEX too).
Annnnd I’m stuck!

This is what I have so far…

    switch (_messageType) {
        case "112" : { }  //this works as the number is in DEC format
        case (Integer::parseInt("0x70", 16)).toString : // Ive tried a few variations in here with no success
        {
            logInfo("security.rules", "YEY!")
        }
    }

Any ideas anyone?

I posted too soon (as usual)

Here is the solution:
Convert the switch string into an integer, then all I need to deal with is hex to dec in the case.
In my instance above the “0x” was stopping it from working (I found this in some javascript documents). It must not work in OH.

        switch (Integer::parseInt(_messageType)) {
            case "112" : { }
            case "161" : { }
            case "22" : { }
            case "25" : { }
            case "21" : { }
            case "24" : { }
            case "18" : { }
            case "19" : { }
            case "9" : { }
            case "169" : { }
            case "168" : { }
            case "167" : { }
            case Integer::parseInt("1B", 16) :
            {
                logInfo("security.rules", "YEY")
            }
            case "113" : { }
            case "130" : { }
            case "33" : { }
        }

umm

case 27 :    // hex 1B

Yes I know that!! :joy:

See my first post…

Yes, for readability a comment would be ideal I thought, rather than unnecessary processing. Perhaps you didn’t mean human readable.

Yes I suppose that would be okay, but I had a list of about 20, would have meant I need to work them all out. I understand it’s not very efficient either haha.
My OH is on a decent PC so have a lot to play with.