Hi,
i use the following dimmer rule.
If I dim the lamp for example with the Basic UI and then with the wall switch, the lamp jumps in the dim value (visible). Basically the rule works great, except for this one point.
Also longer searches here in the forum and at google brought unfortunately no success, perhaps I used only the wrong terms.
I guess it’s really no big deal.
I would like to use a global dimming value in my rule, but I am not sure how this works. My idea is simply to use the current dimming value of the item as val/var (item.stat), but unfortunately I have not yet managed to implement this.
I’ve tried various things… for example:
val dimVal = WzDlD.state as Number
But I received the following error
Cannot reference the field 'WzDlD' before it is defined
I have unfortunately never been able to correct this “small” error.
I hope for your creative ideas.
Thanks for your help!
- Platform information:
- Hardware: RPI4 4GB
- OS: latest Raspberry Pi OS 32bit
- Java Runtime Environment: Zulu Embedded 8.25.0.76-linux-aarch32hf
- openHAB version: 2.5.6
DIM RULE
val int timeoutMills = 100
var int dimLevel = 50
var Timer timerWzDlD = null
rule IKEA_Remote_WzDlD
when
Channel "deconz:switch:deconzCore:wohnzimmer-decke:buttonevent" triggered
then
switch(receivedEvent.getEvent())
{
case "1002": // ON
{
WzDlD.sendCommand(50)
}
case "2002": // OFF
{
WzDlD.sendCommand(0)
}
case "1001": // dim brighter
if (timerWzDlD === null) {
timerWzDlD = createTimer(now.plusSeconds(0), [ |
WzDlD.sendCommand(dimLevel)
if (dimLevel > 99) dimLevel = 99
if (dimLevel == 99) {
timerWzDlD = null
} else {
dimLevel = dimLevel + 1
timerWzDlD.reschedule(now.plusMillis(timeoutMills))
}
])
}
case "1003": // dim stop
{
timerWzDlD?.cancel
timerWzDlD = null
}
case "2001": // dim darker
if (timerWzDlD === null) {
timerWzDlD = createTimer(now.plusSeconds(0), [ |
WzDlD.sendCommand(dimLevel)
if (dimLevel < 1) dimLevel = 1
if (dimLevel == 1) {
timerWzDlD = null
} else {
dimLevel = dimLevel - 1
timerWzDlD.reschedule(now.plusMillis(timeoutMills))
}
])
}
case "2003": // dim stop
{
timerWzDlD?.cancel
timerWzDlD = null
}
}
end
ITEM
Group:Dimmer WzDlD "Wohnzimmer Deckenleuchte [%d]" <light> (WZ, gLight)
Dimmer Wohnzimmer_Deckenlampe1 "Wohnzimmer Deckenlampe 1 [%d]" <light> (WZ, gLight, WzDlD) {channel="deconz:dimmablelight:deconzCore:wohnzimmer-decke1:brightness"}
Dimmer Wohnzimmer_Deckenlampe2 "Wohnzimmer Deckenlampe 1 [%d]" <light> (WZ, gLight, WzDlD) {channel="deconz:dimmablelight:deconzCore:wohnzimmer-decke2:brightness"}
Dimmer Wohnzimmer_Deckenlampe3 "Wohnzimmer Deckenlampe 1 [%d]" <light> (WZ, gLight, WzDlD) {channel="deconz:dimmablelight:deconzCore:wohnzimmer-decke3:brightness"}