I'm trying to create a script to simplify overriding motion and presence sensors. I have input_boolean helpers for this purpose that start with "override_motion" or "override_presence". what is the syntax to dynamically present these as a field for a script?
The official documentation for Scripts, Input booleans and Selectors don't cover script fields at all (though this otherScript documentation shows only baseline field structure and links to the Selectors one that says nothing further).
I found this other community post that comes close but I haven't been able to figure out how to adapt the second example into something the script field selector will accept.
I'm not sure if I'm 100% clear on what you're asking...
I think what you want is a selector that narrows down to a list of entities that match your chosen naming/ID convention...
AFAIK, there aren't any selectors that can do that. The Entity selector can narrow down to the domain and/or integration, but it doesn't accept templates for the include_entities or exclude_entities configuration variables.
It won't make the selection more targeted, but you could add a variable to reject any selected entities that don't match you criteria after-the-fact.
I don't think you can... select entities are not related to input field Selectors. But, maybe if you explain what you were envisioning, we could help find a workaround.
Exactly. When invoking the script I'd like the Override Boolean input to only show the targeted helpers to simplify and speed up selection.
Well, if nothing more "native" satisfies this, what about getting a list to present as options?
fields:
override_id:
selector:
select:
options:
- some function
- to format
- a list like this
If not, or if that's too much effort, then I'll just settle for using the input_boolean domain as suggested. The rejection feature is a nice bonus, too, though I can't say I understand it as presented, yet. Studying it now...
Oh, include_entities for a hard-coded list. I missed that option. I was more thinking about generating a list of strings that also happen to be entity ID's that would hopefully work when actually used as entity reference later.
Does the rejection feature you shared work by making a new list of elements that appear in both the input list and the searched list?
It creates a new variable, overrides_only, that selects just the entity IDs from the input list that match the search criteria. Here's a screenshot of the "changed variables" section from the trace from a simple script, you can see the two lists: