mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
Add support for supported_features
for entity selector (#16003)
This commit is contained in:
parent
91caffc4e1
commit
273904a6eb
@ -1,5 +1,7 @@
|
|||||||
import type { HassEntity } from "home-assistant-js-websocket";
|
import type { HassEntity } from "home-assistant-js-websocket";
|
||||||
|
import { ensureArray } from "../common/array/ensure-array";
|
||||||
import { computeStateDomain } from "../common/entity/compute_state_domain";
|
import { computeStateDomain } from "../common/entity/compute_state_domain";
|
||||||
|
import { supportsFeature } from "../common/entity/supports-feature";
|
||||||
import { UiAction } from "../panels/lovelace/components/hui-action-editor";
|
import { UiAction } from "../panels/lovelace/components/hui-action-editor";
|
||||||
import type { DeviceRegistryEntry } from "./device_registry";
|
import type { DeviceRegistryEntry } from "./device_registry";
|
||||||
import type { EntitySources } from "./entity_sources";
|
import type { EntitySources } from "./entity_sources";
|
||||||
@ -149,6 +151,7 @@ interface EntitySelectorFilter {
|
|||||||
integration?: string;
|
integration?: string;
|
||||||
domain?: string | readonly string[];
|
domain?: string | readonly string[];
|
||||||
device_class?: string | readonly string[];
|
device_class?: string | readonly string[];
|
||||||
|
supported_features?: number | [number];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EntitySelector {
|
export interface EntitySelector {
|
||||||
@ -358,6 +361,7 @@ export const filterSelectorEntities = (
|
|||||||
const {
|
const {
|
||||||
domain: filterDomain,
|
domain: filterDomain,
|
||||||
device_class: filterDeviceClass,
|
device_class: filterDeviceClass,
|
||||||
|
supported_features: filterSupportedFeature,
|
||||||
integration: filterIntegration,
|
integration: filterIntegration,
|
||||||
} = filterEntity;
|
} = filterEntity;
|
||||||
|
|
||||||
@ -383,6 +387,16 @@ export const filterSelectorEntities = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filterSupportedFeature) {
|
||||||
|
if (
|
||||||
|
ensureArray(filterSupportedFeature).some(
|
||||||
|
(feature) => !supportsFeature(entity, feature)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
filterIntegration &&
|
filterIntegration &&
|
||||||
entitySources?.[entity.entity_id]?.domain !== filterIntegration
|
entitySources?.[entity.entity_id]?.domain !== filterIntegration
|
||||||
|
Loading…
x
Reference in New Issue
Block a user