Skip to content

Commit

Permalink
Fix #49: Dropdown selector entity in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
danimart1991 authored Feb 5, 2023
1 parent 15e6f8a commit 37d7a8d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ You could use [HACS](https://hacs.xyz/) or follow this [guide](https://www.danie

```yaml
resources:
url: /local/pvpc-hourly-pricing-card.js?v=1.8.0
url: /local/pvpc-hourly-pricing-card.js?v=1.9.0
type: module
```
Expand Down
38 changes: 21 additions & 17 deletions dist/pvpc-hourly-pricing-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class PVPCHourlyPricingCard extends LitElement {
${this.ll('from')} ${maxPriceFrom} ${this.ll('to')} ${maxPriceTo}
</li>
${this.despiction.minPriceNextDay
? html` <li>
? html` <li>
<ha-icon icon="mdi:thumb-up-outline"></ha-icon>
${this.ll('minPriceNextDay')}
${minPriceNextDay}${this.pvpcHourlyPricingObj.attributes.unit_of_measurement} ${this.ll('from')}
Expand All @@ -353,7 +353,7 @@ class PVPCHourlyPricingCard extends LitElement {
${maxPriceNextDay}${this.pvpcHourlyPricingObj.attributes.unit_of_measurement} ${this.ll('from')}
${maxPriceFromNextDay} ${this.ll('to')} ${maxPriceToNextDay}
</li>`
: ''}
: ''}
</ul>
`;
}
Expand Down Expand Up @@ -777,10 +777,6 @@ export class PVPCHourlyPricingCardEditor extends LitElement {

this.lang = this.hass.selectedLanguage || this.hass.language;

const entities = Object.keys(this.hass.states).filter((eid) =>
Object.keys(this.hass.states[eid].attributes).some((aid) => aid == 'attribution')
);

return html`
<div class="card-config">
<div class="side-by-side">
Expand All @@ -793,17 +789,25 @@ export class PVPCHourlyPricingCardEditor extends LitElement {
</paper-input>
</div>
<div class="side-by-side">
<paper-dropdown-menu
label="${this.ll('optionEntity')}"
@value-changed="${this._valueChanged}"
.configValue="${'entity'}"
>
<paper-listbox slot="dropdown-content" .selected="${entities.indexOf(this._entity)}">
${entities.map((entity) => {
return html` <paper-item>${entity}</paper-item> `;
})}
</paper-listbox>
</paper-dropdown-menu>
${customElements.get("ha-entity-picker")
? html`
<ha-entity-picker
.hass="${this.hass}"
.value="${this._entity}"
.configValue=${"entity"}
@change="${this._valueChanged}"
allow-custom-entity
></ha-entity-picker>
`
: html`
<paper-input
label="${this.ll('optionEntity')}"
.value="${this._entity}"
.configValue="${"entity"}"
@value-changed="${this._valueChanged}"
></paper-input>
`
}
</div>
<div class="side-by-side">
<div>
Expand Down

0 comments on commit 37d7a8d

Please sign in to comment.