From a7a945e6e1b3143d7b9494cc9b6f91f9542bb142 Mon Sep 17 00:00:00 2001 From: smkrv <17809065+smkrv@users.noreply.github.com> Date: Fri, 15 Nov 2024 02:24:29 +0300 Subject: [PATCH] Create ha_text_ai_request_push.yaml --- .../automation/ha_text_ai_request_push.yaml | 199 ++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 blueprints/automation/ha_text_ai_request_push.yaml diff --git a/blueprints/automation/ha_text_ai_request_push.yaml b/blueprints/automation/ha_text_ai_request_push.yaml new file mode 100644 index 0000000..91491c2 --- /dev/null +++ b/blueprints/automation/ha_text_ai_request_push.yaml @@ -0,0 +1,199 @@ +blueprint: + name: Push Notification Sender + description: Send push notifications with customizable content and options + domain: automation + source_url: https://github.com/smkrv/ha-text-ai/blob/main/blueprints/automation/ha_push_notification.yaml + input: + # Trigger Configuration + trigger_type: + name: Trigger Type + description: Select the type of trigger for this automation + default: state + selector: + select: + options: + - state + - numeric_state + - time + - template + + trigger_entity: + name: Trigger Entity + description: Entity that will trigger this automation when its state changes + selector: + entity: {} + + # State Trigger Options + state_from: + name: From State + description: Previous state value to trigger the automation (optional, for state trigger) + default: "" + selector: + text: + + state_to: + name: To State + description: New state value to trigger the automation (optional, for state trigger) + default: "" + selector: + text: + + # Numeric State Options + numeric_above: + name: Above Value + description: Trigger when the numeric value exceeds this threshold + selector: + number: + mode: box + step: 0.1 + + numeric_below: + name: Below Value + description: Trigger when the numeric value falls below this threshold + selector: + number: + mode: box + step: 0.1 + + # Time Trigger Options + time_at: + name: Time + description: Specific time to trigger the automation (for time trigger) + selector: + time: {} + + # Template Trigger Options + template_value: + name: Template + description: Template condition that evaluates to true/false (for template trigger) + selector: + template: {} + + # Notification Configuration + notification_target: + name: Notification Target + description: The target device or group to receive the notification + selector: + text: + + title_template: + name: Title Template + description: > + Template for the notification title. Supports Home Assistant template syntax. + Example: Temperature Alert: {{ states('sensor.temperature') }}°C + default: Home Assistant Notification + selector: + text: + multiline: true + + message_template: + name: Message Template + description: > + Template for the notification message. Supports Home Assistant template syntax. + Example: Current temperature is {{ states('sensor.temperature') }}°C in {{ states('sensor.location') }} + selector: + text: + multiline: true + + # Advanced Options + importance: + name: Importance Level + description: Set the importance/priority level of the notification + default: default + selector: + select: + options: + - low + - default + - high + + notification_sound: + name: Notification Sound + description: Select a sound to play with the notification (optional) + default: default + selector: + text: + + data_actions: + name: Actions + description: > + JSON array of actions (optional). Example: + [{"action": "URI", "title": "Open Map", "uri": "https://maps.google.com"}] + default: "[]" + selector: + text: + multiline: true + + # Additional Options + group_notifications: + name: Group Notifications + description: Group similar notifications together + default: false + selector: + boolean: + + notification_timeout: + name: Timeout + description: Time in seconds before the notification disappears (optional) + selector: + number: + min: 0 + max: 86400 + step: 1 + mode: box + +mode: queued +max_exceeded: silent + +trigger: + - choose: + - conditions: + - condition: template + value_template: "{{ trigger_type == 'state' }}" + sequence: + - platform: state + entity_id: !input trigger_entity + from: !input state_from + to: !input state_to + - conditions: + - condition: template + value_template: "{{ trigger_type == 'numeric_state' }}" + sequence: + - platform: numeric_state + entity_id: !input trigger_entity + above: !input numeric_above + below: !input numeric_below + - conditions: + - condition: template + value_template: "{{ trigger_type == 'time' }}" + sequence: + - platform: time + at: !input time_at + - conditions: + - condition: template + value_template: "{{ trigger_type == 'template' }}" + sequence: + - platform: template + value_template: !input template_value + +variables: + notification_target: !input notification_target + title_template: !input title_template + message_template: !input message_template + importance: !input importance + notification_sound: !input notification_sound + data_actions: !input data_actions + group_notifications: !input group_notifications + notification_timeout: !input notification_timeout + +action: + - service: notify.mobile_app_{{ notification_target }} + data: + title: "{{ title_template }}" + message: "{{ message_template }}" + data: + importance: "{{ importance }}" + sound: "{{ notification_sound }}" + actions: "{{ data_actions }}" + group: "{{ group_notifications }}" + timeout: "{{ notification_timeout }}"