Script to send notifications to multiple devices and be able to select which devices

so i had a basic script to send a notification to my iphone working and while working on a problem device that was not reporting in when it should i had the idea to see if claude could help rewrite the script to notify a specific device then i implemented it and had the thought, it would be nice if i could notify multiple devices at the same time so ask claude to tweak it so i could choose multiple or all of the devices and here is what it came up with

sequence:
  - variables:
      all_devices:
        - mobile_app_iphone
        - mobile_app_star8
      targets: >-
        {% set t = target_device | default('mobile_app_iphone', true) %} {% set
        t = [t] if t is string else t %} {{ all_devices if 'all' in t else t }}
  - repeat:
      for_each: '{{ targets }}'
      sequence:
        - action: notify.{{ repeat.item }}
          continue_on_error: true
          metadata: {}
          data:
            message: '{{message}}'
            title: '{{title}}'
alias: notify robert
description: notify selected devices
fields:
  target_device:
    name: Device
    description: Which device(s) to send the notification to
    required: false
    selector:
      select:
        multiple: true
        options:
          - label: All devices
            value: all
          - label: Robert's iPhone
            value: mobile_app_iphone
          - label: Android tablet (star8)
            value: mobile_app_star8
  title:
    selector:
      text: null
    name: title
    required: true
  message:
    selector:
      text: null
    name: message
    required: true

it works and to change the devices that are selectable alter the options labels and values to match your devices and you can even add more. this would probably work well for wall mounted displays that use android

Why not just use notify.send_message which supports selecting devices as targets?

bercause i have quite a few automations and going in to edit them in yaml is a pain this makes using he ui editor a bit simpler