Group command concern arises from that.
Yes, but not from the scriptâŠ
[clipse.smarthome.model.script.alloff]
I had to because in my habpanel code, it dynamically populates the lights from a group, and the item.type I could only get working as a Switch
as per this:
<div class="widget" ng-if="item.type=='Switch' && itemValue(item.name)=='ON'" ng-click="sendCmd(item.name, 'OFF')">
I have a mix of switches and dimmers, so for this to work Iâd need to have
item.type=='Switch' && item.type=='Dimmer' && itemValue=(item.name=='ON'
" but i couldnt get it to function
No, you need a different version:
(Lights instanceof SwitchItem || Lights instanceof DimmerItem) && Lights.state == ON
An Item canât be Switch and Dimmer the same time
Sorry, I mean in my HabPanel code (not the rule code youâre speaking of). The rule works, I just need to try and remove the duplicate switch items for each dimmer device but display both in my habpanel code (as not every light is a dimmer)
Ah, sorry, didnât get this point. I donât use HABpanel (yet), so unfortunatley I canât help here.
No trouble! Looks like I spoke too soon.
I went ahead and removed the nested groups , by adding my switches & dimmer items into âgAllLightsâ for simplicity
The rule however still sends commands of OFF to all lights
rule "Turn off all lights"
when
Item gAllLights received command OFF
then
gAllLights?.allMembers.forEach[ AllLights |
if (AllLights instanceof SwitchItem && AllLights.state == ON) {
AllLights.sendCommand(OFF)
} else if (AllLights instanceof DimmerItem && AllLights.state > 0) {
AllLights.sendCommand(OFF)
} //else if any other type we do nothing
]
end
Yes because you send the command to the group, openHAB will cascade the command to members.
OpenHAB does that REGARDLESS there is a rule for that trigger or not.
Understood, so the proxy solution is the only option for the rule trigger
rule "Turn off all lights"
when
Item Proxy_gAllLights received command OFF
then
gAllLights?.allMembers.forEach[ AllLights |
if (AllLights instanceof SwitchItem && AllLights.state == ON) {
AllLights.sendCommand(OFF)
} else if (AllLights instanceof DimmerItem && AllLights.state > 0) {
AllLights.sendCommand(OFF)
} //else if any other type we do nothing
]
end
Yes
Definitely. And then this rule should also work:
rule "Turn off all Lights"
when
Item proxyAllLights received command OFF
then
gAllLights?.allMembers.filter[Lights | !(Lights instanceof GroupItem) && Lights.getStateAs(OnOffType) == ON ].forEach[ LightsON |
LightsON.sendCommand(OFF)
]
end
If there are no more groups in gAllLights, the code can be simplified to:
rule "Turn off all Lights"
when
Item proxyAllLights received command OFF
then
gAllLights?.members.filter[Lights | Lights.getStateAs(OnOffType) == ON ].forEach[ LightsON |
LightsON.sendCommand(OFF)
]
end