Using OH 2.4.0-1 on Debian 9.
I have 5 dimmer items (Philips Hue) and a dimmer switch (Philips Hue).
I also have a virtual dimmer in the Items-file for controlling all the Hue-lamps and two zwave on/of lamps.
Dimmer Woonkamer_keuken "Woonk./keuken" <light>
Dimmer Licht_bank "Licht bank" <light> (Verlichting,Woonkamer, Schemer, gTest) {channel="hue:0100:0017887ff168:3:brightness"}
Dimmer Licht_bobbie "Licht bobbie" <light> (Verlichting,Woonkamer, Schemer, gTest) {channel="hue:0100:0017887ff168:1:brightness"}
Dimmer Licht_TVL "Licht TV links" <light> (Verlichting,Woonkamer, Schemer, gTest) {channel="hue:0100:0017887ff168:2:brightness"}
Dimmer Licht_TVR "Licht TV recht" <light> (Verlichting,Woonkamer, Schemer, gTest) {channel="hue:0100:0017887ff168:6:brightness"}
Dimmer Licht_vak "Licht vakjeskast" <light> (Verlichting,Woonkamer, Schemer, gTest) {channel="hue:0100:0017887ff168:5:brightness"}
//two zwave lamps:
Switch Lamp_K_Aanrecht "Lamp keuken aanrecht" <light> (Verlichting, Keuken) {channel="zwave:device:512:node6:switch_binary"}
Switch Lamp_K_koelkast "Lampjes koelkast" <light> (Verlichting, Keuken) {channel="zwave:device:512:node27:switch_binary"}
What I like to accomplish is that if I use the general dimmer âWoonkamer_keukenâ, it also switches on 2 zwave sitches for on/of-lamps. This is working through a rule.
Also I want to accomplish that I can set the dimmer value of the 5 Hue-dimmers all at once from the OH-app in steps. This is also working:
Selection item=Woonkamer_keuken mappings=[0="uit", 10="10%", 30="30%", 50="50%", 90="90%", 100="100%"]
But when I change just one of the Hue lamps to another level, this causes the âgeneralâ dimmer item âWoonkamer_leulenâ to not show itâs status because the value is not one of the presets.
I thought if using postUpdate to set the virtual dimmer âWoonkamer_keukenâ to the pre-set value that is closest to the average of the 5 real dimmer values. But two things donât work out with my rule: the postUpdate really sets the value like senCommand while I thought it would just show the new value and not switch on it.
And the second thing that doesnât work is that the switch case does not do a thing.
Any help is welcome, also if it means changing the way to do this, but I really would like to better understand the postUpdate behaviour and the switch-case-thing.
rule "DIm-gemiddelde lampen -> keuken"
when
Item Licht_bank changed or
Item Licht_bobbie changed or
Item Licht_TVL changed or
Item Licht_TVR changed or
Item Licht_vak changed
then
var Number avgLevel = (Licht_bank.state as Number + Licht_bobbie.state as Number + Licht_TVL.state as Number + Licht_TVR.state as Number +Licht_vak.state as Number) / 5
logInfo("DIm-gemiddelde lampen -> keuken", "Huidig gemiddelde: "+avgLevel) //this shows up in log alright
if (avgLevel <= 20) {
Lamp_K_Aanrecht.sendCommand(OFF)
Lamp_K_koelkast.sendCommand(OFF)
} else {
Lamp_K_Aanrecht.sendCommand(ON)
Lamp_K_koelkast.sendCommand(ON)
}
var newLevel = 0
switch avgLevel {
case (avgLevel > 0 && avgLevel < 15) : newLevel == 10
case avgLevel >= 15 && avgLevel < 25 : newLevel == 20
case avgLevel >= 25 && avgLevel < 35 : newLevel == 30
case avgLevel >= 35 && avgLevel < 55 : newLevel == 50
case avgLevel >= 55 && avgLevel < 95 : newLevel == 90
default : newLevel == 100
}
logInfo("DIm-gemiddelde lampen -> keuken", "Nieuw gemiddelde: "+newLevel) //this always show whatever I use to initiate 'newLevel'
Woonkamer_keuken.postUpdate(newLevel)
end
I also tried using the group gTest to set al dimmers using the same presets from the sitemap, but this is not working. Therefore I went back to the virtual dimmer again.