diff --git a/home-assistant/Send Dynamic Notification To All Devices.yml b/home-assistant/Send Dynamic Notification To All Devices.yml index a0cc405..485fa66 100644 --- a/home-assistant/Send Dynamic Notification To All Devices.yml +++ b/home-assistant/Send Dynamic Notification To All Devices.yml @@ -4,71 +4,155 @@ sequence: image_url: "{{ base_url~image }}" video_url: "{{ base_url~video }}" - parallel: - - if: - - condition: template - value_template: '{{ send_to_sm_n986b | default(True) }}' - then: - - data: - message: "{{ message }}" - title: "{{ title }}" - data: - sticky: "true" - color: "#2DF56D" - channel: "{{ channel }}" - vibrationPattern: 100, 1000, 100, 1000, 100 - priority: "{{ priority }}" - ledColor: red - importance: "{{ importance }}" - clickAction: "{{ image_url }}" - tag: "{{ notifTag }}" - group: "{{ group }}" - image: >- - {% if (importance == "default" and video != null) -%} {{ null }} - {%- else -%} {{ image_url }} {%- endif %} - video: >- - {% if (importance == "default" and video != null) -%} {{ video_url - }} {%- else -%} {{ null }} {%- endif %} - notification_icon: "{{ notifIcon }}" - when: "{{ when }}" - actions: - - action: URI - title: Open Image - uri: "{{ image_url }}" - - action: URI - title: Open Clip - uri: "{{ video_url }}" - action: notify.mobile_app_sm_n986b - - data: - message: '{{ message }}' - title: '{{ title }}' - data: - url: '{{ video_url }}' - tag: '{{ notifTag }}' - group: '{{ group }}' - attachment: - url: '{% if (importance == "default" and video != null) -%} {{ video }} {%- else -%} {{ image_url }} {%- endif %}' - push: - interruption-level: '{% if importance == "max" -%} time-sensitive {%- else -%} passive {%- endif %}' - # must test above data sent to notify.mobile_app_sm_n986b and check whether the following data is needed - # actions: - # - action: URI - # title: Open Image - # uri: https://home-assistant.sthome.org/api/frigate/notifications/{{ id }}/thumbnail.jpg?format=android - action: notify.mobile_app_sm_n986b -# - if: -# - condition: template -# value_template: '{{ states("media_player.nova4k") != "off" }}' -# - condition: template -# value_template: '{{ importance == "max" }}' -# then: -# - data: -# message: '{{ message }}' -# title: '{{ title }}' -# data: -# fontsize: medium -# image: -# url: https://frigate.sthome.org/api/events/{{id}}/snapshot.jpg -# action: notify.nova_4k + - sequence: + - if: + - condition: template + value_template: "{{ send_to_sm_n986b | default(True) }}" + alias: Send to SM_N986B? + then: + - data: + message: "{{ message }}" + title: "{{ title }}" + data: + sticky: "true" + color: "#2DF56D" + channel: "{{ channel }}" + vibrationPattern: 100, 1000, 100, 1000, 100 + priority: "{{ priority }}" + ledColor: red + importance: "{{ importance }}" + clickAction: "{{ image_url }}" + tag: "{{ notifTag }}" + group: "{{ group }}" + image: >- + {% if (importance == "default" and video != null) -%} {{ + null }} {%- else -%} {{ image_url }} {%- endif %} + video: >- + {% if (importance == "default" and video != null) -%} {{ + video_url }} {%- else -%} {{ null }} {%- endif %} + notification_icon: "{{ notifIcon }}" + when: "{{ when }}" + actions: + - action: URI + title: Open Image + uri: "{{ image_url }}" + - action: URI + title: Open Clip + uri: "{{ video_url }}" + action: notify.mobile_app_sm_n986b + alias: "Notify: Send message to SM_N986B" + - if: + - condition: template + value_template: '{{ send_to_nokia_c20 | default(True) }}' + then: + - sequence: + - data: + message: "{{ message }}" + title: "{{ title }}" + data: + sticky: "true" + color: "#2DF56D" + channel: "{{ channel }}" + vibrationPattern: 100, 1000, 100, 1000, 100 + priority: "{{ priority }}" + ledColor: red + importance: "{{ importance }}" + clickAction: "{{ image_url }}" + tag: "{{ notifTag }}" + group: "{{ group }}" + image: >- + {% if (importance == "default" and video != null) -%} {{ null }} + {%- else -%} {{ image_url }} {%- endif %} + video: >- + {% if (importance == "default" and video != null) -%} {{ video_url + }} {%- else -%} {{ null }} {%- endif %} + notification_icon: "{{ notifIcon }}" + when: "{{ when }}" + actions: + - action: URI + title: Open Image + uri: "{{ image_url }}" + - action: URI + title: Open Clip + uri: "{{ video_url }}" + action: notify.mobile_app_nokia_c20 + - action: counter.increment + target: + entity_id: counter.nokia_c20_notification_counter + data: {} + alias: Increment NOKIA_C20 notification counter + - if: + - condition: template + value_template: '{{ send_to_sm_x115 | default(True) }}' + then: + - sequence: + - data: + message: "{{ message }}" + title: "{{ title }}" + data: + sticky: "true" + color: "#2DF56D" + channel: "{{ channel }}" + vibrationPattern: 100, 1000, 100, 1000, 100 + priority: "{{ priority }}" + ledColor: red + importance: "{{ importance }}" + clickAction: "{{ image_url }}" + tag: "{{ notifTag }}" + group: "{{ group }}" + image: >- + {% if (importance == "default" and video != null) -%} {{ null }} + {%- else -%} {{ image_url }} {%- endif %} + video: >- + {% if (importance == "default" and video != null) -%} {{ video_url + }} {%- else -%} {{ null }} {%- endif %} + notification_icon: "{{ notifIcon }}" + when: "{{ when }}" + actions: + - action: URI + title: Open Image + uri: "{{ image_url }}" + - action: URI + title: Open Clip + uri: "{{ video_url }}" + action: notify.mobile_app_sm_x115 + - action: counter.increment + target: + entity_id: counter.sm_x115_notification_counter + data: {} + alias: Increment SM_X115 notification counter + + # - data: + # message: '{{ message }}' + # title: '{{ title }}' + # data: + # url: '{{ video_url }}' + # tag: '{{ notifTag }}' + # group: '{{ group }}' + # attachment: + # url: '{% if (importance == "default" and video != null) -%} {{ video }} {%- else -%} {{ image_url }} {%- endif %}' + # push: + # interruption-level: '{% if importance == "max" -%} time-sensitive {%- else -%} passive {%- endif %}' + # must test above data sent to notify.mobile_app_sm_n986b and check whether the following data is needed + # actions: + # - action: URI + # title: Open Image + # uri: https://home-assistant.sthome.org/api/frigate/notifications/{{ id }}/thumbnail.jpg?format=android + # action: notify.mobile_app_sm_n986b + # - if: + # - condition: template + # value_template: '{{ states("media_player.nova4k") != "off" }}' + # - condition: template + # value_template: '{{ importance == "max" }}' + # then: + # - data: + # message: '{{ message }}' + # title: '{{ title }}' + # data: + # fontsize: medium + # image: + # url: https://frigate.sthome.org/api/events/{{id}}/snapshot.jpg + # action: notify.nova_4k mode: parallel icon: mdi:bell-ring-outline max: 10 @@ -78,6 +162,16 @@ fields: boolean: null name: send_to_sm_n986b required: false + send_to_nokia_c20: + selector: + boolean: null + name: send_to_nokia_c20 + required: false + send_to_sm_x115: + selector: + boolean: null + name: send_to_sm_x115 + required: false send_to_nova_4k: selector: boolean: null diff --git a/home-assistant/templates.yml b/home-assistant/templates.yml new file mode 100644 index 0000000..119cc25 --- /dev/null +++ b/home-assistant/templates.yml @@ -0,0 +1,36 @@ +template: + - binary_sensor: + - name: Sun Up + state: > + {{ is_state("sun.sun", "above_horizon") }} + icon: > + {% if is_state("binary_sensor.sun_up", "on") %} + mdi:weather-sunset-up + {% else %} + mdi:weather-sunset-down + {% endif %} +#notify: +# - platform: androidtv +# name: Android TV +# host: 10.0.0.71 + - sensor: + - name: alarm_triggered_gui + state: "{{ states('switch.sthome_ut1_alarm_zone_4') }}" + icon: > + {%- set state = states('switch.sthome_ut1_alarm_zone_4') -%} + {%- if state == 'on' -%} + mdi:alarm-light + {%- elif state == 'off' -%} + mdi:alarm-light-off + {%- endif -%} + - name: gate_lock_gui + state: "{{ states('switch.sthome_ut4_relay_5') }}" # should change to binary sensor + icon: > + {%- set state = states('switch.sthome_ut4_relay_5') -%} + {%- if state == 'on' -%} + mdi:lock-open + {%- elif state == 'off' -%} + mdi:lock + {%- else -%} + mdi:lock-off + {%- endif -%}