Skip to content

Commit

Permalink
Cleanup list of entities for selects.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrBearPresident committed Jan 25, 2025
1 parent 40cbd54 commit a34e851
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/cards/select/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function renderSelectEditor(editor){
<div class="card-config">
${editor.makeDropdown("Card type", "card_type", editor.cardTypeList)}
<ha-form
.hass=${editor.inputSelectList2}
.hass=${editor.inputSelectList}
.data=${editor._config}
.schema=${[
{ name: "entity",
Expand Down
22 changes: 10 additions & 12 deletions src/editor/bubble-card-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,23 @@ class BubbleCardEditor extends LitElement {
value: item
});

this.inputSelectList = Object.keys(this.hass.states)
this.inputSelectList = {states:{}, locale : this.hass.locale, localize : this.hass.localize, entities : this.hass.entities };

Object.keys(this.hass.states)
.filter((eid) => {
const entity = this.hass.states[eid];
const domain = eid.substr(0, eid.indexOf("."));
const isSelectDomain = domain === "input_select" || domain === "select";
const hasSelectableAttributes = this._selectable_attributes.some(attr => entity.attributes?.[attr]);
return isSelectDomain || hasSelectableAttributes;
})
.map(formateList);

this.inputSelectList2 = {states:{}, locale : this.hass.locale, localize : this.hass.localize, entities : this.hass.entities };

this.inputSelectList.forEach((item) => {
const entityId = item.label || item;
const entity = this.hass.states[entityId]; // Retrieve the corresponding state from hass.states
if (entity) {
this.inputSelectList2.states[entityId] = entity;
}
});
.map(formateList).forEach((item) => {
const entityId = item.label || item;
const entity = this.hass.states[entityId]; // Retrieve the corresponding state from hass.states
if (entity) {
this.inputSelectList.states[entityId] = entity;
}
});

this.attributeList = Object.keys(this.hass.states[this._entity]?.attributes || {}).map((attributeName) => {
let entity = this.hass.states[this._entity];
Expand Down

0 comments on commit a34e851

Please sign in to comment.