Current state of mesh devices

I have a virtual color bulb on "hub 2" that has been exported into "hub 1" via Hub Mesh.
My application executes some code after testing the current level and color temperature of the bulb.

It is standard code in the following form:
> if (colorbulb.currentLevel != level || currentbulb.currentColorTemperature != temperature)
> {code block}
Strangely, the level and temperature checks always return false, even though the color bulb device status page shows respective matching values. When I print the level and temperature from code they show square brackets around the values:
> Color bulb current level: [100]
> Color bulb current temperature: [5000]
Interestingly, the same code executed on a color bulb that is local to "hub 1" works as expected.

My guess is that there is a data type mismatch between your level and temperature variables compared to whatever the Hub Mesh device is reporting. The fact that there are brackets around the value when you print it (presumably just log.debug colorbulb.currentLevel or something similar?) suggests it might be a List. I do not use Hub Mesh so can't easily test this, and in the Hubitat sandbox, some attempts at finding the data type directly won't work, but you can call a non-existent method with the value, and the error in the log will tell you.

So something like:


should give you an error you can use to tell. I'm not sure why that's happening, and it seems like it shouldn't be, but that will at least let you see for sure...

You are right! It was a bug in my code...Your reply came as I was typing this up :blush:...
Previously I had an array of bulbs defined in my app preferences:
input "colorbulb", "capability.colorControl", title: "Color Bulb", required: true, multiple: true

I switched this to a single bulb and forgot to delete "multiple: true", resulting in an ArrayList of bulbs ...
Thank you for the reply!

Ah, yeah, didn't think of multiple: true, but that would do it, too! Glad you got it figured out.

Download the Hubitat app