Skip to content

Commit

Permalink
fix syntax error
Browse files Browse the repository at this point in the history
  • Loading branch information
iantrich committed Jun 12, 2021
1 parent 991a418 commit a5e69ab
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions group-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class GroupCard extends HTMLElement {
const cardConfig = Object.assign({}, config);
if (!cardConfig.card) cardConfig.card = {};
if (!cardConfig.card.type) cardConfig.card.type = 'entities';
if (!cardConfig.entities_vars) cardConfig.entities_vars = {type: 'entity'};
if (!cardConfig.entities_vars) cardConfig.entities_vars = { type: 'entity' };
const element = document.createElement(`hui-${cardConfig.card.type}-card`);
this.appendChild(element);
this._config = JSON.parse(JSON.stringify(cardConfig));
}

set hass(hass) {
const config = this._config;
if (!hass.states[config.group]){
if (!hass.states[config.group]) {
throw new Error(`${config.group} not found`);
}
const entities = hass.states[config.group].attributes['entity_id'];
Expand All @@ -26,29 +26,31 @@ class GroupCard extends HTMLElement {
if (!config.row) {
config.card.entities = entities;
}
else {
else {
const fmtentities = [];
entities.forEach (function (item) {
entities.forEach(function (item) {
const stateObj = new Object;
for (var k in config.row)
stateObj[k]=config.row[k];
stateObj[k] = config.row[k];
stateObj.entity = item;
fmtentities.push (stateObj);
fmtentities.push(stateObj);
});
config.card.entities = fmtentities;
if (config.card.type == "entities" || config.card.type == "glance") {
config.card.entities = entities;
} else {
config.card.cards = []
for(const entity of entities){
const card = JSON.parse(JSON.stringify(config.entities_vars));
card.entity = entity
config.card.cards.push(card)
if (config.card.type == "entities" || config.card.type == "glance") {
config.card.entities = entities;
} else {
config.card.cards = []
for (const entity of entities) {
const card = JSON.parse(JSON.stringify(config.entities_vars));
card.entity = entity
config.card.cards.push(card)
}
}
}

this.lastChild.setConfig(config.card);
this.lastChild.hass = hass;
}
this.lastChild.setConfig(config.card);
this.lastChild.hass = hass;
}

getCardSize() {
Expand Down

0 comments on commit a5e69ab

Please sign in to comment.