I have Group definitions like
Group:Dimmer:MIN gDimm "All Dimmed Lights"
Group:Switch:MIN gSwitchedLight "All Switched Lights"
When calling up GetType on these groups, “Group” is returned.
How can I query the subtype “Dimmer/Switch”?
I have Group definitions like
Group:Dimmer:MIN gDimm "All Dimmed Lights"
Group:Switch:MIN gSwitchedLight "All Switched Lights"
When calling up GetType on these groups, “Group” is returned.
How can I query the subtype “Dimmer/Switch”?
This might work:
if(gDimm instance of DimmerType)
The question is why do you need to do this? There might be another way to accomplish what you are after.
For example, you can send ON/OFF commands to Dimmers so it may not matter what type it is.
You can also get the state of Items as different types. For example, because Dimmer and Color Items can receive be commanded with ON/OFF, you can also get their current state as those types.
MyDimmerItem.getStateAs(OnOffType)
What I have seen is that if I perform following operation on a dimmer (in particular osram lightify):
I get get a flash between step 2&3.
so I have to make sure to switch of dimmers by set state to 0
And just to mention: I am too getting the feeling that I am full off track with lamda-crazy-solution, but not tried, not failed.
Is Color also instance of DimmerType?
Yes.
Color is a Dimmer and a Switch
Dimmer is a Switch
So you can, for example, send an ON to a Color Item or a Dimmer Item. You can send a single PercentType to a Color or a Dimmer to adjust brightness.
An item of type GroupItem provides the method getBaseItem() that will return the group item’s base item, the type of which you can query with the method getType(). Note that getBaseItem() returns a null if the provided group item has no base item.
Untested example usage:
var groupBaseType = gMyGroupItem.getBaseItem()?.getType()
Rich’s advice is sound, I use groups of lights that are a mix of Dimmer and Switch items exactly the way Rich describes their use above.
I get following error:
'getBaseItem' is not a member of 'org.eclipse.smarthome.core.items.GroupItem'; line 18, column 46, length 19
Implemented the check this way:
gMyGroupItem.acceptedCommandTypes.contains(PercentType)
Which separates dimmer from switches regardless if it is an single item or group.
Works for me.
logInfo(logID, "gOFLtsOn groupBaseType: {}", gOFLtsOn.getBaseItem().getType().toString())
When the rule containing that line is executed, the following appears in openhab.log:
2018-12-14 07:21:17.938 [INFO ][SH-ruleEngine-4][vation-azimuth.rules.ofc-all-off-led] - gOFLtsOn groupBaseType: Switch
Platform here is openHABian on RPi 3B, 2.4.0-SNAPSHOT, Build #1445.
Can you post your relevant items and rules file(s)?
2.3.0 Stable, got a solution, see above.
here the rules file:
import java.util.Map
val Number NO_TIMEOUT = -1
val Number FORGOT_TIMEOUT = 60*60*5
val Number STAIRS_TIMEOUT = 60
val Number EXTENDED_TIMEOUT = 2*60
val Number STAIRS_ILUMINATION = 100
val Number ENTRY_ILUMINATION = 70
val Number WORK_ILUMINATION = 230
val Number INGNORE_ILUMINATION = 255
val java.util.concurrent.ConcurrentHashMap<String, Timer> lightTimers = new java.util.concurrent.ConcurrentHashMap()
val java.util.concurrent.ConcurrentHashMap<String, DateTime> lightTimersExpiration = new java.util.concurrent.ConcurrentHashMap()
val lightManager = [ GenericItem light, Number level, Boolean keepLevel |
try{
logInfo("lightManager", " <"+light.label + "> : start")
if (light.acceptedCommandTypes.contains(PercentType) ) {
logInfo("lightManager", " <"+light.label + "> : *** dimmer type ***, target level: " + level + " Light level: "+ light.state )
// make sure not to go over 100
if (!keepLevel || light.state <= level) sendCommand(light, if (level > 100) 100 else level)
logInfo("lightManager", " <"+light.label + "(1)> " )
}
else {
logInfo("lightManager", " <"+light.label + "> : *** Switch type ***" )
sendCommand(light, if (level > 0) ON else OFF)
}
} catch(Exception e) {
logInfo("lightManager", " Exception : " + e.getLocalizedMessage)
sendCommand(light, "0")
}
return true
]
val lightTimerManager = [ GenericItem light, GenericItem motion, Functions$Function3<GenericItem, Number, Boolean, Boolean> lightMgr, Number timeout, Map<String, Timer> timers, Map<String, DateTime> timersExpiration |
try{
// timeout -1 means reset timer e.g. light toggeled OFF
if (timeout > 0 ){
logInfo("lightTimerManager", " <"+light.label + "> : size of timers HM before: " + timers.size)
// Is there a time already running for item and timer is runing (timersExpiration > now)
if (timers.containsKey(light.label) && timers.get(light.label) !==null && timersExpiration.get(light.label) > now ){
// Is the current running timer shorter that new needed
if (timersExpiration.get(light.label) < now.plusSeconds(timeout.intValue)){
// yes, so extend timer and store new timeout in table
timersExpiration.put(light.label, now.plusSeconds(timeout.intValue))
timers.get(light.label).reschedule(now.plusSeconds(timeout.intValue))
logInfo("lightTimerManager", "<"+light.label + "> : found and extend timer ")
}
}
else {
// no timer runnimg create a new one and store new timeout in table
logInfo("lightTimerManager", " <"+light.label + "> : create timeout")
timersExpiration.put(light.label, now.plusSeconds(timeout.intValue))
timers.put(light.label, createTimer(now.plusSeconds(timeout.intValue), [|
logInfo("lightTimerManager", "<"+light.label + "(1)> : expired timer, motion: " + motion.state)
if (motion !== null && motion.state == ON) {
logInfo("lightTimerManager", "<"+light.label + "(1)> : expired timer, but motion still active")
timers.get(light.label). reschedule(now.plusSeconds(timeout.intValue))
timersExpiration.put(light.label, now.plusSeconds(timeout.intValue))
}
else {
logInfo("lightTimerManager", "<"+light.label + "(2)> : expired timer")
lightMgr.apply(light, 0, false)
}
]))
}
} else if (timers.containsKey(light.label) && timers.get(light.label) !==null){
// Cancel timer and set it to null
logInfo("lightTimerManager", " <"+light.label + "(1)> : cancel timer")
timers.get(light.label).cancel()
lightMgr.apply(light, 0, false)
timersExpiration.put(light.label, now)
}
} catch(Exception e) {
logInfo("lightTimerManager", " Exception : " + e.getLocalizedMessage)
sendCommand(light, "0")
}
return true
]
val dimmLight= [ GenericItem light, Functions$Function3<GenericItem, Number, Boolean, Boolean>lightMgr|
try{
logInfo("dimmLight ", "<"+light.label + "> ")
// incremet by 5% light manager does not to go over 100%
lightMgr.apply(light, light.state as Number + 5, false)
logInfo("dimmLight ", "<"+light.label + "> state : " + light.state.toString)
} catch(Exception e) {
logInfo("toggleLight", " Exception : " + e.getLocalizedMessage)
sendCommand(light, "0")
}
return true
]
val toggleLight= [ GenericItem light, Functions$Function3<GenericItem, Number, Boolean, Boolean> lightMgr|
// retvalue is used to reset timer if light switched off
var retValue = false
try{
logInfo("toggleLight ", "<"+light.label + "> ")
if ( light.getStateAs(OnOffType) == OFF) {
logInfo("toggleLight ", "<"+light.label + "(1)> ")
if (isBedTime.state == ON){
logInfo("toggleLight ", "<"+light.label + "(2)> ")
lightMgr.apply(light, 5, false)
}
else {
logInfo("toggleLight ", "<"+light.label + "(3)> ")
lightMgr.apply(light, 100, false)
}
retValue = true
}
else {
logInfo("toggleLight ", "<"+light.label + "(4)> ")
lightMgr.apply(light, 0, false)
}
} catch(Exception e) {
logInfo("toggleLight", " Exception : " + e.getLocalizedMessage)
lightMgr.apply(light, 0, false)
}
return retValue
]
val motionOnLight= [GenericItem ilumination, GenericItem light, Number ilmLimit, Functions$Function3<GenericItem, Number, Boolean, Boolean> lightMgr, Boolean allDay |
// retvalue used to start timer, not all calls to motionOnLight actually switches light on
var retValue = false
try{
logInfo("motionOnLight", "<" + light.label + "> : started, ilumination : "+ ilumination.state + " limit : " + ilmLimit.toString )
// Is is not bed time and it is dark enough so it makes sense to switch on
if ((isBedTime.state == OFF || allDay) && ((ilumination.state as Number) <= ilmLimit)) {
// out of the threshold calculate min 5 and max 100 values
var Number calculatedLevel = 5 + ((ilumination.state as Number + 5) * 95 / ilmLimit)
// setting threshold to 255 mean, ignoring it, so set target level to 100
var Number targetLevel = if ( ilmLimit < 255 ) calculatedLevel else 100
// only set value if current light power is lower
lightMgr.apply(light, targetLevel, true)
logInfo("motionOnLight", light.label + ": targetLevel : "+ targetLevel.toString )
retValue = true
}
} catch(Exception e) {
logInfo("motionOnLight", " Exception : " + e.getLocalizedMessage)
sendCommand(light, "0")
}
return retValue
]
rule "Initiate lightControl.rules"
when
System started
then
logInfo("Initiate lightControl.rules", "finished")
end
// ***************************************************************
// ************************ Rules Start **************************
// ***************************************************************
// ***************************************************************
// ************************ Entry/Outside **************************
// ***************************************************************
rule "Entry toggle light"
when
Channel "homematic:HmIP-SMI55:87ff2485:0014D709AEF787:1#PRESS" triggered SHORT
then
lightTimerManager.apply(EntryLight, null, lightManager, if (toggleLight.apply(EntryLight, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "Entry Outside toggle light"
when
Channel "homematic:HmIP-SMI55:87ff2485:0014D709AEF787:2#PRESS" triggered SHORT
then
lightTimerManager.apply(EntryOutsideLight, null, lightManager, if (toggleLight.apply(EntryOutsideLight, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "Entry dimm light"
when
Channel "homematic:HmIP-SMI55:87ff2485:0014D709AEF787:1#PRESS" triggered LONG or
Channel "homematic:HmIP-SMI55:87ff2485:0014D709AEF787:2#PRESS" triggered LONG or
Channel "homematic:HmIP-SMI55:87ff2485:0014D709AEF787:1#PRESS" triggered CONT or
Channel "homematic:HmIP-SMI55:87ff2485:0014D709AEF787:2#PRESS" triggered CONT
then
dimmLight.apply(EntryLight, lightManager)
lightTimerManager.apply(EntryLight, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "Entry motion light "
when
Item EntryMotion changed to ON
then
if (motionOnLight.apply(EntryIlumination, EntryLight, STAIRS_ILUMINATION, lightManager, false))
lightTimerManager.apply(EntryLight, EntryMotion, lightManager, STAIRS_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "Entry external motion light "
when
Item EntryOutsideMotion changed to ON
then
if (motionOnLight.apply(EntryOutsideIlumination, EntryOutsideLight, STAIRS_ILUMINATION, lightManager, true))
lightTimerManager.apply(EntryOutsideLight, EntryOutsideMotion, lightManager, STAIRS_TIMEOUT, lightTimers, lightTimersExpiration)
end
// ***************************************************************
// ************************ Hallway **************************
// ***************************************************************
rule "Hallway toggle light"
when
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961383:1#PRESS" triggered SHORT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961383:2#PRESS" triggered SHORT
then
lightTimerManager.apply(HallwayDownLight, null, lightManager, if (toggleLight.apply(HallwayDownLight, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "Hallway dimm light"
when
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961383:1#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961383:2#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961383:1#PRESS" triggered CONT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961383:2#PRESS" triggered CONT
then
dimmLight.apply(HallwayDownLight, lightManager)
lightTimerManager.apply(HallwayDownLight, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "Hallway motion light "
when
Item HallwayDownMotion changed to ON
then
/*
if (motionOnLight.apply(HallwayDownIlumination, HallwayDownLight, STAIRS_ILUMINATION, lightManager, false))
lightTimerManager.apply(HallwayDownLight, HallwayDownMotion, lightManager, STAIRS_TIMEOUT, lightTimers, lightTimersExpiration)
*/
end
// ***************************************************************
// ************************ Stair/Hallway **************************
// ***************************************************************
rule "StairsHallway toggle light"
when
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961397:1#PRESS" triggered SHORT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961397:2#PRESS" triggered SHORT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961368:1#PRESS" triggered SHORT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961368:2#PRESS" triggered SHORT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0964574:1#PRESS" triggered SHORT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0964574:2#PRESS" triggered SHORT
then
lightTimerManager.apply(StairsHallwayLight, null, lightManager, if (toggleLight.apply(StairsHallwayLight, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "StairsHallway dimm light"
when
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961397:1#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961397:2#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961368:1#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961368:2#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0964574:1#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0964574:2#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961397:1#PRESS" triggered CONT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961397:2#PRESS" triggered CONT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961368:1#PRESS" triggered CONT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961368:2#PRESS" triggered CONT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0964574:1#PRESS" triggered CONT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0964574:2#PRESS" triggered CONT
then
dimmLight.apply(StairsHallwayLight, lightManager)
lightTimerManager.apply(StairsHallwayLight, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "StairsHallway motion light "
when
Item g_StairsHallwayMotion changed to ON
then
if (motionOnLight.apply(g_StairsHallwayIlumination, StairsHallwayLight, STAIRS_ILUMINATION, lightManager, false))
lightTimerManager.apply(StairsHallwayLight, g_StairsHallwayMotion, lightManager, STAIRS_TIMEOUT, lightTimers, lightTimersExpiration)
end
// ***************************************************************
// ************************ Guestroom **************************
// ***************************************************************
rule "GuestRoom Light Top toggle"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001867:1#PRESS" triggered SHORT
then
lightTimerManager.apply(GuestTopLight, null, lightManager, if (toggleLight.apply(GuestTopLight, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "GuetsRoom TopLight dimm"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001867:1#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001867:1#PRESS" triggered CONT
then
dimmLight.apply(GuestTopLight, lightManager)
lightTimerManager.apply(GuestTopLight, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "GuestRoom Light Standlamp toggle"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001867:3#PRESS" triggered SHORT
then
lightTimerManager.apply(GuestRoomStandLamp, null, lightManager, if (toggleLight.apply(GuestRoomStandLamp, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "GuetsRoom Standlamp dimm"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001867:3#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001867:3#PRESS" triggered CONT
then
dimmLight.apply(GuestRoomStandLamp, lightManager)
lightTimerManager.apply(GuestRoomStandLamp, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
// ***************************************************************
// ************************ StudyRoom **************************
// ***************************************************************
rule "StudyRoom Top Lamp toggle"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001224:1#PRESS" triggered SHORT
then
lightTimerManager.apply(StudyRoomLightTop, null, lightManager, if (toggleLight.apply(StudyRoomLightTop, lightManager)) FORGOT_TIMEOUT else -1 , lightTimers, lightTimersExpiration)
end
rule "StudyRoom Top Lamp dimm"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001224:1#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001224:1#PRESS" triggered CONT
then
dimmLight.apply(StudyRoomLightTop, lightManager)
lightTimerManager.apply(StudyRoomLightTop, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
// ***************************************************************
// ************************ Dining/Living Room **************************
// ***************************************************************
rule "Dining Room Spots dimm"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001241:1#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001902:3#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001241:1#PRESS" triggered CONT or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001902:3#PRESS" triggered CONT
then
dimmLight.apply(gTFDRLightSpot, lightManager)
lightTimerManager.apply(gTFDRLightSpot, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "Dining Room Spots toggle"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001241:1#PRESS" triggered SHORT or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001902:3#PRESS" triggered SHORT
then
lightTimerManager.apply(gTFDRLightSpot, null, lightManager, if (toggleLight.apply(gTFDRLightSpot, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "Dining Room Table dimm"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001241:2#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001902:4#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001241:2#PRESS" triggered CONT or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001902:4#PRESS" triggered CONT
then
dimmLight.apply(gTFDRLightTop, lightManager)
lightTimerManager.apply(gTFDRLightTop, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "Dining Room Table toggle"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001241:2#PRESS" triggered SHORT or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001902:4#PRESS" triggered SHORT
then
lightTimerManager.apply(gTFDRLightTop, null, lightManager, if (toggleLight.apply(gTFDRLightTop, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "Living Room Spots dimm"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001241:3#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001241:3#PRESS" triggered CONT
then
dimmLight.apply(gTFWZLightSpot, lightManager)
lightTimerManager.apply(gTFWZLightSpot, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "Living Room Spots toggle"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001241:3#PRESS" triggered SHORT
then
lightTimerManager.apply(gTFWZLightSpot, null, lightManager, if (toggleLight.apply(gTFWZLightSpot, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "Living Room Table dimm"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001241:4#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001241:4#PRESS" triggered CONT
then
dimmLight.apply(gTFWZLightTop, lightManager)
lightTimerManager.apply(gTFWZLightTop, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "Living Room Table toggle"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001241:4#PRESS" triggered SHORT
then
lightTimerManager.apply(gTFWZLightTop, null, lightManager, if (toggleLight.apply(gTFWZLightTop, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "Living Room Standlamp toggle"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001241:6#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001241:6#PRESS" triggered SHORT or
Channel "homematic:HM-PB-6-WM55:87ff2485:OEQ0284543:6#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:OEQ0284543:6#PRESS" triggered SHORT
then
lightTimerManager.apply(LivingRoomStandLamp, null, lightManager, if (toggleLight.apply(LivingRoomStandLamp, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "Living Room Chair Lamp dimm"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:OEQ0284543:5#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:OEQ0284543:5#PRESS" triggered CONT
then
dimmLight.apply(LivingRoomChairLamp, lightManager)
lightTimerManager.apply(LivingRoomChairLamp, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "Living Room Chair Lamp toggle"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:OEQ0284543:5#PRESS" triggered SHORT
then
lightTimerManager.apply(LivingRoomChairLamp, null, lightManager, if (toggleLight.apply(LivingRoomChairLamp, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
// ***************************************************************
// ************************ Kitchen **************************
// ***************************************************************
rule "KitchenWorktop dimm"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001902:1#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001902:1#PRESS" triggered CONT
then
dimmLight.apply(TFKichenWorkTop, lightManager)
lightTimerManager.apply(TFKichenWorkTop, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "KitchenWorktop toggle"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001902:1#PRESS" triggered SHORT
then
lightTimerManager.apply(TFKichenWorkTop, null, lightManager, if (toggleLight.apply(TFKichenWorkTop, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
// ***************************************************************
// ************************ Boiler Room **************************
// ***************************************************************
rule "Boiler Room toggle"
when
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0962519:1#PRESS" triggered SHORT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0962519:2#PRESS" triggered SHORT
then
lightTimerManager.apply(BoilerRoomLight, null, lightManager, if (toggleLight.apply(BoilerRoomLight, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "Boiler Room dimm"
when
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0962519:1#PRESS" triggered CONT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0962519:2#PRESS" triggered CONT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0962519:1#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0962519:2#PRESS" triggered LONG
then
dimmLight.apply(BoilerRoomLight, lightManager)
lightTimerManager.apply(BoilerRoomLight, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "Boiler Room motion"
when
Item BoilerRoomMotion changed to ON
then
if (motionOnLight.apply(BoilerRoomIlumination, BoilerRoomLight, STAIRS_ILUMINATION, lightManager, false))
lightTimerManager.apply(BoilerRoomLight, BoilerRoomMotion, lightManager, EXTENDED_TIMEOUT, lightTimers, lightTimersExpiration)
end
// ***************************************************************
// ************************ Pantry Room **************************
// ***************************************************************
rule "PantryRoom motion light"
when
Item PantryMotion changed to ON
then
if (motionOnLight.apply(PantryIllumination, PantryLight, WORK_ILUMINATION, lightManager, false))
lightTimerManager.apply(PantryLight, PantryMotion, lightManager, STAIRS_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "PantryRoom light toggle"
when
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:MEQ1848771:1#PRESS" triggered SHORT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:MEQ1848771:2#PRESS" triggered SHORT
then
lightTimerManager.apply(PantryLight, null, lightManager, if (toggleLight.apply(PantryLight, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "PantryRoom light dimm"
when
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:MEQ1848771:1#PRESS" triggered CONT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:MEQ1848771:2#PRESS" triggered CONT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:MEQ1848771:1#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:MEQ1848771:2#PRESS" triggered LONG
then
dimmLight.apply(PantryLight, lightManager)
lightTimerManager.apply(PantryLight, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
// ***************************************************************
// ************************ Locker Room **************************
// ***************************************************************
rule "LockerRomm light toggle"
when
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0964632:1#PRESS" triggered SHORT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0964632:2#PRESS" triggered SHORT
then
lightTimerManager.apply(LockerRoomLight, null, lightManager, if (toggleLight.apply(LockerRoomLight, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "LockerRomm light dimm"
when
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0964632:1#PRESS" triggered CONT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0964632:2#PRESS" triggered CONT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0964632:1#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0964632:2#PRESS" triggered LONG
then
dimmLight.apply(LockerRoomLight, lightManager)
lightTimerManager.apply(LockerRoomLight, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "LockerRoom motion light "
when
Item LockerRoomMotion changed to ON
then
if (motionOnLight.apply(LockerRoomIlumination, LockerRoomLight, STAIRS_ILUMINATION, lightManager, false))
lightTimerManager.apply(LockerRoomLight, LockerRoomMotion, lightManager, STAIRS_TIMEOUT, lightTimers, lightTimersExpiration)
end
// ***************************************************************
// ************************ Bedroom **************************
// ***************************************************************
rule "Bed Headlight dimm"
when
Channel "homematic:HM-PB-2-WM55:87ff2485:OEQ0484128:1#PRESS" triggered LONG or
Channel "homematic:HMIP-WRC2:87ff2485:000193C98CA4FE:1#PRESS" triggered LONG or
Channel "homematic:HM-PB-2-WM55:87ff2485:OEQ0484128:2#PRESS" triggered LONG or
Channel "homematic:HMIP-WRC2:87ff2485:000193C98CA4FE:2#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001787:3#PRESS" triggered LONG or
Channel "homematic:HM-PB-2-WM55:87ff2485:OEQ0484128:1#PRESS" triggered CONT or
Channel "homematic:HMIP-WRC2:87ff2485:000193C98CA4FE:1#PRESS" triggered CONT or
Channel "homematic:HM-PB-2-WM55:87ff2485:OEQ0484128:2#PRESS" triggered CONT or
Channel "homematic:HMIP-WRC2:87ff2485:000193C98CA4FE:2#PRESS" triggered CONT or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001787:3#PRESS" triggered CONT
then
dimmLight.apply(BedRoomBedLight, lightManager)
lightTimerManager.apply(BedRoomBedLight, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "Bed Head Light Toggle"
when
Channel "homematic:HM-PB-2-WM55:87ff2485:OEQ0484128:1#PRESS" triggered SHORT or
Channel "homematic:HMIP-WRC2:87ff2485:000193C98CA4FE:1#PRESS" triggered SHORT or
Channel "homematic:HM-PB-2-WM55:87ff2485:OEQ0484128:2#PRESS" triggered SHORT or
Channel "homematic:HMIP-WRC2:87ff2485:000193C98CA4FE:2#PRESS" triggered SHORT or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001787:3#PRESS" triggered SHORT
then
if (toggleLight.apply(BedRoomBedLight, lightManager)){
lightTimerManager.apply(BedRoomBedLight, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
}
else {
lightTimerManager.apply(BedRoomBedLight, null, lightManager, NO_TIMEOUT, lightTimers, lightTimersExpiration)
// This will drag down gTFDRLightBed light too
lightTimerManager.apply(gTFDRLightBed, null, lightManager, NO_TIMEOUT, lightTimers, lightTimersExpiration)
}
end
rule "Bed Table lamps dimm"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001787:4#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001787:4#PRESS" triggered CONT
then
dimmLight.apply(gTFDRLightBed, lightManager)
lightTimerManager.apply(gTFDRLightBed, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "Bed table Lamps toggle"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001787:4#PRESS" triggered SHORT
then
lightTimerManager.apply(gTFDRLightBed, null, lightManager, if (toggleLight.apply(gTFDRLightBed, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule BedRoomClosetLights
when
Item g_BRClContacts changed
then
// logInfo("BedRoomClosetLight", "triggered")
/*
try{
if ( g_BRClContacts.state as OpenClosedType == OPEN && isBedTime.state == OFF )
{ sendCommand(BedRoomTopSpots, "100")}
else {
createTimer(now.plusSeconds(1), [|
if (g_BRClContacts.state as OpenClosedType == CLOSED) sendCommand(BedRoomTopSpots, "0") ])
}
} catch(Exception e) {sendCommand(BedRoomTopSpots, "0")}
*/
end
// ***************************************************************
// ************************ Toilet **************************
// ***************************************************************
rule "ToiletRoom motion light"
when
Item ToiletMotion changed to ON
then
if (motionOnLight.apply(ToiletIlumination, ToiletLightWall, INGNORE_ILUMINATION, lightManager, false))
lightTimerManager.apply(ToiletLightWall, ToiletMotion, lightManager, EXTENDED_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "ToiletRoom light toggle"
when
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961367:1#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961367:2#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961367:1#PRESS" triggered SHORT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961367:2#PRESS" triggered SHORT
then
lightTimerManager.apply(ToiletLightMirror, null, lightManager, if (toggleLight.apply(ToiletLightMirror, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
/*
rule "ToiletRoom light dimm"
when
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:MEQ1848771:1#PRESS" triggered CONT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:MEQ1848771:2#PRESS" triggered CONT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:MEQ1848771:1#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:MEQ1848771:2#PRESS" triggered LONG
then
dimmLight.apply(PantryLight, lightManager)
lightTimerManager.apply(PantryLight, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
*/
// ***************************************************************
// ************************ Garage **************************
// ***************************************************************
rule "Garage overall motion light"
when
Item g_GarageMotion changed to ON
then
if (motionOnLight.apply(g_GarageIlumination, GarageLight, WORK_ILUMINATION, lightManager, true))
lightTimerManager.apply(GarageLight, g_GarageMotion, lightManager, STAIRS_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "Garage Desk motion light"
when
Item GarageMotionWorkdesk changed to ON
then
if (motionOnLight.apply(g_GarageIlumination, GarageWorkdeskSocket, WORK_ILUMINATION, lightManager, true))
lightTimerManager.apply(GarageWorkdeskSocket, g_GarageMotion, lightManager, STAIRS_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "Garage light toggle"
when
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961436:1#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961436:2#PRESS" triggered LONG or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961436:1#PRESS" triggered SHORT or
Channel "homematic:HM-Sen-MDIR-WM55:87ff2485:NEQ0961436:2#PRESS" triggered SHORT
then
lightTimerManager.apply(GarageLight, null, lightManager, if (toggleLight.apply(GarageLight, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
// ***************************************************************
// ************************ Terrasse **************************
// ***************************************************************
rule "Terrasse Stand Lamp dimm"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001214:2#PRESS" triggered SHORT or
Channel "homematic:HM-PB-6-WM55:87ff2485:OEQ0284543:2#PRESS" triggered LONG or
Channel "homematic:HM-PB-6-WM55:87ff2485:NEQ1001214:2#PRESS" triggered CONT or
Channel "homematic:HM-PB-6-WM55:87ff2485:OEQ0284543:2#PRESS" triggered CONT
then
dimmLight.apply(TerrasseStandLamp, lightManager)
lightTimerManager.apply(TerrasseStandLamp, null, lightManager, FORGOT_TIMEOUT, lightTimers, lightTimersExpiration)
end
rule "Terrasse Stand Lamp toggle"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:OEQ0284543:2#PRESS" triggered SHORT or
Channel "homematic:HM-PB-6-WM55:87ff2485:OEQ0284543:2#PRESS" triggered CONT
then
lightTimerManager.apply(TerrasseStandLamp, null, lightManager, if (toggleLight.apply(TerrasseStandLamp, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "Terrasse Xmas Light toggle"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:OEQ0284543:3#PRESS" triggered SHORT or
Channel "homematic:HM-PB-6-WM55:87ff2485:OEQ0284543:3#PRESS" triggered CONT
then
lightTimerManager.apply(gXMasLight, null, lightManager, if (toggleLight.apply(gXMasLight, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "Terrasse Xmas Light ON"
when
Time cron "0 0 16 1/1 * ? *"
then
lightManager.apply(gXMasLight, 100, false)
end
rule "Terrasse Xmas Light OFF"
when
Time cron "0 30 23 1/1 * ? *"
then
lightManager.apply(gXMasLight, 0, false)
end
The item light
in your lambda lightManager
is declared as a GenericItem
, not a GroupItem
.
True, but a the end im some cases a group is passed in the chain of all lambdas:
e.g. : toggleLight -> lightTimerManager -> lightManager
Group:Switch:MIN gXMasLight "All Switched Lights" (gSwitchedLight)
Switch TreeXMasLight "Tree XMas Light [MAP(on-off.map):%s]" <switch> (gXMasLight) { channel="homematic:HM-LC-Sw1-FM:87ff2485:NEQ0211971:1#STATE"}
Switch GardenMotion "Garden Motion [MAP(on-off.map):%s]" <switch> (gXMasLight) { channel="wemo:socket:Socket-1_0-221417K01006DB:state"}
rule "Terrasse Xmas Light toggle"
when
Channel "homematic:HM-PB-6-WM55:87ff2485:OEQ0284543:3#PRESS" triggered SHORT or
Channel "homematic:HM-PB-6-WM55:87ff2485:OEQ0284543:3#PRESS" triggered CONT
then
lightTimerManager.apply(gXMasLight, null, lightManager, if (toggleLight.apply(gXMasLight, lightManager)) FORGOT_TIMEOUT else -1, lightTimers, lightTimersExpiration)
end
rule "Terrasse Xmas Light ON"
when
Time cron "0 0 16 1/1 * ? *"
then
lightManager.apply(gXMasLight, 100, false)
end
rule "Terrasse Xmas Light OFF"
when
Time cron "0 30 23 1/1 * ? *"
then
lightManager.apply(gXMasLight, 0, false)
end