The following will dim a z-wave light bulb by 5% (note: Study_Light.state returns a string from “0” to “100”). Nice an easy as there is one value to change for dimming on this bulb.
Study_Light.sendCommand((Study_Light.state as Number) -5 )
I’m struggling however to do the same with a Lifx Light bulb as Test_Light_Colour.state returns a string from “0.0,0,0” to "0.0,0,100) where it is just the 3rd variable I need to change (also, note the first variable has a decimal place). I’ve been faffing around for a couple of hours and just can’t nail the syntax. The following is the best I’ve got so far…any suggestions would be great!
var HSB = Test_Light_Colour.state.toString.split(",")
Test_Light_Colour.sendCommand(HSB.get(0),HSB.get(1),((HSB.get(2) as Number) -5 ))
You know that’s a string, you made it into one.
There is more to converting from string to number than “as”, you need to parse e.g. use a function like parseInt()
Can’t help feeling string manipulation is the wrong approach here
@5iver Thanks Scott, The logic works. Just polishing an example to post on using a fibaro button to control various lights like the hardwired fibaro dimmer (eg Press for On/Off, Long Hold Dim, etc). Good Man!
Thanks again,
Nathan