Skip to content

Commit

Permalink
Merge pull request #461 from Barma-lej/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Barma-lej authored Oct 31, 2024
2 parents 3f7fa19 + a04ec5e commit 6e30b29
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/landroid-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class LandroidCard extends LitElement {
* @return {string[]} The list of entities to be displayed as settings in the card.
*/
get settingsEntity() {
return this.config?.settings ?? [];
return this.config?.settings ?? null;
}

/**
Expand Down Expand Up @@ -323,14 +323,16 @@ class LandroidCard extends LitElement {
}
}


/**
* Indicates if any of the settings entities have changed.
*
* @param {Map} changedProperties - Map of changed properties.
* @return {boolean} True if any of the settings entities have changed, false otherwise.
*/
settingsEntityChanged(changedProperties) {
if (!this.settingsEntity) {
return false;
}
for (const entityId of this.settingsEntity) {
const previousState = changedProperties.get('hass')?.states[entityId]?.state;
const currentState = this.hass.states[entityId]?.state;
Expand Down Expand Up @@ -505,7 +507,7 @@ class LandroidCard extends LitElement {
findEntitiesBySuffixes(suffixes) {
return suffixes.reduce((result, suffix) => {
const entitiesWithSuffix = Object.values(this.associatedEntities).filter(
(entity) => entity && entity.state !== 'unavailable' && entity.entity_id.endsWith(suffix)
(entity) => entity && entity.state !== consts.UNAVAILABLE && entity.entity_id.endsWith(suffix)
);
return result.concat(entitiesWithSuffix);
}, []);
Expand All @@ -519,13 +521,13 @@ class LandroidCard extends LitElement {
* @return {string[]} An array of matching entity IDs.
*/
findEntitiesIdBySuffixes(suffixes) {
return suffixes.reduce((entityIds, suffix) => {
const filteredEntities = Object.values(this.associatedEntities).filter(
(entity) => entity && entity.state !== 'unavailable' && entity.entity_id.endsWith(suffix)
);
return entityIds.concat(filteredEntities.map(entity => entity.entity_id));
}, []);
// return this.findEntitiesBySuffixes(suffixes).map(entity => entity.entity_id);
// return suffixes.reduce((entityIds, suffix) => {
// const filteredEntities = Object.values(this.associatedEntities).filter(
// (entity) => entity && entity.state !== consts.UNAVAILABLE && entity.entity_id.endsWith(suffix)
// );
// return entityIds.concat(filteredEntities.map(entity => entity.entity_id));
// }, []);
return this.findEntitiesBySuffixes(suffixes).map(entity => entity.entity_id);
}

/**
Expand Down Expand Up @@ -793,7 +795,7 @@ return html`
${this.renderButtonsForState(state)}
<div class="fill-gap"></div>
${this.renderShortcuts()}
${this.config.settings
${this.settingsEntity
? html`
<ha-icon-button
label="${localize('action.config')}"
Expand Down

0 comments on commit 6e30b29

Please sign in to comment.