Skip to content

Commit

Permalink
updates to improve sync with other card
Browse files Browse the repository at this point in the history
  • Loading branch information
punxaphil committed Dec 5, 2024
1 parent 4af0648 commit a098305
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Sonos Card for Home Assistant UI with a focus on managing multiple media players
* Configurable styling
* Dynamic volume level slider
* Track progress bar
* Show, play and remove tracks of play queue
* Set and clear sleep timer
* Show, play and remove tracks of play queue <!-- //#ONLY_SONOS_CARD -->
* Set and clear sleep timer <!-- //#ONLY_SONOS_CARD -->

and more!

Expand All @@ -26,7 +26,7 @@ and more!
![groups.png](https://github.com/punxaphil/custom-sonos-card/raw/main/img/groups.png)
![grouping.png](https://github.com/punxaphil/custom-sonos-card/raw/main/img/grouping.png)
![volumes.png](https://github.com/punxaphil/custom-sonos-card/raw/main/img/volumes.png)
![queue.png](https://github.com/punxaphil/custom-sonos-card/raw/main/img/queue.png)
![queue.png](https://github.com/punxaphil/custom-sonos-card/raw/main/img/queue.png) <!-- //#ONLY_SONOS_CARD -->

## Support the project

Expand Down Expand Up @@ -115,8 +115,8 @@ sections: # see explanation further up
- grouping
- media browser
- player
- queue
startSection: queue # default is player. Use this to set the default section to show.
- queue <!-- //#ONLY_SONOS_CARD -->
startSection: queue # default is player. Use this to set the default section to show. <!-- //#ONLY_SONOS_CARD -->
widthPercentage: 75 # default is 100. Use this to change the width of the card.
heightPercentage: 75 # default is 100. Use this to change the height of the card. Set to 'auto' to make the card height adjust to the content.
footerHeight: 4 # default is 5. Unit is 'rem'. Use this to change the height of the footer.
Expand Down Expand Up @@ -245,8 +245,8 @@ mediaBrowserTitle: My favorites # default is 'All favorites'. Use this to change
# volumes specific
hideVolumeCogwheel: true # default is false. Will hide the cogwheel for the volumes section.

# queue specific
queueTitle: Songs # default is 'Play Queue'. Use this to change the title for the queue section.
# queue specific <!-- //#ONLY_SONOS_CARD -->
queueTitle: Songs # default is 'Play Queue'. Use this to change the title for the queue section. <!-- //#ONLY_SONOS_CARD -->
```
## Using individual section cards
Expand Down
2 changes: 1 addition & 1 deletion copy-to-maxi-media-player.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ find ../maxi-media-player -name "*" \
-not -path "*/node_modules/*" \
-not -path "*/coverage/*" -type f \
-exec gsed -i '/\/\/#ONLY_SONOS_CARD_START/,/\/\/#ONLY_SONOS_CARD_END/d' {} \; \
-exec gsed -i 's/.*#ONLY_SONOS_CARD.*//g' {} \; \
-exec gsed -i ':a;N;$!ba;s/[^\n]*#ONLY_SONOS_CARD[^\n]*\n//g' {} \; \
-exec gsed -i "s/'sonos-card'/'maxi-media-player'/g" {} \; \
-exec gsed -i "s/'Sonos'/'Maxi Media Player'/g" {} \; \
-exec gsed -i 's/custom-sonos-card/maxi-media-player/g' {} \; \
Expand Down
1 change: 1 addition & 0 deletions src/editor/advanced-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const ADVANCED_SCHEMA = [
{
name: 'queueTitle',
type: 'string',
cardType: 'sonos',
},
{
name: 'artworkHostname',
Expand Down
2 changes: 2 additions & 0 deletions src/editor/base-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ export abstract class BaseEditor extends LitElement {
return this.dispatchEvent(new CustomEvent('closed'));
}
}

export type Schema = { cardType: string; [name: string]: unknown };
12 changes: 9 additions & 3 deletions src/editor/form.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { html, TemplateResult } from 'lit';
import { BaseEditor } from './base-editor';
import { BaseEditor, Schema } from './base-editor';
import { property } from 'lit/decorators.js';

class Form extends BaseEditor {
@property({ attribute: false }) schema!: unknown;
@property({ attribute: false }) schema!: Schema[];
@property({ attribute: false }) data!: unknown;
@property() changed!: (ev: CustomEvent) => void;

protected render(): TemplateResult {
const schema = filterEditorSchemaOnCardType(this.schema, this.config.type);
return html`
<ha-form
.data=${this.data || this.config}
.schema=${this.schema}
.schema=${schema}
.computeLabel=${computeLabel}
.hass=${this.hass}
@value-changed=${this.changed || this.valueChanged}
Expand All @@ -36,4 +38,8 @@ export function computeLabel({ help, label, name }: { name: string; help: string
return unCamelCased + (help ? ` (${help})` : '');
}

function filterEditorSchemaOnCardType(schema: Schema[], cardType: string) {
return schema.filter((schema) => schema.cardType === undefined || cardType.indexOf(schema.cardType) > -1);
}

customElements.define('sonos-card-editor-form', Form);

0 comments on commit a098305

Please sign in to comment.