Hi All,
I have a number of lights distributed across some groups, they all roll up into a parent group, gAllLivingLights.
What I want to display, is the number of lights ON inside that parent group.
I have the following.
Can I use
Group:Number:SUM
Would just displaying all of them, either ON or OFF. Not ideal.
My current nested group code is:
Group gAllLivingLights (gLivingLights,gLivingDimmers,gKitchenLights,gStudyLights,gKitchenLights)
With my childs:
/*Group Definitions for Lights on the Living Level*/
Group:Switch:SUM gLivingLights "Living Lights" [ "Lighting" ]
Group:Switch:SUM gLivingDimmers "Living Level Dimmers" [ "Lighting" ]
Group:Switch:SUM gKitchenLights "Kitchen Lights" [ "Lighting" ]
Group:Switch:SUM gStudyLights "Study Lights" [ "Lighting" ]
Thank you wise ones!
ljsquare
(Laurens Jan Merkx)
August 14, 2019, 9:30pm
2
I think this is what you want:
Group:Switch:OR(ON,OFF) Lights “Active Lights [%d]”
https://www.openhab.org/docs/configuration/items.html#group-type-and-state
Yes, for an individual group, but for a nested? I’ll try it
ljsquare
(Laurens Jan Merkx)
August 14, 2019, 10:05pm
5
But I’ve I read your code right, this is the wrong way. The parent group is not supposed to belong to any group. The child groups are supposed to belong to the parent group.
Group:Switch:OR(ON,OFF) gAllLivingLights
Group:Switch:OR(ON,OFF) gLivingLights "Living Lights" (gAllLivingLights) [ "Lighting" ]
Group:Switch:OR(ON,OFF) gLivingDimmers "Living Level Dimmers" (gAllLivingLights) [ "Lighting" ]
Group:Switch:OR(ON,OFF) gKitchenLights "Kitchen Lights" (gAllLivingLights) [ "Lighting" ]
Group:Switch:OR(ON,OFF) gStudyLights "Study Lights" (gAllLivingLights) [ "Lighting" ]
This supposed to work
1 Like
dastrix80
(Kris K)
August 14, 2019, 10:27pm
6
Thanks Laurens! ill give this a go
dastrix80
(Kris K)
August 14, 2019, 10:31pm
7
So absolutely, it now displays ON or OFF in the nested group, but I need to know the number of ONs in the nested group
A bit closer!
RolfV
(Rolf Vermeer)
August 14, 2019, 10:46pm
8
I don’t believe it is possible to SUM ON and OF states. I think you will have to resort to an item that is updated by a rule whenever any item within the group changes its state, and in that rule count the number of items in the group that are ON.
rossko57
(Rossko57)
August 15, 2019, 12:47am
9
Have you actually tried your first thought?
Group:Number:SUM with Switch Item members will count the ON states.
And of course a Group:Number:SUM with Group:Number:SUM members will total those up.
dastrix80
(Kris K)
August 15, 2019, 4:14am
10
I had my nesting wrong, so havent since then. Ill give it a go now
dastrix80
(Kris K)
August 15, 2019, 5:04am
11
Sort of! Its giving me numerical values lol!
So when study light goes on, it shows 1.5
openhab> smarthome:status gAllLivingLights
0.00000000
openhab>
ljsquare
(Laurens Jan Merkx)
August 15, 2019, 6:07am
12
Put in de label of the parent group [%d]
at the end of the name. Eg. “All lights [%d]”
dastrix80
(Kris K)
August 15, 2019, 7:30am
13
Now it shows
openhab> smarthome:status gAllLivingLights
30.48000000
openhab>
Group:Number:SUM gAllLivingLights "All Living Lights [%d]"
hmerk
(Hans-Jörg Merk)
August 15, 2019, 7:42am
14
Try what it shows when you remove the Dimmer Item from the group.
2 Likes
rossko57
(Rossko57)
August 15, 2019, 9:44am
15
Oh, Dimmers in the mix. Well, that’s not going to work.
1 Like
dastrix80
(Kris K)
August 15, 2019, 11:06am
16
Thanks Hans, you’ve got it Working nicely now! Thanks all!
dastrix80
(Kris K)
August 15, 2019, 9:35pm
18
I Spoke too soon!
Combined number is 19 lights on this Living Level, yet the parent shows only 2 of 5.
2 on is correct , 1 in Kitchen and 1 in the study. But who knows where 5 is coming from!
Group:Number:SUM gAllLivingLights "All Living Lights [%d]"
/*Group Definitions for Lights on the Living Level*/
Group:Switch:SUM gLivingLights "Living Lights" (gAllLivingLights,gInsideLights,gAllLights) [ "Lighting" ]
And displayed with:
div ng-repeat="item in itemsInGroup('gAllLivingLights') | filter:query as filteredAllLivingLights"></div>
<div class="summary on">ON: {{ ( filteredAllLivingLights | filter: { state: 'ON' } ).length }} of {{filteredAllLivingLights.length}}</div>
rossko57
(Rossko57)
August 15, 2019, 10:21pm
19
It’s got five direct members (the groups).
dastrix80
(Kris K)
August 15, 2019, 10:24pm
20
Which is not what I wanted in the original post.
What I want to display, is the number of lights ON inside that parent group.
Not the number of groups in the parent…