I know I’m late to the game but is there any way at all to know when the database migration is complete?
I updated 5 hours ago and my history is still locked up completely. So I don’t know if it’s still working on something or just locked up and I should restart.
It really would be nice if there was some kind of “complete” message when it was done.
Mine took at least ~8 hours (3GB) and i never saw anything indicating it was completed. But I didn’t look in the log specifically for it since there was a pop up notification that the db migration started and not to restart until it was done so I assumed it should have popped up another notification that it was done. Nobody should need to look for a random log entry for something like that.
the only way I was confident that it was done was that all my history graphs came back.
Upsttairs: {{ expand('light.upstairs_lights') | list | count }}
Downstairs: {{ expand('light.downstairs_lights') | list | count }}
outside: {{ expand('light.outside_lights') | list | count }}
All: {{ expand('light.all_lights') | list | count }}
I have groups for upstairs, downstairs, and outside. the all lights group contains these groups and the expand does iterate through all of them:
Upsttairs: 16
Downstairs: 11
outside: 4
All: 31
EDIT: just saw @pedolsky detail and i completely missed that bit about counting the group as one light without expanding. i tried it with the hide members option, but it still expanded the groups.
EDIT part deux: @123 is right, i just had an error in my template:
Upsttairs: {{ expand('light.upstairs_lights') | list | count }}
Downstairs: {{ expand('light.downstairs_lights') | list | count }}
outside: {{ expand('light.outside_lights') | list | count }}
All: {{ expand('light.all_lights') | list | count }}
ALL - @123: {{ state_attr('light.all_lights', 'entity_id') | list | count }}
I’m not following what you’re saying because the template I posted doesn’t use expand.
I tested it by creating a Switch Group containing two switches and another Switch Group (which contains two other switches). The resulting Switch Group’s entity_id contains three entities (not five) and 3 is the count produced by the template.
Hard for me to comment because I don’t know what you were trying to achieve.
Your examples employ expand which recursively expands all nested groups. If you want a count of all entities in all nested groups, you would use expand. If you don’t want nested groups to be expanded, your template cannot employ expand.
EDIT
Here’s the PR that modified the behavior of expand.
Expand’s inability to expand nested groups was reported in this Issue:
It was considered to be a bug. FWIW, I feel it probably should have been reported as a Breaking Change in the Release Notes because its new behavior is significantly different from previous versions. However, the modification was probably overlooked and didn’t get documented.
Have pity on my lousy language skills I meant this comment:
I tested it with an old-style group containing single lights, a Hue group and one HA light group. I also haven’t found a solution to only count the members of the group.
In Developer Tools → States find your old-style group entity and look at its entity_id attribute. The number of entities shown in its entity_id attribute will be the count returned by the template I posted.
I’ll go search if you don’t know, but in case you do: Do you know whether introducing a parameter to control the depth was considered? Looks to me like what should’ve been done, because that way a default could’ve been specified to keep the current behaviour the same while introducing useful new functionality.
So the problem is your light group has light groups and you do not want it to recursively expand is that the gist? Yes in that case you won’t be able to use expand in this spot anymore. expand always recursively expanded group entities but did not recursively expand other types of groups (like light groups for example). Now all groups work the same with expand which is more consistent and less confusing but appears to be an issue for you.
I think your best solution here is now this:
{% set ns = namespace(on_lights=0) %}
{% for light in state_attr('group.all_lights', 'entity_id') if is_state(light, 'on') %}
{% set ns.on_lights = ns.on_lights + 1 %}
{% endfor %}
{{ ns.on_lights }}