From fb56e8621b36cdbb54f790d0a1c9feeac26a68bc Mon Sep 17 00:00:00 2001 From: kalhimeo Date: Tue, 20 Jul 2021 20:47:30 +0200 Subject: [PATCH 1/5] Try to fix volume_entity at activity level Using volume_entity at activity level does not override card volume_entity as per order of precedence --- src/harmony-card.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/harmony-card.ts b/src/harmony-card.ts index 389581d..8ecb241 100644 --- a/src/harmony-card.ts +++ b/src/harmony-card.ts @@ -91,15 +91,13 @@ export class HarmonyCard extends LitElement { } } - protected volumeCommand(e, command: string, attributes?: any) { + protected volumeCommand(e, volumeMediaPlayer: string, command: string, attributes?: any) { this.preventBubbling(e); - if (this._config?.volume_entity) { + var baseAttributes = { entity_id: volumeMediaPlayer }; - var baseAttributes = { entity_id: this._config?.volume_entity }; - - this.hass?.callService("media_player", command, Object.assign(baseAttributes, attributes || {})); - } + this.hass?.callService("media_player", command, Object.assign(baseAttributes, attributes || {})); + } protected shouldUpdate(changedProps: PropertyValues): boolean { @@ -309,8 +307,8 @@ export class HarmonyCard extends LitElement { return html``; } - - private renderMediaPlayerVolumeControls(hass: HomeAssistant, volumeMediaPlayer: string, buttonConfig: { [key: string]: HarmonyButtonConfig }) { + + private renderMediaPlayerVolumeControls(hass: HomeAssistant, volumeMediaPlayer: string, buttonConfig: { [key: string]: HarmonyButtonConfig }) { var volume_state = hass.states[volumeMediaPlayer]; var volume = volume_state.attributes.volume_level; @@ -322,10 +320,10 @@ export class HarmonyCard extends LitElement { return html`
- - + + this.volumeCommand(e, 'volume_set', { volume_level: e.target.value / 100 })} + @change=${e => this.volumeCommand(e, volumeMediaPlayer, 'volume_set', { volume_level: e.target.value / 100 })} @click=${e => e.stopPropagation()} @touchstart="${e => this.preventBubbling(e)}" ?disabled=${muted} @@ -335,7 +333,7 @@ export class HarmonyCard extends LitElement { ignore-bar-touch pin> - +
`; } From 41d91acd3cd7e57d21c8909837d41b2905908bf9 Mon Sep 17 00:00:00 2001 From: kalhimeo Date: Tue, 20 Jul 2021 22:43:10 +0200 Subject: [PATCH 2/5] Update harmony-card.ts --- src/harmony-card.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/harmony-card.ts b/src/harmony-card.ts index 8ecb241..118cb79 100644 --- a/src/harmony-card.ts +++ b/src/harmony-card.ts @@ -97,7 +97,9 @@ export class HarmonyCard extends LitElement { var baseAttributes = { entity_id: volumeMediaPlayer }; this.hass?.callService("media_player", command, Object.assign(baseAttributes, attributes || {})); - + + + } protected shouldUpdate(changedProps: PropertyValues): boolean { @@ -307,8 +309,8 @@ export class HarmonyCard extends LitElement { return html``; } - - private renderMediaPlayerVolumeControls(hass: HomeAssistant, volumeMediaPlayer: string, buttonConfig: { [key: string]: HarmonyButtonConfig }) { + + private renderMediaPlayerVolumeControls(hass: HomeAssistant, volumeMediaPlayer: string, buttonConfig: { [key: string]: HarmonyButtonConfig }) { var volume_state = hass.states[volumeMediaPlayer]; var volume = volume_state.attributes.volume_level; From c3b3e006c307aab3b8e08fb3cdcea9de54fee80d Mon Sep 17 00:00:00 2001 From: kalhimeo Date: Fri, 23 Jul 2021 11:32:44 +0200 Subject: [PATCH 3/5] Update harmony-card.ts --- src/harmony-card.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harmony-card.ts b/src/harmony-card.ts index 118cb79..503a065 100644 --- a/src/harmony-card.ts +++ b/src/harmony-card.ts @@ -1,4 +1,4 @@ -import { LitElement, html, customElement, property, TemplateResult, css, PropertyValues } from 'lit-element'; + import { LitElement, html, customElement, property, TemplateResult, css, PropertyValues } from 'lit-element'; import { HomeAssistant, hasAction, From faf0e35cc92a5dbfea6848042534845d1081f6f5 Mon Sep 17 00:00:00 2001 From: kalhimeo Date: Fri, 23 Jul 2021 11:34:47 +0200 Subject: [PATCH 4/5] Fix order of precedence for volume_entity Using volume_entity at activity level was not overriding the card volume_entity as per order of precedence --- src/harmony-card.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harmony-card.ts b/src/harmony-card.ts index 503a065..118cb79 100644 --- a/src/harmony-card.ts +++ b/src/harmony-card.ts @@ -1,4 +1,4 @@ - import { LitElement, html, customElement, property, TemplateResult, css, PropertyValues } from 'lit-element'; +import { LitElement, html, customElement, property, TemplateResult, css, PropertyValues } from 'lit-element'; import { HomeAssistant, hasAction, From f7be25a1ee39f0d8028666c27edae45bbe4d3510 Mon Sep 17 00:00:00 2001 From: kalhimeo Date: Thu, 4 Nov 2021 23:30:56 +0100 Subject: [PATCH 5/5] Fix icon not showing on HA 2021.11 use new --- src/harmony-card.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/harmony-card.ts b/src/harmony-card.ts index 118cb79..849351b 100644 --- a/src/harmony-card.ts +++ b/src/harmony-card.ts @@ -235,7 +235,8 @@ export class HarmonyCard extends LitElement { ?outlined="${outlined}" @click="${e => this.harmonyCommand(e, command)}" @touchstart="${e => this.preventBubbling(e)}" - > + > + ` : html` + @touchstart="${e => this.preventBubbling(e)}" + > `; } @@ -322,8 +324,8 @@ export class HarmonyCard extends LitElement { return html`
- - + + this.volumeCommand(e, volumeMediaPlayer, 'volume_set', { volume_level: e.target.value / 100 })} @click=${e => e.stopPropagation()} @@ -335,7 +337,7 @@ export class HarmonyCard extends LitElement { ignore-bar-touch pin> - +
`; }