mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-07 18:09:47 +00:00
Add exclude attributes support to attribute selector (#13421)
* Add exclude attribute support to attribute selector * Fix typing * Fix rebase f-up * Revert const removal * Make exclude_attributes readonly and fix some propert mismatches Co-authored-by: Zack <zackbarett@hey.com> Co-authored-by: Steve Repsher <steverep@users.noreply.github.com>
This commit is contained in:
@@ -15,6 +15,14 @@ class HaEntityAttributePicker extends LitElement {
|
||||
|
||||
@property() public entityId?: string;
|
||||
|
||||
/**
|
||||
* List of attributes to be excluded.
|
||||
* @type {Array}
|
||||
* @attr exclude-attributes
|
||||
*/
|
||||
@property({ type: Array, attribute: "exclude-attributes" })
|
||||
public excludeAttributes?: string[];
|
||||
|
||||
@property({ type: Boolean }) public autofocus = false;
|
||||
|
||||
@property({ type: Boolean }) public disabled = false;
|
||||
@@ -42,10 +50,12 @@ class HaEntityAttributePicker extends LitElement {
|
||||
if (changedProps.has("_opened") && this._opened) {
|
||||
const state = this.entityId ? this.hass.states[this.entityId] : undefined;
|
||||
(this._comboBox as any).items = state
|
||||
? Object.keys(state.attributes).map((key) => ({
|
||||
value: key,
|
||||
label: formatAttributeName(key),
|
||||
}))
|
||||
? Object.keys(state.attributes)
|
||||
.filter((key) => !this.excludeAttributes?.includes(key))
|
||||
.map((key) => ({
|
||||
value: key,
|
||||
label: formatAttributeName(key),
|
||||
}))
|
||||
: [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user