i have certain rooms where there are 4 bulbs but they are grouped into 1 “light” for the rooom, however the sensor is counting that as 5 lights “on” when i really only want it to count it as 1.
how do i adjust this so that it only counts any bulbs in a particular group as 1?
For a start you should be using the new template integration instead of the legacy template sensor platform for new template sensors. The legacy template sensor is still supported but it is not getting new features.
Secondly light groups have an attribute called entity_id that you can use to refine your selection. This will only count light groups that are on:
However if you want a mix of groups and lights you are going to have to list them individually. The logic required to reject lights that are on in light groups that are on would be more complicated than doing it that way.
i have 2 rooms where there are 4 GUI10 bulbs grouped together to make 1 “light” for the room. the others rooms have a single bulb.
for the grouped bulbs there is never an instance where only “some” of the bulbs are on, it’s an “all or nothing” situation.
the outcome i need is that i have an icon on the dashboard that shows me how many “lights” are on, so it telling me that 5 lights are on (when in actual fact there is only 1 “light” on (4 grouped lights) is wrong for the display output.
the first code you supplied still reports back 5, when all that is currently on is 1 group if lights (the group contains 4 bulbs) so that appears to be doing the same as my orginal code and reporting 4+1.
the code posted in the template editor produces this