I was playing around with a Blueprint, but I've hit a road block. The goal was to set it up so that users could add song names and their corresponding codes using an Object selector at the blueprint level, then derive the script's field selects options from that list of objects...
blueprint:
name: ESPHome Play RTTTL
description: |
This script should be adaptable to any device using the ESPHome RTTTL Component.
This script expects your device to include the following action in it's API component configuration:
```
api:
actions:
- action: rtttl_play
variables:
tone: string
then:
- rtttl.play:
rtttl: !lambda 'return tone;'
```
domain: script
input:
rtttl_action:
name: RTTL Action
description: |
The RTTL action suplied by your ESPHome device.
If you can't find it try searching for "esphome." or "rtttl"
selector:
action:
tune_collection:
name: Tune Collection
selector:
object:
label_field: Tune Name and Code
description_field: |
Use the "Name" field to define how you want the tune to appear for selection in the script.
Paste the RTTTL Code for that tune in it's field. You can add new tunes at anytime.
multiple: true
fields:
name:
label: Name
selector:
text: null
rtttl_code:
label: RTTTL Code
selector:
text: null
mode: queued
variables:
tune_collection: !input tune_collection
rtttl_action: !input rtttl_action
action_id: "{{ rtttl_action[0]['action']|default('esphome.esphome_starter_kit_play_rtttl', true) }}"
tune_names: "{{ tune_collection | map(attribute='name') | list }}"
fields:
tune:
name: Tune
selector:
select:
multiple: false
options: "{{tune_names}}" #This is what doesn't work
sequence:
- action: "{{ action_id }}"
metadata: {}
data:
song_string: "{{ tune_collection|selectattr('name','eq', tune) | map(attribute= 'rtttl_code') | first }}"
EDIT:
I think the only options are:
- Use a Text selector in the script field... maybe with some bare bones search logic, since I don't think there's any way to do proper fuzzy search.
- Set up multiple inputs with Object selector instead of just one... but that would make the GUI kind of gross.
Anyone have any better ideas....?