lovelace-mushroom
lovelace-mushroom copied to clipboard
[Feature]: Badge numeric values
Requirements
- [X] I have updated Mushroom to the latest available version
- [X] I did a search to see if there is a similar issue or if a pull request is open.
Is your feature request related to a problem?
No
Describe the solution you'd like
Add sensor data (for example: number of lights on) in a badge instead of a icon
Describe alternatives you've considered
No response
Additional context
No response
Hereafter a solution based on icon for up to 9 elements (then display 9+)
Here looking to all the lights in a group in a template card:
{% set all = expand('group.lumieres_toutes')| list -%}
{% set open1 = all | selectattr('state','eq','on')|list|count%}
{% if open1 == 0 %}
mdi:numeric-0
{% elif open1 == 1 %}
mdi:numeric-1
{% elif open1 == 2 %}
mdi:numeric-2
{% elif open1 == 3 %}
mdi:numeric-3
{% elif open1 == 4 %}
mdi:numeric-4
{% elif open1 == 5 %}
mdi:numeric-5
{% elif open1 == 6 %}
mdi:numeric-6
{% elif open1 == 7 %}
mdi:numeric-7
{% elif open1 == 8 %}
mdi:numeric-8
{% elif open1 == 9 %}
mdi:numeric-9
{% elif open1 >= 9 %}
mdi:numeric-9-plus
{% else %}
none
{% endif %}
It might help for the time being...
Thanks @BBESINET I already used the 'numeric' badges, just hadn't thought of 9+.
I have now:
{% if states(entity) > '0' %}
mdi:numeric-{{ states(entity) }}
{% elif states(entity) > '9' %}
mdi:numeric-9-plus
{% endif %}
This works fine for now, but it would be nice if we could just fill this with sensor data.
Thanks .
I now improved mine with mdi:numeric-{{ states(entity) }}
instead of ten elif lines...
type: custom:mushroom-template-card
tap_action:
action: navigate
navigation_path: /lovelace/lights
fill_container: true
layout: vertical
entity: light.all_lights
icon: mdi:lightbulb-group
icon_color: '{{ state_attr(''light.all_lights'', ''rgb_color'') }}'
badge_icon: >
{% set numLightsOn = expand(state_attr('light.all_lights', 'entity_id')) |
selectattr('state', 'eq', 'on') | list | count %}
{%- if numLightsOn > 9 %}
mdi:numeric-9-plus
{%- elif numLightsOn == 0 %}
{%- else %}
mdi:numeric-{{ numLightsOn }}
{%- endif %}
badge_color: ''
primary: ''
picture: ''
secondary: ''
multiline_secondary: false