Hej there,
I am trying to convert a working DSL rule into JS (ECMAScript 2022+). The DSL rule works fine and look quite “elegant” meaning it uses built-in functions like “.getBrightness()”.
I managed to get the brightness value from my lamp, but it seems a little bit too complicated to me and I cannot find something like “.getBrighness()” for JS.
Assume the Color value in HSB coming from the item: 24.5,50.8,100. I need the “100”
Example DSL:
var lamp = WiZ_Lamp_Color
var lampColorState = lamp.state as HSBType
var brightness = lampColorState.getBrightness()
My version in JS:
var lamp = WiZ_Lamp_Color
var lampColorState = lamp.state
var brightness = lampColorState.toString().split(',')[2]
The conversion to string plus the splitting etc seems not quite elegant.
How could I use something like .getBrightness()? Is there something like this? Where can I find docs about those things?
So far I read the getting started but I am not quite secure in how to do a rule. Looking in the forum sometime does not help me here as DSL and JS look quite the same from my level of experience (so far)…