- Platform information:
- OS: Raspbian GNU/Linux 10 buster on Pi 3
- openHAB version: 2.5.12
Hey Guys! Im kind of a newbie in OpenHAB, but i was wondering if someone here could answer my “short” question.:
First off here is the code, which is written into my .rules File:
var Number DebugCounter
val String CurrentBulbVar = "NULL"
rule "Bulbs Control"
when
Item BulbCounterID changed
then
if (BulbCounterID.state == 1) { CurrentBulbVar = "Bedroom_Light.sendCommand" }
else if (BulbCounterID.state == 2) { CurrentBulbVar = "LivingRoom_Light.sendCommand" }
else if (BulbCounterID.state == 3) { CurrentBulbVar = "HueAmbianceLamp1Brightness.sendCommand" }
else if (BulbCounterID.state == 4) { CurrentBulbVar = "HueAmbianceLamp2Brightness.sendCommand" }
else if (BulbCounterID.state == 5) { CurrentBulbVar = "HueAmbianceLamp3Brightness.sendCommand" }
logWarn("DebugCurrentBulb", "Current Bulb Var has changed to " + CurrentBulbVar)
end
rule "Control Bulbs"
when
Item BulbConfirmerID changed
then
if (BulbConfirmerID.state == ON) { CurrentBulbVar (ON) }
else if (BulbConfirmerID.state == OFF) { CurrentBulbVar (OFF) }
end
here are the .items files:
(Virtual Items)
Group BulbStatusGrp "BulbStatusGrp"
Number BulbCounterID "BulbCounter" (BulnStatusGrp)
Switch BulbConfirmerID "BulbConfirmer" (BulnStatusGrp)
Switch DummySwitchID "DummySwitch" (BulbStatusGrp)
Switch DummySwitch2ID "DummySwitch2" (BulbStatusGrp)
(Tradfri Hardware)
Group Home "Home" <house>
Group Bedroom "Schlafzimmer" <bedroom> (Home)
Group LivingRoom "Wohnzimmer" <sofa> (Home)
Switch Bedroom_Light "Licht" <light> (Bedroom, gLight) {channel="tradfri:0220:gw4491603032fb:65537:brightness"}
Dimmer Bedroom_Light_Brightness "Schlafzimmer Helligkeit" <light> (Bedroom, gLight) {channel="tradfri:0220:gw4491603032fb:65537:brightness"}
Dimmer Bedroom_Light_ColorTemp "Schlafzimmer Farb Temp" <sun> (Bedroom, gLight) {channel="tradfri:0220:gw4491603032fb:65537:color_temperature"}
Number Bedroom_RemoteCtrl_BatteryStatus "Batterie Status" <battery> (Bedroom) {channel="tradfri:0830:gw4491603032fb:65539:battery_level"}
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
Switch LivingRoom_Light "Licht" <light> (LivingRoom, gLight) {channel="tradfri:0220:gw4491603032fb:65541:brightness"}
Dimmer LivingRoom_Light_Brightness "Wohnzimmer Helligkeit" <light> (LivingRoom, gLight) {channel="tradfri:0220:gw4491603032fb:65541:brightness"}
Dimmer LivingRoom_Light_ColorTemp "Wohnzimmer Farb Temp" <sun> (LivingRoom, gLight) {channel="tradfri:0220:gw4491603032fb:65541:color_temperature"}
/*Dummy Switch for rules*/
Switch AlleLichter "Alle Lichter"
So what Im trying to achieve is the switching between 5 different bulbs, therefore I have made the Virtual Items, “BulbCounterID” for example is used to define which Bulb should be controlled, at the moment I have set up the Switches in Basic UI:
I can switch between the Bulbs with the two arrows (up and down). You can ignore the “Dim Up” and “Dim Down” switches for now. My Problem is, that I would like to enable the currently selected Bulb with the “Bulb Confirmer” Switch. More precise: I want to know why the command:
if (BulbConfirmerID.state == ON) { CurrentBulbVar (ON) }
doesn’t work. Everything works if I just put the Item ID and .sendCommand instead of “CurrentBulbVar”, but if I do that I lose the ability to switch between the bulbs and control them, does anyone have an Idea?