SUBFLOW : Notification Center : HTML5 / Discord / Telegram / Email / Home Assistant (mobile) / TTS

Hello,

I have create a sublow to manage all notification service, and I tell myself that it can be cool to share it :wink:
It is still under development and I am gradually adding the different services that I use.

Actualy, you can notify :

  • HTML5 by Home Assistant
  • Discord
  • Home Assistant (application mobile)
  • Email
  • Telegram
  • TTS

Screenshot :

You can download it here.

Docs :

=============================================================================

Information

This flow aims to centralize all notifications.

Actualy, it’s work with :

  • HTML5 (by Home Assistant)
  • Discord
  • Telegram
  • Email
  • TTS
  • Home Assistant (Mobile App)

Requirement

  • node-red-contrib-chatbot
  • node-red-contrib-chatbot-discord
  • node-red-contrib-string
  • node-red-contrib-home-assistant-websocket
  • node-red-node-email

Input

In this exemple, you can find all inut :

msg.title = "Home Assistant - New version available"
msg.dest = "tel_clement;mail_clement;tts_80_hall"  
msg.message = "Home Assistant : New version available => 0.113.0 \n
https://github.com/home-assistant/core/releases/tag/0.113.0"
msg.short_message = "Home Assistant : New version available (0.113.0)"
msg.image = "/data/image.jpeg"
msg.document = "/data/doc.js"
msg.video = "/data/video.mp4"

All inputs are not necessarily compatible with all services

Title / msg.title

Available on : Email

Title use only for email

Exemple:

msg.title = "Home Assistant - New version available"

Message / msg.message

Available on : Email / Telegram / Discord

Long version of message

Exemple:

msg.message = "Home Assistant : New version available => 0.113.0 \n https://github.com/home-assistant/core/releases/tag/0.113.0"

Short Message / msg.short_message

Available on : HTML5 / Home Assistant

Short Message use in "popup’

Exemple:

msg.short_message = "Home Assistant : New version available (0.113.0)"

WARNING : Message are Trim & \n replace by space

=> If not set, i take msg.message.

Image / msg.image

Available on : Telegram

Exemple:

msg.image = "/data/image.jpeg"
msg.image = "https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__340.jpg"

Document / msg.document

Available on : Telegram
Exemple:

msg.document = "/data/doc.js"

Video / msg.video

Available on : Telegram
Exemple:

msg.video = "/data/video.mp4"

Destination / msg.dest

Available on : All

Is a string to contains all destination separated by “;

Exemple:

msg.dest = "tel_clement;mail_clement;tts_80_hall"  

Message send to :

  • tel_clement
  • mail_clement
  • tts_80_hall

HTML5

This dest is always notify, you don’t need to add this dest.

Discord

Dest must start by discord_

Exemple:

msg.dest = "discord_communaute_news;discord_maison_information;discord_maison_network"  

Home Assistant

Dest must start by tel_

Exemple:

msg.dest = "tel_clement;tel_papa;tel_maman

Email

Dest must start by mail_

Exemple:

msg.dest = "mail_clement;mail_thomas"

Telegram

Dest must start by telegram_

Exemple:

msg.dest = "telegram_smarthome;telegram_familly"

TTS

Dest must start by tts_

Format : tts_{VOLUME}_{ENTITY_ID_OF_MEDIA_PLAYER}

Exemple:

msg.dest = "tts_80_hall"

Configuration

Subflow get configuration in global variable notif.

TTS no need configuration

Exemple:

// Discord channel ID
var discord = {
    "discord_communaute_news": XXXXXX,
    "discord_maison_general": XXXXXX,
    "discord_maison_alert": XXXXXX,
    "discord_maison_information": XXXXXX,
    "discord_maison_network": XXXXXX,
    "discord_maison_volets": XXXXXX,
}

// Entity ID of your phone
var home_assistant = {
    "tel_clement": "mobile_app_oneplus_a6010",
    "tel_nathalie": "mobile_app_oneplus_a5000"
}

// Email
var email = {
    "mail_1": "[email protected]",
    "mail_2": "[email protected]",
    "mail_3": "[email protected]"
}

// Telegram channel_id
var telegram = {
    "telegram_smarthome": "-channel_id",
    "telegram_serie": "-channel_id",
    "telegram_film": "-channel_id"
}

global.set("notif.discord",discord);
global.set("notif.home_assistant",home_assistant);
global.set("notif.email",email);
global.set("notif.telegram",telegram);

You can take this flow to help you to configure sublow :slight_smile:

[{"id":"eeef2d85.9fa7","type":"inject","z":"711f44dc.b8379c","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":440,"wires":[["487a6ba5.82acf4","9492f68.6dd8208"]]},{"id":"9492f68.6dd8208","type":"function","z":"711f44dc.b8379c","name":"Config Exemple","func":"// Discord channel ID\nvar discord = {\n    \"discord_communaute_news\": XXXXXX,\n    \"discord_maison_general\": XXXXXX,\n    \"discord_maison_alert\": XXXXXX,\n    \"discord_maison_information\": XXXXXX,\n    \"discord_maison_network\": XXXXXX,\n    \"discord_maison_volets\": XXXXXX,\n}\n\n// Entity ID of your phone\nvar home_assistant = {\n    \"tel_clement\": \"mobile_app_oneplus_a6010\",\n    \"tel_nathalie\": \"mobile_app_oneplus_a5000\"\n}\n\n// Just email\nvar email = {\n    \"mail_1\": \"[email protected]\",\n    \"mail_2\": \"[email protected]\",\n    \"mail_3\": \"[email protected]\"\n}\n\n// Just channel_id\nvar telegram = {\n    \"telegram_smarthome\": \"-channel_id\",\n    \"telegram_serie\": \"-channel_id\",\n    \"telegram_film\": \"-channel_id\"\n}\n\n// TTS\n// No configuration \n// Ex : tts_80_hall\n//   => Volume 80%\n//   => media_player.hall\n\nglobal.set(\"notif.discord\",discord);\nglobal.set(\"notif.home_assistant\",home_assistant);\nglobal.set(\"notif.email\",email);\nglobal.set(\"notif.telegram\",telegram);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":380,"y":440,"wires":[[]]}]

Exemple of input :

[{"id":"66da3fb7.1e4ff","type":"change","z":"8a8a63c5.0c3c2","name":"","rules":[{"t":"set","p":"title","pt":"msg","to":"Coucou","tot":"str"},{"t":"set","p":"message","pt":"msg","to":"Long Message","tot":"str"},{"t":"set","p":"short_message","pt":"msg","to":"Short Message","tot":"str"},{"t":"set","p":"dest","pt":"msg","to":"tel_clement;mail_clement","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":1880,"wires":[["7300bcc2.c97c34"]]}]

#Enjoy

6 Likes

Very nice! This gave me plenty of inspiration for my own notification engine.
Have you made any improvements over time?

Yes, you can see new version here :

Sorry, README is in french…

2 Likes