In Alert call script via notify

Since you haven’t shared your script, I don’t know if this approach will work for you, but this is how I use alerts with scripted logic. Instead of using a REST notifier, I use a notify group with an empty set as the value of services. Alerts can be targeted at that notifier, and an automation can be triggered off the service call event created by the alert.

notify:
  - platform: group
    name: scripted_alerts
    services: []

alert:
  whirlpool_temperatur:
    name: Die Temperatur des Whirlpools ist unter 6 Grad
    entity_id: input_boolean.ztest_new_bool
    state: "on"
    skip_first: true
    repeat:
      - 1
      - 2
      - 3
    notifiers:
      - scripted_alerts
    message: "Achtung: Die Temperatur des Whirlpools ist unter 6 Grad"
    title: "Temperatur des Whirlpools"
    data:  
      type: "tts"
      duration: 6.3

automation:
  - id: scripted_alerts_00001
    alias: Scripted Alerts
    description: Play message from "scripted_alerts"
    trigger:
      - platform: event
        event_type: call_service
        event_data:
          domain: notify
          service: scripted_alerts
        variables:
          data: "{{trigger.event.data.service_data.data | to_json}}"
    condition: []
    action:
      - service: script.sprachausgabe
        data:
          message: "{{trigger.event.data.service_data.message}}"
          title: "{{trigger.event.data.service_data.title}}"
          type: "{{data.type}}"
          duration: "{{data.type}}"

EDIT: Modified action to reflect OP’s script call.

3 Likes