Skip to content

Commit

Permalink
Merge pull request #11 from cerebrate/master
Browse files Browse the repository at this point in the history
Allows for customization of the row
  • Loading branch information
iantrich authored Jun 5, 2021
2 parents 0d00794 + 6aa95a4 commit 9d69bb2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ resources:
| type | string | **Required** | `custom:group-card`
| card | object | **Required** | Card object
| group | string | **Required** | The entity_id of a group
| row | object | Optional | The additional parameters to be added to each entity object to customize each row.
| entities_vars | object | optional | The entity variables depends of card type use and need to have same device_class

Card object
Expand Down Expand Up @@ -55,11 +56,16 @@ Show all with some exceptions:
group: group.lights
entities_vars:
type: light
```
```yaml
- type: custom:group-card
card:
type: entities
title: Group card
group: group.bedroom
row:
type: custom:light-entity-row
showColorPicker: true
type: vertical-stack
title: Temparatures
group: group.my_sensors
Expand Down
13 changes: 13 additions & 0 deletions group-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ class GroupCard extends HTMLElement {
const entities = hass.states[config.group].attributes['entity_id'];
if (!config.card.entities || config.card.entities.length !== entities.length ||
!config.card.entities.every((value, index) => value.entity === entities[index].entity)) {
if (!config.row) {
config.card.entities = entities;
}
else {
const fmtentities = [];
entities.forEach (function (item) {
const stateObj = new Object;
for (var k in config.row)
stateObj[k]=config.row[k];
stateObj.entity = item;
fmtentities.push (stateObj);
});
config.card.entities = fmtentities;
if (config.card.type == "entities" || config.card.type == "glance") {
config.card.entities = entities;
} else {
Expand Down

0 comments on commit 9d69bb2

Please sign in to comment.