Skip to content

Commit

Permalink
FIx #171
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasloven committed Mar 8, 2021
1 parent 989321e commit eb38683
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion auto-entities.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AutoEntities extends LitElement {
@property() card: LovelaceCard;
@property() _template: string[];
_entities: EntityList;
_renderer;
//_renderer;
_cardConfig;
_updateCooldown = { timer: undefined, rerun: false };
_cardBuilt?: Promise<void>;
Expand Down Expand Up @@ -70,7 +70,6 @@ class AutoEntities extends LitElement {
config = JSON.parse(JSON.stringify(config));
this._config = config;

this._renderer = (tpl) => (this._template = tpl);
if (
this._config.filter?.template &&
hasTemplate(this._config.filter.template)
Expand All @@ -85,6 +84,14 @@ class AutoEntities extends LitElement {
queueMicrotask(() => this.update_all());
}

_renderer = (tpl) => {
if (typeof tpl === "string") {
this._template = tpl.split(/[\s,]+/);
} else {
this._template = tpl;
}
};

connectedCallback() {
super.connectedCallback();
if (
Expand Down
3 changes: 3 additions & 0 deletions test/lovelace/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ cards:
'light.kitchen_lights',
{'entity': 'light.ceiling_lights', 'icon': 'mdi:lamp'}
] }}"
- <<: *card
filter:
template: "{{ 'light.bed_light, light.kitchen_lights, light.ceiling_lights'}}"

- type: vertical-stack
cards:
Expand Down

0 comments on commit eb38683

Please sign in to comment.