Skip to content

Custom badges#3867

Merged
bramkragten merged 17 commits into
home-assistant:devfrom
iantrich:custom-badges
Oct 16, 2019
Merged

Custom badges#3867
bramkragten merged 17 commits into
home-assistant:devfrom
iantrich:custom-badges

Conversation

@iantrich
Copy link
Copy Markdown
Member

@iantrich iantrich commented Oct 3, 2019

Closes #3896

    badges:
      - entity: sensor.yr_symbol
      - entity: binary_sensor.movement_backyard
        type: state-labels
      - type: entity-filter
        state_filter:
          - closed
        entities:
          - entity: cover.hall_window
          - entity: sensor.outside_humidity
            state_filter:
              - operator: <
                value: 55
      - entity: binary_sensor.basement_floor_wet
        type: state-label
      - entity: input_number.slider2
        type: state-label

Docs: home-assistant/home-assistant.io#10915

Allows for custom badges along with new entity-filter badge type.

@iantrich iantrich self-assigned this Oct 3, 2019
Comment thread src/data/lovelace.ts Outdated
Comment thread src/panels/lovelace/common/create-badge-element.ts Outdated
@bramkragten
Copy link
Copy Markdown
Member

Woehoe! entity button badge 😛
image

I can see some nice (ab)use for this, clock badge, weather forecast badge, scene choose badge, ...

Comment thread src/panels/lovelace/badges/hui-entity-filter-badge.ts Outdated
Comment thread src/panels/lovelace/badges/hui-entity-filter-badge.ts
Comment thread src/panels/lovelace/badges/hui-entity-filter-badge.ts
Comment thread src/panels/lovelace/badges/hui-error-badge.ts Outdated
Comment thread src/panels/lovelace/common/create-badge-element.ts Outdated
Comment thread src/panels/lovelace/views/hui-view.ts Outdated
Comment thread src/panels/lovelace/views/hui-view.ts Outdated
@iantrich iantrich mentioned this pull request Oct 4, 2019
@iantrich
Copy link
Copy Markdown
Member Author

iantrich commented Oct 4, 2019

I'll write up docs once I'm sure everyone is on-board with the changes

Comment thread src/data/lovelace.ts Outdated
Comment thread src/panels/lovelace/badges/hui-state-label-badge.ts Outdated
Comment thread src/panels/lovelace/badges/hui-entity-filter-badge.ts Outdated
Comment thread src/panels/lovelace/common/create-badge-element.ts Outdated
Comment thread src/panels/lovelace/common/create-badge-element.ts
Comment thread src/panels/lovelace/editor/view-editor/hui-edit-view.ts
Comment thread src/data/lovelace.ts
Comment thread src/panels/lovelace/views/hui-view.ts Outdated
Comment thread src/panels/lovelace/views/hui-view.ts
@iantrich
Copy link
Copy Markdown
Member Author

@frenck I'm going to need some help with the doc changes on this. I need to add a new section to the lovelace navigation for badge types. I see that lovelace_navigation.html has that, but not sure how I populate the list of badges like cards currently is.
{% assign cards = site.lovelace | sort_natural: 'title' %}

@bramkragten
Copy link
Copy Markdown
Member

Have you also tested the code with custom badges? Does the rebuild etc. work?

@@ -96,11 +96,7 @@ export class HUIView extends LitElement {
element.addEventListener(
"ll-badge-rebuild",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just use the same event we use for cards here, instead of a separate one for badges?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to rebuild cards if we don't have to?

@iantrich
Copy link
Copy Markdown
Member Author

Have you also tested the code with custom badges? Does the rebuild etc. work?

Only with internal cards as custom, e.g. custom;hui-entity-button-card

@bramkragten
Copy link
Copy Markdown
Member

Have you also tested the code with custom badges? Does the rebuild etc. work?

Only with internal cards as custom, e.g. custom;hui-entity-button-card

But they will always exist, can you check a custom custom one?

@iantrich
Copy link
Copy Markdown
Member Author

Have you also tested the code with custom badges? Does the rebuild etc. work?

Only with internal cards as custom, e.g. custom;hui-entity-button-card

But they will always exist, can you check a custom custom one?

Just tested custom:button-card and works great

@bramkragten bramkragten merged commit c9242a5 into home-assistant:dev Oct 16, 2019
@iantrich
Copy link
Copy Markdown
Member Author

I still need docs for this and not sure how to format them yet

@bramkragten
Copy link
Copy Markdown
Member

bramkragten commented Oct 16, 2019

You've 1 week 😜

@shack31b
Copy link
Copy Markdown

Do I get this wrong or is the entity-filter on badges in views not possible?
So you have to add the badges to a card if you want to hide them depending on their states?
I try to figure out how to hide a device_tracker entity if it's not home and I think this is very common to others...

@github-actions github-actions Bot locked and limited conversation to collaborators Jul 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add filter for view badges

6 participants