Added templates to home-assistant

This commit is contained in:
Chris Stuurman 2025-04-30 00:36:14 +02:00
parent 34e1836ffe
commit 3655fd2e85
2 changed files with 195 additions and 65 deletions

View File

@ -4,71 +4,155 @@ sequence:
image_url: "{{ base_url~image }}" image_url: "{{ base_url~image }}"
video_url: "{{ base_url~video }}" video_url: "{{ base_url~video }}"
- parallel: - parallel:
- if: - sequence:
- condition: template - if:
value_template: '{{ send_to_sm_n986b | default(True) }}' - condition: template
then: value_template: "{{ send_to_sm_n986b | default(True) }}"
- data: alias: Send to SM_N986B?
message: "{{ message }}" then:
title: "{{ title }}" - data:
data: message: "{{ message }}"
sticky: "true" title: "{{ title }}"
color: "#2DF56D" data:
channel: "{{ channel }}" sticky: "true"
vibrationPattern: 100, 1000, 100, 1000, 100 color: "#2DF56D"
priority: "{{ priority }}" channel: "{{ channel }}"
ledColor: red vibrationPattern: 100, 1000, 100, 1000, 100
importance: "{{ importance }}" priority: "{{ priority }}"
clickAction: "{{ image_url }}" ledColor: red
tag: "{{ notifTag }}" importance: "{{ importance }}"
group: "{{ group }}" clickAction: "{{ image_url }}"
image: >- tag: "{{ notifTag }}"
{% if (importance == "default" and video != null) -%} {{ null }} group: "{{ group }}"
{%- else -%} {{ image_url }} {%- endif %} image: >-
video: >- {% if (importance == "default" and video != null) -%} {{
{% if (importance == "default" and video != null) -%} {{ video_url null }} {%- else -%} {{ image_url }} {%- endif %}
}} {%- else -%} {{ null }} {%- endif %} video: >-
notification_icon: "{{ notifIcon }}" {% if (importance == "default" and video != null) -%} {{
when: "{{ when }}" video_url }} {%- else -%} {{ null }} {%- endif %}
actions: notification_icon: "{{ notifIcon }}"
- action: URI when: "{{ when }}"
title: Open Image actions:
uri: "{{ image_url }}" - action: URI
- action: URI title: Open Image
title: Open Clip uri: "{{ image_url }}"
uri: "{{ video_url }}" - action: URI
action: notify.mobile_app_sm_n986b title: Open Clip
- data: uri: "{{ video_url }}"
message: '{{ message }}' action: notify.mobile_app_sm_n986b
title: '{{ title }}' alias: "Notify: Send message to SM_N986B"
data: - if:
url: '{{ video_url }}' - condition: template
tag: '{{ notifTag }}' value_template: '{{ send_to_nokia_c20 | default(True) }}'
group: '{{ group }}' then:
attachment: - sequence:
url: '{% if (importance == "default" and video != null) -%} {{ video }} {%- else -%} {{ image_url }} {%- endif %}' - data:
push: message: "{{ message }}"
interruption-level: '{% if importance == "max" -%} time-sensitive {%- else -%} passive {%- endif %}' title: "{{ title }}"
# must test above data sent to notify.mobile_app_sm_n986b and check whether the following data is needed data:
# actions: sticky: "true"
# - action: URI color: "#2DF56D"
# title: Open Image channel: "{{ channel }}"
# uri: https://home-assistant.sthome.org/api/frigate/notifications/{{ id }}/thumbnail.jpg?format=android vibrationPattern: 100, 1000, 100, 1000, 100
action: notify.mobile_app_sm_n986b priority: "{{ priority }}"
# - if: ledColor: red
# - condition: template importance: "{{ importance }}"
# value_template: '{{ states("media_player.nova4k") != "off" }}' clickAction: "{{ image_url }}"
# - condition: template tag: "{{ notifTag }}"
# value_template: '{{ importance == "max" }}' group: "{{ group }}"
# then: image: >-
# - data: {% if (importance == "default" and video != null) -%} {{ null }}
# message: '{{ message }}' {%- else -%} {{ image_url }} {%- endif %}
# title: '{{ title }}' video: >-
# data: {% if (importance == "default" and video != null) -%} {{ video_url
# fontsize: medium }} {%- else -%} {{ null }} {%- endif %}
# image: notification_icon: "{{ notifIcon }}"
# url: https://frigate.sthome.org/api/events/{{id}}/snapshot.jpg when: "{{ when }}"
# action: notify.nova_4k 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 mode: parallel
icon: mdi:bell-ring-outline icon: mdi:bell-ring-outline
max: 10 max: 10
@ -78,6 +162,16 @@ fields:
boolean: null boolean: null
name: send_to_sm_n986b name: send_to_sm_n986b
required: false 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: send_to_nova_4k:
selector: selector:
boolean: null boolean: null

View File

@ -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 -%}