Label Selector
The Label selector provides a label picker for selecting Home Assistant labels.
⚠️ Note: This selector can provide part of the functionality of the
targetproperty (specificallylabel_id), but for more flexible target selection that supports multiple target types simultaneously, use thetargetproperty instead. See Target Selector for details.
Options
All label selectors accept these common metadata options:
default?: TLabelId- Default selected labeldescription?: string- Human-readable description shown in the UIrequired?: boolean- Whether the field must be provided
Label-specific options (from ServiceListSelector["label"]):
multiple?: boolean- Whentrue, allows selecting multiple labels (returnsTLabelId[])
Return Type
TLabelIdwhenmultipleis not set orfalseTLabelId[]whenmultiple: true
Example
import { TServiceParams } from "@digital-alchemy/core";
import { ServiceField } from "@digital-alchemy/synapse";
export function SynapseServiceCreate({
synapse,
context,
logger,
}: TServiceParams) {
synapse.service.create(
{
context,
description: "Apply label-based action",
fields: {
// Label selector
label: ServiceField.Label({
description: "Label to target",
required: true,
}),
},
},
async data => {
// data.label is typed as: TLabelId
logger.info(`Targeting label: ${data.label}`);
}
);
}