Anyone willingt o help me with this one?
Goal
- To create a master rule file with lambdas to reduce code repetition and make changes to functionality on a global level.
- Re-write Color Temperature by Sun elevation in Rules DSL, and add smoothing to the offset created by coarse cloudiness data.
- Re-write dimming function to be a “press and hold” type experience.
What I’ve got so far:
a rule file with about 800 lines of code that control the functionality of multiple dimmers and switches of various brands (Hue, Aqora etc) that control various types of lights (CCT, On/Off etc).
Lambdas
I have used lambdas for the dimming and on/off functions, but I would like to use a few variables at the start of each rule to autofill a lot of the code required to trigger the lambas in the first place. I think this alone could reduce the length of code by a few hundred lines of code.
But when I try to create a variable, the lambda does not accept the STRING as an GenericItemType. Can anyone explain how to do this?
Is it poissible to run a lambda within a lambda? And if so, can it pass through the items it took in? It’s not working as I’d expect.
Color Temperature by Sun elevation
The reason I am using such a convoluted ON command in genericCctLight_On
, is because I have another rule I run that sets a global color temperature based on Sun elevation to a Calculated_ColorTemperature
item, and then send this value to any light that is ON. I love this rule, but I’m sure it could be prettier than this, and rewritten in DSL.
You might also notice that I’ve not included the Cloud_Factor
in my final output as I was experiencing massive steps because the local weather data was very coarse data. I want to make it only take a maximum step of about 100K each time the rule is run.
Maybe someone can help with this?
**javascript
var SunElevation = itemRegistry.getItem("AstroSunData_Elevation").getState();
var Clouds = itemRegistry
.getItem("Localweatherandforecast_Cloudiness")
.getState();
var outputstart = 2200; //min color temp
var outputend = 5600; //max color temp
var inputstart = 0; //min sun elevation
var inputend = 40; //max sun elevation
var output =
outputstart +
((outputend - outputstart) / (inputend - inputstart)) *
(SunElevation - inputstart);
var CloudFactor = output * Clouds * 0.003;
var newColourValue = Math.min(Math.max(output, 2200), 5600)
events.sendCommand('Calculated_ColorTemperature', newColourValue);
var lightLevelGroup = itemRegistry.getItem("gAll_Lights_Brightness");
lightLevelGroup.members.forEach(function (item) {
if (item.getState() > 0) {
var thingName = item.getName().match(/^(.*)_.*/)[1];
events.sendCommand(
thingName + "_ColorTemperature",
newColourValue
);
}
});
Dimming
I am currently using a predefined series of steps between brightness values for Dim Up and Dim Down. I would like to replace this with a press and hold function. I’m sure this can be done with loops and timers etc, but I can’t figure it out.
Current code
Anyway, without further ado, here is my code in full. I still have another 3 or 4 switches to add to this, so you can see the need for streamlining…
//Lambdas for reusable light functions.
val switch_On = [
GenericItem brightness
|
if (brightness.state != ON) {brightness.sendCommand(ON)}
logInfo("Lights", getLocation(brightness) + " " + getEquipment(brightness) + " turned ON")
]
val cct_On = [
GenericItem brightness,
GenericItem scene_brightness,
GenericItem color_temp
|
if (brightness.state == 0) {
color_temp.sendCommand(Calculated_ColorTemperature.state.toString)
if (brightness.state != scene_brightness.state) {
brightness.sendCommand(scene_brightness.state.toString)
}
logInfo("Lights", getLocation(brightness).label + " " + getEquipment(brightness).label + " set to " + scene_brightness.state)
} else if (brightness.state != 100) {
brightness.sendCommand(100)
logInfo("Lights", getLocation(brightness).label + " " + getEquipment(brightness).label + " set to 100")
}
]
val light_Off = [
GenericItem brightness
|
if (brightness.state != OFF) { brightness.sendCommand(OFF) }
logInfo("Lights", getLocation(brightness).label + " " + getEquipment(brightness).label + " turned OFF")
]
val light_dimUp = [
GenericItem brightness
|
if (brightness.state >= 75 && brightness.state < 100) {brightness.sendCommand(100)}
else if (brightness.state >= 50 && brightness.state < 75) {brightness.sendCommand(75)}
else if (brightness.state >= 25 && brightness.state < 50) {brightness.sendCommand(50)}
else if (brightness.state >= 10 && brightness.state < 25) {brightness.sendCommand(25)}
else if (brightness.state >= 5 && brightness.state < 10) {brightness.sendCommand(10)}
else if (brightness.state >= 0 && brightness.state < 5) {brightness.sendCommand(5)}
logInfo("Lights", getLocation(brightness).label + " " + getEquipment(brightness).label + " dimmed UP")
]
val light_dimDown = [
GenericItem brightness
|
if (brightness.state > 75 && brightness.state <= 100) {brightness.sendCommand(75)}
else if (brightness.state > 50 && brightness.state <= 75) {brightness.sendCommand(50)}
else if (brightness.state > 25 && brightness.state <= 50) {brightness.sendCommand(25)}
else if (brightness.state > 10 && brightness.state <= 25) {brightness.sendCommand(10)}
else if (brightness.state > 5 && brightness.state <= 10) {brightness.sendCommand(5)}
else if (brightness.state > 1 && brightness.state <= 5) {brightness.sendCommand(1)}
else if (brightness.state > 0 && brightness.state <= 1) {brightness.sendCommand(0)}
logInfo("Lights", getLocation(brightness).label + " " + getEquipment(brightness).label + " dimmed DOWN")
]
val light_min = [
GenericItem brightness
|
brightness.sendCommand(1)
logInfo("Lights", getLocation(brightness).label + " " + getEquipment(brightness).label + " set to Minimum")
]
rule "Wall Switch - Back Room, Hue Dimmer 1"
when
Item BackRoom_WallSwitch_Button changed
then
if (newState == 1000) { // 1000=On INITIAL PRESS
} else if (newState == 1001) { // 1001=On LONG PRESS
} else if (newState == 1002) { // 1002=On
cct_On.apply(
BackRoom_Ceiling_Light_Brightness,
BackRoom_Ceiling_Light_SceneBrightness,
BackRoom_Ceiling_Light_ColorTemperature
)
} else if (newState == 1003) { // 1003=On LONG RELEASE
} else if (newState == 2000) { // 2000=Dim Up INITIAL PRESS
} else if (newState == 2001) { // 2001=Dim Up LONG PRESS
} else if (newState == 2002) { // 2002=Dim Up
light_dimUp.apply(BackRoom_Ceiling_Light_Brightness)
} else if (newState == 2003) { // 2003=Dim Up LONG RELEASE
} else if (newState == 3000) { // 3000=Dim Down INITIAL PRESS
} else if (newState == 3001) { // 3001=Dim Down LONG PRESS
light_min.apply(BackRoom_Ceiling_Light_Brightness)
} else if (newState == 3002) { // 3002=Dim Down
light_dimDown.apply(BackRoom_Ceiling_Light_Brightness)
} else if (newState == 3003) { // 3003=Dim Down LONG RELEASE
} else if (newState == 4000) { // 4000=Off INITIAL PRESS
} else if (newState == 4001) { // 4001=Off LONG PRESS
} else if (newState == 4002) { // 4002=Off
light_Off.apply(BackRoom_Ceiling_Light_Brightness)
} else if (newState == 4003) { // 4003=Off LONG RELEASE
}
end
rule "Wall Switch - Kitchen Sink (Hue Dimmer 2)"
when
Item Kitchen_Door_Left_WallSwitch_Button changed
then
if (newState == 1000) { // 1000=On INITIAL PRESS
} else if (newState == 1001) { // 1001=On LONG PRESS
} else if (newState == 1002) { // 1002=On
cct_On.apply(
Kitchen_Sink_Ceiling_Light_Brightness,
Kitchen_Sink_Ceiling_Light_SceneBrightness,
Kitchen_Sink_Ceiling_Light_ColorTemperature
)
} else if (newState == 1003) { // 1003=On LONG RELEASE
} else if (newState == 2000) { // 2000=Dim Up INITIAL PRESS
} else if (newState == 2001) { // 2001=Dim Up LONG PRESS
} else if (newState == 2002) { // 2002=Dim Up
light_dimUp.apply(Kitchen_Sink_Ceiling_Light_Brightness)
} else if (newState == 2003) { // 2003=Dim Up LONG RELEASE
} else if (newState == 3000) { // 3000=Dim Down INITIAL PRESS
} else if (newState == 3001) { // 3001=Dim Down LONG PRESS
light_min.apply(Kitchen_Sink_Ceiling_Light_Brightness)
} else if (newState == 3002) { // 3002=Dim Down
light_dimDown.apply(Kitchen_Sink_Ceiling_Light_Brightness)
} else if (newState == 3003) { // 3003=Dim Down LONG RELEASE
} else if (newState == 4000) { // 4000=Off INITIAL PRESS
} else if (newState == 4001) { // 4001=Off LONG PRESS
} else if (newState == 4002) { // 4002=Off
light_Off.apply(Kitchen_Sink_Ceiling_Light_Brightness)
} else if (newState == 4003) { // 4003=Off LONG RELEASE
}
end
rule "Wall Switch - Kitchen Endboard (Hue Dimmer 1)"
when
Item Kitchen_Door_Right_WallSwitch_Button changed
then
if (newState == 1000) { // 1000=On INITIAL PRESS
} else if (newState == 1001) { // 1001=On LONG PRESS
} else if (newState == 1002) { // 1002=On
cct_On.apply(
Kitchen_Endboard_Ceiling_Light_Brightness,
Kitchen_Endboard_Ceiling_Light_SceneBrightness,
Kitchen_Endboard_Ceiling_Light_ColorTemperature
)
} else if (newState == 1003) { // 1003=On LONG RELEASE
} else if (newState == 2000) { // 2000=Dim Up INITIAL PRESS
} else if (newState == 2001) { // 2001=Dim Up LONG PRESS
} else if (newState == 2002) { // 2002=Dim Up
light_dimUp.apply(Kitchen_Endboard_Ceiling_Light_Brightness)
} else if (newState == 2003) { // 2003=Dim Up LONG RELEASE
} else if (newState == 3000) { // 3000=Dim Down INITIAL PRESS
} else if (newState == 3001) { // 3001=Dim Down LONG PRESS
light_min.apply(Kitchen_Endboard_Ceiling_Light_Brightness)
} else if (newState == 3002) { // 3002=Dim Down
light_dimDown.apply(Kitchen_Endboard_Ceiling_Light_Brightness)
} else if (newState == 3003) { // 3003=Dim Down LONG RELEASE
} else if (newState == 4000) { // 4000=Off INITIAL PRESS
} else if (newState == 4001) { // 4001=Off LONG PRESS
} else if (newState == 4002) { // 4002=Off
light_Off.apply(Kitchen_Endboard_Ceiling_Light_Brightness)
} else if (newState == 4003) { // 4003=Off LONG RELEASE
}
end
rule "Wall Switch - Back Hall (Aqora 2 Gang)"
when
Item BackHall_WallSwitch_Button received update
then
if (newState == 1001) { // 1001=R Up LONG
cct_On.apply(
BackHall_Ceiling_Light_Brightness,
BackHall_Ceiling_Light_SceneBrightness,
BackHall_Ceiling_Light_ColorTemperature
)
} else if (newState == 1002) { // 1002=R Up 1
if (BackHall_Ceiling_Light_Brightness.state == 0) {
cct_On.apply(
BackHall_Ceiling_Light_Brightness,
BackHall_Ceiling_Light_SceneBrightness,
BackHall_Ceiling_Light_ColorTemperature
)
} else {
light_dimUp.apply(BackHall_Ceiling_Light_Brightness)
}
} else if (newState == 1003) { // 1003=R Up LONG RELEASE
} else if (newState == 1004) { // 1004=R Up 2
cct_On.apply(
BackHall_Ceiling_Light_Brightness,
BackHall_Ceiling_Light_SceneBrightness,
BackHall_Ceiling_Light_ColorTemperature
)
} else if (newState == 1005) { // 1005=R Up 3
cct_On.apply(
BackHall_Ceiling_Light_Brightness,
BackHall_Ceiling_Light_SceneBrightness,
BackHall_Ceiling_Light_ColorTemperature
)
} else if (newState == 2001) { // 2001=R Down LONG
light_Off.apply(BackHall_Ceiling_Light_Brightness)
} else if (newState == 2002) { // 2002=R Down 1
light_dimDown.apply(BackHall_Ceiling_Light_Brightness)
} else if (newState == 2003) { // 2003=R Down LONG RELEASE
} else if (newState == 2004) { // 2004=R Down 2
light_min.apply(BackHall_Ceiling_Light_Brightness)
} else if (newState == 2005) { // 2005=R Down 3
light_min.apply(BathRoom_Ceiling_Light_Brightness)
} else if (newState == 3001) { // 3001=L Up LONG
} else if (newState == 3002) { // 3002=L Up 1
if (BathRoom_Ceiling_Light_Brightness.state == 0) {
cct_On.apply(
BathRoom_Ceiling_Light_Brightness,
BathRoom_Ceiling_Light_SceneBrightness,
BathRoom_Ceiling_Light_ColorTemperature
)
} else {
light_dimUp.apply(BathRoom_Ceiling_Light_Brightness)
}
} else if (newState == 3003) { // 3003=L Up LONG RELEASE
} else if (newState == 3004) { // 3004=L Up 2
cct_On.apply(
BathRoom_Ceiling_Light_Brightness,
BathRoom_Ceiling_Light_SceneBrightness,
BathRoom_Ceiling_Light_ColorTemperature
)
} else if (newState == 3005) { // 3005=L Up 3
cct_On.apply(
BathRoom_Ceiling_Light_Brightness,
BathRoom_Ceiling_Light_SceneBrightness,
BathRoom_Ceiling_Light_ColorTemperature
)
} else if (newState == 4001) { // 4001=L Down LONG
light_Off.apply(BathRoom_Ceiling_Light_Brightness)
} else if (newState == 4002) { // 4002=L Down 1
light_dimDown.apply(BathRoom_Ceiling_Light_Brightness)
} else if (newState == 4003) { // 4003=L Down LONG RELEASE
} else if (newState == 4004) { // 4004=L Down 2
light_min.apply(BathRoom_Ceiling_Light_Brightness)
} else if (newState == 4005) { // 4005=L Down 3
light_Off.apply(BathRoom_Ceiling_Light_Brightness)
}
end
rule "Wall Switch - Bath Room (Aqora 2 Gang)"
when
Item BathRoom_WallSwitch_Button received update
then
if (newState == 1001) { // 1001=R Up LONG
cct_On.apply(
BathRoom_Ceiling_Light_Brightness,
BathRoom_Ceiling_Light_SceneBrightness,
BathRoom_Ceiling_Light_ColorTemperature
)
} else if (newState == 1002) { // 1002=R Up 1
if (BathRoom_Ceiling_Light_Brightness.state == 0) {
cct_On.apply(
BathRoom_Ceiling_Light_Brightness,
BathRoom_Ceiling_Light_SceneBrightness,
BathRoom_Ceiling_Light_ColorTemperature
)
} else {
light_dimUp.apply(BathRoom_Ceiling_Light_Brightness)
}
} else if (newState == 1003) { // 1003=R Up LONG RELEASE
} else if (newState == 1004) { // 1004=R Up 2
cct_On.apply(
BathRoom_Ceiling_Light_Brightness,
BathRoom_Ceiling_Light_SceneBrightness,
BathRoom_Ceiling_Light_ColorTemperature
)
} else if (newState == 1005) { // 1005=R Up 3
cct_On.apply(
BathRoom_Ceiling_Light_Brightness,
BathRoom_Ceiling_Light_SceneBrightness,
BathRoom_Ceiling_Light_ColorTemperature
)
} else if (newState == 2001) { // 2001=R Down LONG
light_Off.apply(BathRoom_Ceiling_Light_Brightness)
} else if (newState == 2002) { // 2002=R Down 1
light_dimDown.apply(BathRoom_Ceiling_Light_Brightness)
} else if (newState == 2003) { // 2003=R Down LONG RELEASE
} else if (newState == 2004) { // 2004=R Down 2
light_min.apply(BathRoom_Ceiling_Light_Brightness)
} else if (newState == 2005) { // 2005=R Down 3
light_min.apply(BathRoom_Ceiling_Light_Brightness)
// Below buttons for Colour change.
} else if (newState == 3001) { // 3001=L Up LONG
} else if (newState == 3002) { // 3002=L Up 1
} else if (newState == 3003) { // 3003=L Up LONG RELEASE
} else if (newState == 3004) { // 3004=L Up 2
} else if (newState == 3005) { // 3005=L Up 3
} else if (newState == 4001) { // 4001=L Down LONG
} else if (newState == 4002) { // 4002=L Down 1
} else if (newState == 4003) { // 4003=L Down LONG RELEASE
} else if (newState == 4004) { // 4004=L Down 2
} else if (newState == 4005) { // 4005=L Down 3
}
end
rule "Wall Switch - Hall (Aqora 3 Gang)"
when
Item Hall_WallSwitch_Button received update
then
if (newState == 1001) { // 1001=R Up LONG
cct_On.apply(
Hall_FrontDoor_Light_Brightness,
Hall_FrontDoor_Light_SceneBrightness,
Hall_FrontDoor_Light_ColorTemperature
)
} else if (newState == 1002) { // 1002=R Up 1
if (Hall_FrontDoor_Light_Brightness.state == 0) {
cct_On.apply(
Hall_FrontDoor_Light_Brightness,
Hall_FrontDoor_Light_SceneBrightness,
Hall_FrontDoor_Light_ColorTemperature
)
} else {
light_dimUp.apply(Hall_FrontDoor_Light_Brightness)
}
} else if (newState == 1003) { // 1003=R Up LONG RELEASE
} else if (newState == 1004) { // 1004=R Up 2
cct_On.apply(
Hall_FrontDoor_Light_Brightness,
Hall_FrontDoor_Light_SceneBrightness,
Hall_FrontDoor_Light_ColorTemperature
)
} else if (newState == 1005) { // 1005=R Up 3
cct_On.apply(
Hall_FrontDoor_Light_Brightness,
Hall_FrontDoor_Light_SceneBrightness,
Hall_FrontDoor_Light_ColorTemperature
)
} else if (newState == 2001) { // 2001=R Down LONG
light_Off.apply(Hall_FrontDoor_Light_Brightness)
} else if (newState == 2002) { // 2002=R Down 1
light_dimDown.apply(Hall_FrontDoor_Light_Brightness)
} else if (newState == 2003) { // 2003=R Down LONG RELEASE
} else if (newState == 2004) { // 2004=R Down 2
light_min.apply(Hall_FrontDoor_Light_Brightness)
} else if (newState == 2005) { // 2005=R Down 3
light_min.apply(Hall_FrontDoor_Light_Brightness)
} else if (newState == 3001) { // 3001=M Up LONG
cct_On.apply(
Hall_FrontDoor_Light_Brightness,
Hall_FrontDoor_Light_SceneBrightness,
Hall_FrontDoor_Light_ColorTemperature
)
} else if (newState == 3002) { // 3002=M Up 1
if (Landing_Ceiling_Light_Brightness.state == 0) {
cct_On.apply(
Landing_Ceiling_Light_Brightness,
Landing_Ceiling_Light_SceneBrightness,
Landing_Ceiling_Light_ColorTemperature
)
} else {
light_dimUp.apply(Landing_Ceiling_Light_Brightness)
}
} else if (newState == 3003) { // 3003=M Up LONG RELEASE
} else if (newState == 3004) { // 3004=M Up 2
cct_On.apply(
Landing_Ceiling_Light_Brightness,
Landing_Ceiling_Light_SceneBrightness,
Landing_Ceiling_Light_ColorTemperature
)
} else if (newState == 3005) { // 3005=M Up 3
cct_On.apply(
Landing_Ceiling_Light_Brightness,
Landing_Ceiling_Light_SceneBrightness,
Landing_Ceiling_Light_ColorTemperature
)
} else if (newState == 4001) { // 4001=M Down LONG
light_Off.apply(Landing_Ceiling_Light_Brightness)
} else if (newState == 4002) { // 4002=M Down 1
light_dimDown.apply(Landing_Ceiling_Light_Brightness)
} else if (newState == 4003) { // 4003=M Down LONG RELEASE
} else if (newState == 4004) { // 4004=M Down 2
light_min.apply(Landing_Ceiling_Light_Brightness)
} else if (newState == 4005) { // 4005=M Down 3
light_Off.apply(Landing_Ceiling_Light_Brightness)
} else if (newState == 5001) { // 5001=L Up LONG
cct_On.apply(
Hall_Ceiling_Light_Brightness,
Hall_Hall_Ceiling_Light_SceneBrightness,
Hall_Hall_Ceiling_Light_ColorTemperature
)
} else if (newState == 5002) { // 5002=L Up 1
if (Hall_Hall_Ceiling_Light_Brightness.state == 0) {
cct_On.apply(
Hall_Ceiling_Light_Brightness,
Hall_Hall_Ceiling_Light_SceneBrightness,
Hall_Hall_Ceiling_Light_ColorTemperature
)
} else {
light_dimUp.apply(Hall_Hall_Ceiling_Light_Brightness)
}
} else if (newState == 5003) { // 5003=L Up LONG RELEASE
} else if (newState == 5004) { // 5004=L Up 2
cct_On.apply(
Hall_Ceiling_Light_Brightness,
Hall_Ceiling_Light_SceneBrightness,
Hall_Ceiling_Light_ColorTemperature
)
} else if (newState == 5005) { // 5005=L Up 3
cct_On.apply(
Hall_Ceiling_Light_Brightness,
Hall_Ceiling_Light_SceneBrightness,
Hall_Ceiling_Light_ColorTemperature
)
} else if (newState == 6001) { // 6001=L Down LONG
light_Off.apply(Hall_Ceiling_Light_Brightness)
} else if (newState == 6002) { // 6002=L Down 1
light_dimDown.apply(Hall_Ceiling_Light_Brightness)
} else if (newState == 6003) { // 6003=L Down LONG RELEASE
} else if (newState == 6004) { // 6004=L Down 2
light_min.apply(Hall_Ceiling_Light_Brightness)
} else if (newState == 6005) { // 6005=L Down 3
light_Off.apply(Hall_Ceiling_Light_Brightness)
}
end
rule "Wall Switch - Landing (Traadfri Dimmer)"
when
Item Landing_WallSwitch_Button received update
then
if (newState == 1001) { // 1001=
} else if (newState == 1002) { // 1002=Up1
cct_On.apply(
Landing_Ceiling_Light_Brightness,
Landing_Ceiling_Light_SceneBrightness,
Landing_Ceiling_Light_ColorTemperature
)
} else if (newState == 1003) { // 1003=
} else if (newState == 1004) { // 1004=
} else if (newState == 1005) { // 1005=
} else if (newState == 2001) { // 1001=
} else if (newState == 2002) { // 1002=Up1
light_Off.apply(Landing_Ceiling_Light_Brightness)
} else if (newState == 2003) { // 1003=
} else if (newState == 2004) { // 1004=
} else if (newState == 2005) { // 1005=
}
end
rule "Wall Switch - Sitting Room (Aqora Smart Switch)"
when
Item SittingRoom_WallSwitch_Button received update
then
if (newState == 1001) { // 1001=Hold
TVSamsung_Power.sendCommand(OFF)
} else if (newState == 1002) { // 1002=1Clk
if (SittingRoom_Side_Lamps.state == OFF) {
switch_On.apply(SittingRoom_Side_Lamps)
} else {
light_Off.apply(SittingRoom_Side_Lamps)
}
} else if (newState == 1003) { // 1003=
} else if (newState == 1004) { // 1004=2Clk
if (TVSamsung_KeyCode == "KEY_PLAY") {
TVSamsung_KeyCode.sendCommand("KEY_PAUSE")
} else {
TVSamsung_KeyCode.sendCommand("KEY_PLAY")
}
} else if (newState == 1005) { // 1005=3Clk
}
end
rule "Wall Switch - Jimmys Room, Bedside (Aqora Smart Switch)"
when
Item JimmysRoom_Bedside_WallSwitch_Button received update
then
if (newState == 1001) { // 1001=Hold
if (SceneSelection.state == NIGHT) {
light_Off.apply(JimmysRoom_Bedside_Lamp_OnOff)
light_Off.apply(gAll_Lights_Brightness)
} else {
light_Off.apply(JimmysRoom_Bedside_Lamp_OnOff)
}
} else if (newState == 1002) { // 1002=1Clk
if (JimmysRoom_Bedside_Lamp_OnOff.state == ON) {
if (SceneSelection.state == NIGHT) {
light_Off.apply(JimmysRoom_Bedside_Lamp_OnOff)
light_Off.apply(gAll_Lights_Brightness)
} else {
light_Off.apply(JimmysRoom_Bedside_Lamp_OnOff)
}
} else {
switch_On.apply(JimmysRoom_Bedside_Lamp_OnOff)
}
} else if (newState == 1003) { // 1003=
} else if (newState == 1004) { // 1004=2Clk
if (JimmysRoom_Bedside_Lamp_OnOff.state == ON) {
if (SceneSelection.state == NIGHT) {
light_Off.apply(JimmysRoom_Bedside_Lamp_OnOff)
light_Off.apply(gAll_Lights_Brightness)
} else {
light_Off.apply(JimmysRoom_Bedside_Lamp_OnOff)
}
} else {
switch_On.apply(JimmysRoom_Bedside_Lamp_OnOff)
}
} else if (newState == 1005) { // 1005=3Clk
if (JimmysRoom_Bedside_Lamp_OnOff.state == ON) {
if (SceneSelection.state == NIGHT) {
light_Off.apply(JimmysRoom_Bedside_Lamp_OnOff)
light_Off.apply(gAll_Lights_Brightness)
} else {
light_Off.apply(JimmysRoom_Bedside_Lamp_OnOff)
}
} else {
switch_On.apply(JimmysRoom_Bedside_Lamp_OnOff)
}
}
end
Looking forward to hearing some good ideas…