Merge pull request #12252 from spacegaier/issue-12246

This commit is contained in:
Zack Barett 2022-04-07 16:40:08 -05:00 committed by GitHub
commit 5a2cc2646c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import { fireEvent } from "../../common/dom/fire_event";
import { PolymerChangedEvent } from "../../polymer-types"; import { PolymerChangedEvent } from "../../polymer-types";
import { HomeAssistant } from "../../types"; import { HomeAssistant } from "../../types";
import "./ha-device-picker"; import "./ha-device-picker";
import type { HaDevicePickerDeviceFilterFunc } from "./ha-device-picker";
@customElement("ha-devices-picker") @customElement("ha-devices-picker")
class HaDevicesPicker extends LitElement { class HaDevicesPicker extends LitElement {
@ -13,6 +14,8 @@ class HaDevicesPicker extends LitElement {
@property() public helper?: string; @property() public helper?: string;
@property({ type: Boolean }) public disabled?: boolean;
@property({ type: Boolean }) public required?: boolean; @property({ type: Boolean }) public required?: boolean;
/** /**
@ -39,6 +42,8 @@ class HaDevicesPicker extends LitElement {
@property({ attribute: "pick-device-label" }) public pickDeviceLabel?: string; @property({ attribute: "pick-device-label" }) public pickDeviceLabel?: string;
@property() public deviceFilter?: HaDevicePickerDeviceFilterFunc;
protected render(): TemplateResult { protected render(): TemplateResult {
if (!this.hass) { if (!this.hass) {
return html``; return html``;
@ -53,11 +58,13 @@ class HaDevicesPicker extends LitElement {
allow-custom-entity allow-custom-entity
.curValue=${entityId} .curValue=${entityId}
.hass=${this.hass} .hass=${this.hass}
.deviceFilter=${this.deviceFilter}
.includeDomains=${this.includeDomains} .includeDomains=${this.includeDomains}
.excludeDomains=${this.excludeDomains} .excludeDomains=${this.excludeDomains}
.includeDeviceClasses=${this.includeDeviceClasses} .includeDeviceClasses=${this.includeDeviceClasses}
.value=${entityId} .value=${entityId}
.label=${this.pickedDeviceLabel} .label=${this.pickedDeviceLabel}
.disabled=${this.disabled}
@value-changed=${this._deviceChanged} @value-changed=${this._deviceChanged}
></ha-device-picker> ></ha-device-picker>
</div> </div>
@ -65,12 +72,15 @@ class HaDevicesPicker extends LitElement {
)} )}
<div> <div>
<ha-device-picker <ha-device-picker
allow-custom-entity
.hass=${this.hass} .hass=${this.hass}
.helper=${this.helper} .helper=${this.helper}
.deviceFilter=${this.deviceFilter}
.includeDomains=${this.includeDomains} .includeDomains=${this.includeDomains}
.excludeDomains=${this.excludeDomains} .excludeDomains=${this.excludeDomains}
.includeDeviceClasses=${this.includeDeviceClasses} .includeDeviceClasses=${this.includeDeviceClasses}
.label=${this.pickDeviceLabel} .label=${this.pickDeviceLabel}
.disabled=${this.disabled}
.required=${this.required && !currentDevices.length} .required=${this.required && !currentDevices.length}
@value-changed=${this._addDevice} @value-changed=${this._addDevice}
></ha-device-picker> ></ha-device-picker>

View File

@ -14,6 +14,8 @@ class HaEntitiesPickerLight extends LitElement {
@property({ type: Array }) public value?: string[]; @property({ type: Array }) public value?: string[];
@property({ type: Boolean }) public disabled?: boolean;
@property({ type: Boolean }) public required?: boolean; @property({ type: Boolean }) public required?: boolean;
@property() public helper?: string; @property() public helper?: string;
@ -96,6 +98,7 @@ class HaEntitiesPickerLight extends LitElement {
.entityFilter=${this._entityFilter} .entityFilter=${this._entityFilter}
.value=${entityId} .value=${entityId}
.label=${this.pickedEntityLabel} .label=${this.pickedEntityLabel}
.disabled=${this.disabled}
@value-changed=${this._entityChanged} @value-changed=${this._entityChanged}
></ha-entity-picker> ></ha-entity-picker>
</div> </div>
@ -103,6 +106,7 @@ class HaEntitiesPickerLight extends LitElement {
)} )}
<div> <div>
<ha-entity-picker <ha-entity-picker
allow-custom-entity
.hass=${this.hass} .hass=${this.hass}
.includeDomains=${this.includeDomains} .includeDomains=${this.includeDomains}
.excludeDomains=${this.excludeDomains} .excludeDomains=${this.excludeDomains}
@ -113,6 +117,7 @@ class HaEntitiesPickerLight extends LitElement {
.entityFilter=${this._entityFilter} .entityFilter=${this._entityFilter}
.label=${this.pickEntityLabel} .label=${this.pickEntityLabel}
.helper=${this.helper} .helper=${this.helper}
.disabled=${this.disabled}
.required=${this.required && !currentEntities.length} .required=${this.required && !currentEntities.length}
@value-changed=${this._addEntity} @value-changed=${this._addEntity}
></ha-entity-picker> ></ha-entity-picker>

View File

@ -66,12 +66,14 @@ export class HaDeviceSelector extends LitElement {
.hass=${this.hass} .hass=${this.hass}
.value=${this.value} .value=${this.value}
.helper=${this.helper} .helper=${this.helper}
.deviceFilter=${this._filterDevices}
.includeDeviceClasses=${this.selector.device.entity?.device_class .includeDeviceClasses=${this.selector.device.entity?.device_class
? [this.selector.device.entity.device_class] ? [this.selector.device.entity.device_class]
: undefined} : undefined}
.includeDomains=${this.selector.device.entity?.domain .includeDomains=${this.selector.device.entity?.domain
? [this.selector.device.entity.domain] ? [this.selector.device.entity.domain]
: undefined} : undefined}
.disabled=${this.disabled}
.required=${this.required} .required=${this.required}
></ha-devices-picker> ></ha-devices-picker>
`; `;

View File

@ -51,9 +51,10 @@ export class HaEntitySelector extends LitElement {
.hass=${this.hass} .hass=${this.hass}
.value=${this.value} .value=${this.value}
.helper=${this.helper} .helper=${this.helper}
.entityFilter=${this._filterEntities}
.includeEntities=${this.selector.entity.include_entities} .includeEntities=${this.selector.entity.include_entities}
.excludeEntities=${this.selector.entity.exclude_entities} .excludeEntities=${this.selector.entity.exclude_entities}
.entityFilter=${this._filterEntities}
.disabled=${this.disabled}
.required=${this.required} .required=${this.required}
></ha-entities-picker> ></ha-entities-picker>
`; `;