One line of code is giving me trouble. I've a driver that was written some years ago, that causes a bug in HE to show - groups do not handle values for HSL that have decimal places and needs integers. The original developer has been very sick and I don't want to bother him, so I've taken it upon myself to make a personal, customized version of his driver (which works very well I might add!)
The original line:
sendEvent(name: "hue", value: settings.enableHueInDegrees ? parameters.hue/3.6 : parameters.hue)
My code:
sendEvent(name: "hue", value: settings.enableHueInDegrees ? (parameters.hue/3.6).intValue() : parameters.hue.intValue())
I don't understand what the Question mark does or the Colon so I'm just stuffing .intValue() on all the sendEvents which is working but I hiccup in this one spot. Thanks.
The x ? y : z thing is an example of the "tenary operator," which I'm sure you'd find in the link above. Just a shorter way of something like:
if (x)
y
else
z
For your actual problem, it's not clear to me why what you have would fail, at least from a techincal persepective. What, exactly, "hiccups," and are there any errors (in logs)? However, from a practical perspective, I'd probably use Math.round(x) instead of x.intValue() so that you get the nearest integer rather than just truncating everything fractional.