Bonjour Mophete,
Comment j’ai procédé, j’ai d’abord créé un Script que j’ai nommé « centre de notification », que j’appel dans chaque automatisation ou j’ai besoin d’envoyer une notification :
Voci mon script
alias: centre de notification
sequence:
- alias: Action TAB01
if:
- condition: template
value_template: "{{'TAB01' in notificationqui }}"
then:
- metadata: {}
data:
title: "{{ notificationtitre }}"
message: "{{ notificationmessage }}"
data:
color: "{{ notificationcolor }}"
action: notify.mobile
- if:
- condition: and
conditions:
- condition: device
device_id: 6fe81a8c603a593
domain: media_player
entity_id: b9bd04440
type: is_on
- condition: template
value_template: " {{'TV-SALON' in notificationqui }}"
then:
- metadata: {}
data:
title: "{{ notificationtitre }}"
message: "{{ notificationmessage }}"
action: notify.tv_salon
alias: Action TV-SALON
- alias: Action MOBILE-JULIEN
if:
- condition: template
value_template: " {{'MOBILE-JULIEN' in notificationqui }}"
then:
- metadata: {}
data:
title: "{{ notificationtitre }}"
message: "{{ notificationmessage }}"
data:
color: "{{ notificationcolor }}"
channel: "{{ notificationchannel }}"
vibrationPattern: >
{%- if notificationchannel == "alarme" -%} "100, 1000, 100, 1000,
100, 100, 1000, 100, 1000, 100, 100, 1000, 100, 1000, 100, 100,
1000, 100, 1000, 100" {%- endif %}
image: "{{ notificationimage }}"
actions:
- action: "{{ notificationaction1action }}"
title: "{{ notificationaction1title }}"
uri: "{{ notificationaction1uri }}"
- action: "{{ notificationaction2 }}"
title: "{{ notificationaction2 }}"
uri: "{{ notificationuri2 }}"
- action: "{{ notificationaction3 }}"
title: "{{ notificationaction3 }}"
uri: "{{ notificationuri3 }}"
- action: "{{ notificationaction4 }}"
title: "{{ notificationaction4 }}"
uri: "{{ notificationuri4 }}"
action: notify.mobile
- metadata: {}
data:
title: "{{ notificationtitre }}"
message: "{{ notificationmessage }}"
data:
color: "{{ notificationcolor }}"
action: notify.notification_html5
- data:
entity_id: input_text.historique_texte
name: MOBILE JULIEN
message: >
Titre : " {{ notificationtitre }} "
Message : " {{ notificationmessage }} "
Actions : " {{ notificationaction1 }} {{ notificationaction2 }} {{
notificationaction3 }} {{ notificationaction4 }}"
Couleur : " {{ notificationcolor }} "
action: logbook.log
- alias: Action MOBILE-AUTRE
if:
- condition: template
value_template: " {{'MOBILE-AUTRE' in notificationqui }}"
then:
- metadata: {}
data:
title: "{{ notificationtitre }}"
message: "{{ notificationmessage }}"
data:
color: "{{ notificationcolor }}"
channel: "{{ notificationchannel }}"
vibrationPattern: >
{%- if notificationchannel == "alarme" -%} "100, 1000, 100, 1000,
100, 100, 1000, 100, 1000, 100, 100, 1000, 100, 1000, 100, 100,
1000, 100, 1000, 100" {%- endif %}
actions:
- action: "{{ notificationaction1action }}"
title: "{{ notificationaction1title }}"
uri: "{{ notificationaction1uri }}"
- action: "{{ notificationaction2 }}"
title: "{{ notificationaction2 }}"
- action: "{{ notificationaction3 }}"
title: "{{ notificationaction3 }}"
- action: "{{ notificationaction4 }}"
title: "{{ notificationaction4 }}"
action: notify.mobile
enabled: true
- alias: Action MAIL-JULIEN
if:
- condition: template
value_template: " {{'MAIL-JULIEN' in notificationqui }}"
then:
- metadata: {}
data:
target: xxx@gmail.com
title: "{{ notificationtitre }}"
message: "{{ notificationmessage }}"
data:
html: "{{ notificationmessage }}"
images:
- /media/Images/home-assistant-wordmark-color-on-light.png
action: notify.notification_mail_famille
- alias: Action MAIL-AUTRE
if:
- condition: template
value_template: " {{'MAIL-AUTRE' in notificationqui }}"
then:
- metadata: {}
data:
target: xxx@gmail.com
title: "{{ notificationtitre }}"
message: "{{ notificationmessage }}"
data:
html: "{{ notificationmessage }}"
action: notify.notification_mail_famille
- alias: Action HP-ENTREE
if:
- condition: template
value_template: " {{'HP-ENTREE' in notificationqui }}"
then:
- metadata: {}
data: {}
target:
entity_id: media_player.vlc_telnet
action: media_player.media_stop
- metadata:
title: "{{ notificationmessage }}"
thumbnail: null
media_class: music
children_media_class: null
navigateIds:
- {}
- media_content_type: app
media_content_id: media-source://media_source
- media_content_type: ""
media_content_id: media-source://media_source/local/Audios
data:
media_content_id: media-source://media_source/local/Audios/{{ notificationmessage }}
media_content_type: audio/mpeg
target:
entity_id: media_player.vlc_telnet
action: media_player.play_media
- alias: Action HP-TEXTE
if:
- condition: template
value_template: " {{'HP-TEXTE' in notificationqui }}"
then:
- metadata: {}
data:
cache: true
media_player_entity_id: media_player.vlc_telnet
message: "{{ notificationmessage }}"
language: fr
target:
entity_id: tts.google_en_com
enabled: false
action: tts.speak
- metadata: {}
data:
cache: false
entity_id: media_player.vlc_telnet
message: "{{ notificationmessage }}"
action: tts.picotts_say
- alias: Action TEAMS
if:
- condition: template
value_template: " {{'TEAMS' in notificationqui }}"
then:
- action: notify.msteamshomeevjapp
metadata: {}
data:
message: "{{ notificationmessage }}"
title: "{{ notificationtitre }}"
- alias: Action TEAMS Alarme
if:
- condition: template
value_template: " {{'TEAMS-Alarme' in notificationqui }}"
then:
- action: notify.msteamshomeevjappalarme
metadata: {}
data:
message: "{{ notificationmessage }}"
title: "{{ notificationtitre }}"
fields:
notificationqui:
selector:
select:
options:
- MOBILE-JULIEN
- MOBILE-AUTRE
- TAB01
- TV-SALON
- HP-TEXTE
- MAIL-AUTRE
- MAIL-JULIEN
multiple: true
name: notificationqui
required: true
notificationmessage:
selector:
text: null
name: notificationmessage
required: true
notificationtitre:
selector:
text: null
name: notificationtitre
default: Infos
required: false
notificationcolor:
selector:
text: null
name: notificationcolor
default: blue
notificationchannel:
selector:
text: null
name: notificationchannel
default: General
notificationaction1:
selector:
text: null
name: notificationaction1
notificationaction2:
selector:
text: null
name: notificationaction2
notificationaction3:
selector:
text: null
name: notificationaction3
notificationaction4:
selector:
text: null
name: notificationaction4
notificationuri1:
selector:
text: null
name: notificationuri1
notificationuri2:
selector:
text: null
name: notificationuri2
notificationuri3:
selector:
text: null
name: notificationuri3
notificationuri4:
selector:
text: null
name: notificationuri4
notificationimage:
selector:
text: null
name: notificationimage
mode: parallel
icon: mdi:bell-cog-outline
max: 10
Et voici ce je met quand je dois appeler ce script dans mon automatisation :
metadata: {}
data:
variables:
notificationqui:
- MOBILE-JULIEN
- TAB01
- MOBILE-AUTRE
- TV-SALON
notificationtitre: Aspirateur
notificationmessage: >-
L'aspirateur a terminé son cylce de nettoyage, {{
states("sensor.robot_aspirateur_current_clean_area") | round(1) }} m²
nettoyé en {{ (states("sensor.robot_aspirateur_current_clean_duration") |
int / 60 ) | round(1) }} min.
notificationcolor: green
target:
entity_id: script.centre_de_notification
enabled: true
action: script.turn_on
Aussi si besoin un fichier audio :
J’espère que j’ai pu t’aider, si tu as besoin d’autres exemple fait moi signe.
Cdt
Julien