mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +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 { ensureArray } from "../common/array/ensure-array";
|
||||
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 type { DeviceRegistryEntry } from "./device_registry";
|
||||
import type { EntitySources } from "./entity_sources";
|
||||
@ -149,6 +151,7 @@ interface EntitySelectorFilter {
|
||||
integration?: string;
|
||||
domain?: string | readonly string[];
|
||||
device_class?: string | readonly string[];
|
||||
supported_features?: number | [number];
|
||||
}
|
||||
|
||||
export interface EntitySelector {
|
||||
@ -358,6 +361,7 @@ export const filterSelectorEntities = (
|
||||
const {
|
||||
domain: filterDomain,
|
||||
device_class: filterDeviceClass,
|
||||
supported_features: filterSupportedFeature,
|
||||
integration: filterIntegration,
|
||||
} = filterEntity;
|
||||
|
||||
@ -383,6 +387,16 @@ export const filterSelectorEntities = (
|
||||
}
|
||||
}
|
||||
|
||||
if (filterSupportedFeature) {
|
||||
if (
|
||||
ensureArray(filterSupportedFeature).some(
|
||||
(feature) => !supportsFeature(entity, feature)
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
filterIntegration &&
|
||||
entitySources?.[entity.entity_id]?.domain !== filterIntegration
|
||||
|
Loading…
x
Reference in New Issue
Block a user