Hello everybody,
I just want to change the brightness of an tradfri-bulb. But there ist no available channel, so I want to use a item-value of a slider to adjust the brightness.
My problem is, that I dont know how to convert this number-value to a PercentType that can be used for the HSBType.
Items:
Number Tradfri_Leuchte_Dimmen (RRD4J_TEMP) //(Dummy-Item für einen Slider in der sitemap)
Color Tradfri_Leuchte_Farbe { channel=“tradfri:0210:gwa0c9a0d7b653:Tradfri_Flur_Alarm:color” } //Tradfri-Binding
rule (–> error-line ERROR!! Works if its comment out. Brightness is set to 100 - corresponding to the declaration ):
rule "Helligkeit steuern"
when
Item Tradfri_Leuchte_Dimmen received update
then
logInfo("Leuchte", " Helligkeit wird berechnet.")
//Variablen anlegen
var DecimalType hue = new DecimalType(240) // 0-360;
var PercentType sat = new PercentType(100) // 0-100
var PercentType bright = new PercentType(100) // 0-100
hue=(Tradfri_Leuchte_Farbe.state as HSBType).hue
sat=(Tradfri_Leuchte_Farbe.state as HSBType).saturation
--> bright = (Tradfri_Leuchte_Dimmen.state as Number) //ERROR!! Works if its comment out. Brightness is set to 100 - corresponding to the declaration
Tradfri_Leuchte_Farbe.sendCommand(new HSBType(hue, sat, bright))
end
Thanks a lot for your help!