Closed martindybal closed 1 month ago
I found solution for simple cases with one entity. But how to filter badges with multiple entities? Like this binary_sensor.reedcontact_104_balcony_door
and binary_sensor.reedcontact_104_balcony_door_ventilation
.
type: entity-filter
entities:
- type: custom:mushroom-template-badge
entity: binary_sensor.reedcontact_104_balcony_door
color: >-
{% if is_state('binary_sensor.reedcontact_104_balcony_door', 'on') %}
#FF0000
{% elif is_state('binary_sensor.reedcontact_104_balcony_door_ventilation',
'on') %}
#FFA500
{% else %}
#008000
{% endif %}
icon: >-
{% if is_state('binary_sensor.reedcontact_104_balcony_door', 'on') %}
mdi:window-open
{% elif is_state('binary_sensor.reedcontact_104_balcony_door_ventilation',
'on') %}
mdi:window-open
{% else %}
mdi:window-closed
{% endif %}
label: Balkonové dveře
content: >-
{% if is_state('binary_sensor.reedcontact_104_balcony_door', 'on') %}
Balkonové dveře otevřeno
{% elif is_state('binary_sensor.reedcontact_104_balcony_door_ventilation',
'on') %}
Balkonové dveře ventilace
{% else %}
Balkonové dveře zavřeno
{% endif %}
tap_action:
action: more-info
conditions:
- condition: state
state_not: 'off'
I'm not sure we can use this filter with the template badge. Entity filter is not compatible with other type of badges.
@piitaya My sample works, so we can :-). Only my template badge uses multiple entities, not just one.
Yes of course, you can do this :
type: entity-filter
entities:
- type: custom:mushroom-template-badge
entity: binary_sensor.reedcontact_104_balcony_door
color: >-
{% if is_state(entity, 'on') %}
#FF0000
{% else %}
#008000
{% endif %}
icon: >-
{% if is_state(entity, 'on') %}
mdi:window-open
{% else %}
mdi:window-closed
{% endif %}
label: Balkonové dveře
content: >-
{% if is_state(entity, 'on') %}
Balkonové dveře otevřeno
{% else %}
Balkonové dveře zavřeno
{% endif %}
tap_action:
action: more-info
- type: custom:mushroom-template-badge
entity: binary_sensor.reedcontact_104_balcony_door_ventilation
color: >-
{% if is_state(entity, 'on') %}
#FFA500
{% else %}
#008000
{% endif %}
icon: >-
{% if is_state(entity, 'on') %}
mdi:window-open
{% else %}
mdi:window-closed
{% endif %}
label: Balkonové dveře
content: >-
{% if is_state(entity, 'on') %}
Balkonové dveře ventilace
{% else %}
Balkonové dveře zavřeno
{% endif %}
tap_action:
action: more-info
conditions:
- condition: state
state_not: 'off'
But IMO, it's better to use only template badge with visibility option for this usecase.
@piitaya there Is a visibility for badge? That can fix my issue. Didn't find it in doc even in UI editor. https://github.com/piitaya/lovelace-mushroom/blob/main/docs/badges/template.md
The window can has two sensors and together they form three state information (open, ventilation, close). I want to show this in one badge, I don't want to see the ventilation and the open window in case of an open window.
But of course it could be solved by a virtual sensor. But visibility seems like the easiest option.
I'm closing the issue as it's closed on the frontend repository.
Requirements
Is your feature request related to a problem?
Home Assistant introduce new badges with great filter options. https://www.home-assistant.io/dashboards/badges/
type: entity-filter entities:
Describe the solution you'd like
I would love to use the filters with mushroom-template-badge. Is there a way how to combine it has to be implemented?
Describe alternatives you've considered
No response
Additional context
No response