Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using 'source' for app icon #759

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JeffersonBledsoe
Copy link

Description

This PR allows integrations which use source rather than app_name to be given an app icon

Related Issue

Closes #758

Motivation and Context

Users may not want to use the full app picture but instead have an icon that fits in with the HA UI so they can use the icon. Some integrations didn't provide an app_name attribute for this, but instead uses source

How Has This Been Tested

Locally using the instructions in README.md to develop against HA.

Types of changes

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 🌎 Translation (addition or update a translation)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have tested the change locally.

Comment on lines +96 to +101
Object.keys(mediaIconMapping).forEach((attribute) => {
var app = entity.attributes[attribute]?.toLowerCase();
if (app) {
icon = mediaIconMapping[attribute][app];
}
});
Copy link
Owner

@piitaya piitaya Oct 11, 2022

Choose a reason for hiding this comment

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

It's not clear about the rules priority because it depends of the order of the attributes.
I think we can do like this (I just wrote a pseudo code but you got the idea 🙂)

for each app_name
    if app_name === entity.attribute.app_name:
           return app_name icon
for each source
    if app_name === entity.attribute.source:
           return source icon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Media card doesn't use the 'source' attribute for it's media info
2 participants