conditional cards do tend to take spaces, even as separate cards…
my issue above however is new since this week, and I believe it to coincide with the many updates of auto-entities. I didnt notice it after updating Ha itself to either of the 2021.3 versions (but might be wrong there, just didnt notice it)
Nothing else in that card config changed. there’s an older post of mine here too show the gapless way it was before:
Your issue sounds like what my issue was. For me 1.8.3 has fixed it. Make sure you clear caches and reload page a few times. Sometimes it can get stuck to older version in the browser, even after multiple reloads. Closing other browsers can help. Or uninstall card, delete from resources, reboot HA, install again and add as resource, restart HA again and then reload browser.
Make sure it says this in your browser console, keep trying till it does and then test it.
Deleted all cards using auto entities. Removed and reinstalled auto-entities. After start-up, following message was recorded: 12:38:58.063 AUTO-ENTITIES 1.8.3 IS INSTALLED auto-entities.js:194:5516. No errors found. Using auto-entities again without embedded custom:fold-entity-row, functioned properly. Including custom:fold-entity-row back again made lovelace card disappear and resulted in error message: 13:17:40.477 TypeError: r is undefined auto-entities.js:1:27664.
Using the auto-entities.js hyperlink as shown in console delivered the following highlighted pointer:
function t(t,e,i,n){var s,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if(“object”==typeof Reflect&&“function”==typeof …etc
But the batteries must be sorted by “charge level”.
This is an easy task if using “filter / include / …” method.
But here I gonna use a “filter / template” method:
type: 'custom:auto-entities'
card:
type: entities
title: Batteries
entities:
- type: section
label: Some title
unique: entity
show_empty: true
filter:
template: |
{% for state in states.sensor -%}
{%- if state.entity_id | regex_match('sensor.battery_',ignorecase=False) -%}
{{
{ 'entity': state.entity_id,
'secondary_info': 'last-changed'
} }},
{%- endif -%}
{%- endfor %}
sort:
method: state
reverse: false
ignore_case: false
attribute: null
first: 0
count: 1000
numeric: true
Now the question is - how to sort this list?
The code provided above gives this picture:
I am not sure what has happened. But, today my sensors are sorting in reverse order on my browser and the correct/normal order on my tablet. Using 1.8.4. Any ideas?
template: |
{% for state in states.sensor|sort(reverse=false,attribute="state") -%}
{%- if state.entity_id | regex_match('sensor.battery_',ignorecase=False) -%}
{{
{ 'entity': state.entity_id,
'secondary_info': 'last-changed'
} }},
{%- endif -%}
{%- endfor %}
But:
Sort is made for “strings”, so the result is “100%, 14%, 20%, 90%”.
Is it possible to sort it is numbers?
P.S.
A bit simpler way (w/o "secondary_info") - filter by “device_class” (may not be 100% useful in some particular setup) - with "sort", and it does not sort properly too 'cause it sorts strings instead of numbers:
of course ymmv, but, depending on the states and auto-entities cards you have, continuous evaluating of states in the states machine might be very costly. especially since these are done in the back-end and not in the browser?
suggestion: auto create a group at startup with the same template and have the auto-entities card use the group for filter?
automation:
- alias: Create battery group
trigger:
platform: homeassistant
event: start
action:
service: group.set
data:
object_id: battery_sensors
entities: >-
{%- for s in states.sensor
if ('battery_level' in s.entity_id or
'motion_sensor_battery' in s.entity_id)%}
{{s.entity_id}}{% if not loop.last %}, {% endif %}
{%- endfor %}