Hi, newbie here. Sorry if I’ve re-invented the wheel, but I tried to build a control for white lamps with color temperature, therefore two sliders, another feature is “dynamic icons” and if the lamp is unavailable a status message from the Thing behind the Item. Built with current OpenHAB 2.2.
First the groundwork:
There are two or three items for each bulb, the Dimmer for the Brightness channel, a String for Online state (without channel, filled with the Thing state via the rule) and if the bulb supports it the Dimmer for the Color Temperature channel.
Dimmer Flur_Decke_Lampe "Flurlampe" <light> (gLampen) ["Lighting"] {channel="hue:0100:1:1:brightness"}
String Flur_Decke_Lampe_Online <light> (gLampenOnline)
Dimmer Wohnzimmer_Esstisch_Lampe "Esstischlampe" <light> (gLampen) ["Lighting"] {channel="hue:0220:1:4:brightness"}
Dimmer Wohnzimmer_Esstisch_Lampe_Coltemp "Esstischlampe Farbtemp" <light> {channel="hue:0220:1:4:color_temperature"}
String Wohnzimmer_Esstisch_Lampe_Online <light> (gLampenOnline)
There is a rule for each bulb (only one shown here)
rule "Lampe4"
when
System started or
Thing "hue:0220:1:4" changed
then
var si = getThingStatusInfo("hue:0220:1:4");
logInfo("Rule Lampe4", "Status: " + si);
Wohnzimmer_Esstisch_Lampe_Online.sendCommand(if (si !== null) si.toString() else "NULL");
End
Now for the template. It has three settings: config.item_brightness is obviously ties the Item for brightness, config.item_online to the online-Item and config.item_colortemp to the Item for Color temperature (or if not available and as the dialog not allows NULL input, the brightness-Item). The icons are hardcoded, feel free to change them or make them configurable. As I have no Angular experience, the layout is a what I was able to achieve, tweaking this was tedious for me…
Noteworthy: To use the icon-widget, the iconset and icon (and state if hardcoded) have to be “double-quoted”. The name (head text) is retrieved from the Item label. The Color temperature would be from 200K – 6500K, I found no way to set this value as limit and pointer text for the openhab supplied slider widget. The translate-function would have to be overridable from the outside I suppose.
<div>
<div ng-if="getItem(config.item_online).state.toString() != 'ONLINE'" class="box-content">
<widget-icon iconset="'freepik-household'" icon="'lamp-4'" class="icon icon-tile-backdrop" backdrop="true" center="true"></widget-icon>
<widget-icon style="position: absolute; top: 10px; left: 10px;" iconset="'eclipse-smarthome-classic'" icon="'light'" class="icon" state="'OFF'"></widget-icon>
<div class="slider-label box-content">{{getItem(config.item_brightness).label}}
<div class="dummy-content">
<span class="value">{{getItem(config.item_online).state}}</span>
</div>
</div>
</div>
<div ng-if="getItem(config.item_online).state.toString() == 'ONLINE'" class="box-content">
<widget-icon style="position: absolute; top: 10px; left: 10px;" iconset="'eclipse-smarthome-classic'" icon="'light'" class="icon" state="getItem(config.item_brightness).state"></widget-icon>
<div ng-init="slider1 = {
'name': getItem(config.item_brightness).label,
'item': config.item_brightness,
'floor': 0,
'ceil': 100,
'step': 1,
'precision': 1,
'unit': '%',
'hidelabel': false,
'hidelimits': true,
'hidepointer': false,
'backdrop_icon': 'lamp-4',
'backdrop_iconset': 'freepik-household',
}">
<widget-slider ng-model="slider1"/>
</div>
<div ng-if="config.item_colortemp && config.item_colortemp != config.item_brightness">
<div ng-init="slider2 = {
'item': config.item_colortemp,
'floor': 0,
'ceil': 100,
'step': 1,
'precision': 1,
'unit': 'K',
'hidelabel': true,
'hidelimits': true,
'hidepointer': true,
}">
<widget-slider ng-model="slider2"/>
</div>
</div>
</div>
</div>
Hope this is useful for some of you!