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

Override icon with an image URL #639

Merged
merged 4 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Inspired by [Custom UI: Mini media player](https://community.home-assistant.io/t
| entity | string | **required** | v0.1 | An entity_id from an entity within the `media_player` domain.
| name | string | optional | v0.6 | Override the entities friendly name.
| icon | string | optional | v0.1 | Specify a custom icon from any of the available mdi icons.
| icon_image | string | optional | v1.16.2 | Override icon with an image url
| tap_action | [action object](#action-object-options) | true | v0.7.0 | Action on click/tap.
| group | boolean | optional | v0.1 | Removes paddings, background color and box-shadow.
| hide | object | optional | v1.0.0 | Manage visible UI elements, see [hide object](#hide-object) for available options.
Expand Down
1 change: 1 addition & 0 deletions src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export interface MiniMediaPlayerBaseConfiguration {
entity: string;
name?: string;
icon?: string;
icon_image?: string;
tap_action?: MiniMediaPlayerAction;
group?: boolean;
hide?: MiniMediaPlayerHideConfiguration;
Expand Down
7 changes: 7 additions & 0 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ export default class MiniMediaPlayerEditor extends LitElement {
.configValue="${'icon'}"
@value-changed=${this.valueChanged}
></paper-input>

<paper-input
label="Icon Image"
.value="${this._config.icon_image}"
.configValue="${'icon_image'}"
@value-changed=${this.valueChanged}
></paper-input>
</div>

<div class="editor-side-by-side">
Expand Down
6 changes: 6 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ class MiniMediaPlayer extends LitElement {
</div>`;
}

if (this.config.icon_image != undefined){
return html` <div class="entity__icon">
<img src="${this.config.icon_image}" height=25/>
</div>`;
}

const active = !this.config.hide.icon_state && this.player.isActive;
return html` <div class="entity__icon" ?color=${active}>
<ha-icon .icon=${this.computeIcon()}></ha-icon>
Expand Down