Greetings from Germany,
for controlling the light in my rooms I decided to set them in “states”. Those states will change the lighting and so on. Hardware-Switches or Motion Sensors will set the State, not write to the light-bulbs directly.
An important feature I’d like to have is a kind of “auto-state”, which depends on the virtual item “TimeOfDay” and therefore chooses the correct light setting.
-
when turning ON the light, the state will be changed from “0” (OFF) to “1” (ON_AUTO), this “1” is my “auto-state”
-
this State “1” doesn’t switch any lights but chooses, depending on the virtual item “TimeOfDay”, another state like “10” for sleeping-time, “11” for dawn, “12” for day-mode and “13” for maximum brightness
-
states 10,11,12 or 13 turns the actual hardware ON
-
state 0 turns the lights OFF
-
Example: Light is OFF (State 0) --> Switch is pressed --> State 1 --> item “state” changed --> rule is executed and chooses to set the same state to 12 because TimoOfDay is “Tag” --> item “state” changed again --> same rule is executed an turns on the lights
my question:
- is it possible to trigger the rule for “changed item” from itself by changing this item with “sendCommand” (or maybe “sendUpdate”?)
Thanks in advance,
Axel
Items (without the groups)
String vTimeOfDay "Tageszeit [%s]" (gDay)
Number vState_WZ "Lichtstimmung Wohnzimmer" <colorpicker> (gLightStates)
Dimmer WZ_Yeelight_WallLeft_Brightness <slider> (gWohnzimmer, gDimmLicht) { channel="yeelight:Wonder:0x00000000036d7XXX:Brightness" }
Dimmer WZ_Yeelight_WallLeft_ColorTemperature <colorlight> (gWohnzimmer, gColorLicht) { channel="yeelight:Wonder:0x00000000036d7XXX:Color_Temperature" }
//--- Groups (not all)
Group gWohnung
Group gWohnzimmer (gWohnung)
Group gAktoren (gWohnung)
Group:Number gLicht (gAktoren)
Group:Number:AVG gDimmLicht (gLicht)
Group:Number:AVG gColorLicht (gLicht)
Rule
//------ Light Settings
val sleep_Brightness = 1
val sleep_ColorTemperature = 20
val night_Brightness = 20
val night_ColorTemperature = 22
val day_Brightness = 80
val day_ColorTemperature = 24
val max_Brightness = 100
val max_ColorTemperature = 28
//------ Light StateMachines
rule "vState_WZ"
when
Item vState_WZ changed
then
switch (vState_WZ.state) {
// AUS
case 0: {
gWohnzimmer.members.filter[light | light.getGroupNames.contains("gLicht")].forEach[ light | if (light.state == ON) light.sendCommand(OFF)]
}
// AUTO --> Auswahl nach Tageszeit
case 1: {
switch (vTimeOfDay.state) {
case "Schlafen": vState_WZ.sendCommand(10)
case "Morgen": vState_WZ.sendCommand(11)
case "Tag": vState_WZ.sendCommand(12)
case "Nachmittag": vState_WZ.sendCommand(12)
case "Abend": vState_WZ.sendCommand(11)
case "Nacht": vState_WZ.sendCommand(10)
}
}
// Schlafen
case 10: {
gWohnzimmer.members.filter[light | light.getGroupNames.contains("gDimmLicht")].forEach[ light | light.sendCommand(sleep_Brightness) ]
gWohnzimmer.members.filter[light | light.getGroupNames.contains("gColorLicht")].forEach[ light | light.sendCommand(sleep_ColorTemperature) ]
}
// Dämmerung
case 11: {
gWohnzimmer.members.filter[light | light.getGroupNames.contains("gDimmLicht")].forEach[ light | light.sendCommand(night_Brightness) ]
gWohnzimmer.members.filter[light | light.getGroupNames.contains("gColorLicht")].forEach[ light | light.sendCommand(night_ColorTemperature) ]
}
// Tag
case 12: {
gWohnzimmer.members.filter[light | light.getGroupNames.contains("gDimmLicht")].forEach[ light | light.sendCommand(day_Brightness) ]
gWohnzimmer.members.filter[light | light.getGroupNames.contains("gColorLicht")].forEach[ light | light.sendCommand(day_ColorTemperature) ]
}
// Maximal
case 13: {
gWohnzimmer.members.filter[light | light.getGroupNames.contains("gDimmLicht")].forEach[ light | light.sendCommand(max_Brightness) ]
gWohnzimmer.members.filter[light | light.getGroupNames.contains("gColorLicht")].forEach[ light | light.sendCommand(max_ColorTemperature) ]
}
}
end