Start with NodeRed (Alarm System Status Notification - Telegram)

Hello everyone,
As an absolute newcomer to Node Red, I have now implemented my complete shutter control system in Node Red with the help of a YouTube video.
I have to admit, however, that I have taken over a large part and only made small changes to adapt it to my system.
Nevertheless, I find that Node Red is clearer than the automations in HA, especially for more complex requirements.

I would therefore like to delve a little deeper into NR and implement 1-2 projects myself. I have some questions in advance as to whether this is possible, how it can be done better and possibly also tips (links where I can find help on similar projects)

  1. Evaluate alarm situation switching states, report to Telegram and switch additional function

Here I have previously created a message via the HA automation (alarm system switched on and alarm system switched off), whereby the change between the switching states is monitored in the automations in HA and then a corresponding message is sent to Telegram.
The switching states of the alarm system are supported by HA (alarm off, alarm home on/off, alarm full on/off, alarm area X on/off).

How can I do this via NR? (The Telegram connection is already up and running).

  1. Send all important messages in HA to Telegram (extension to 1.)

Do I have the possibility to integrate other “variables/entities” so that I have a central NR board for all messages, which I then send to Telegram with different texts?

Thanks for any help.

Yes it’s code and HA is a fully featured platform. If you can dream it up you can probably write it.

Read the short there’s a collection of nodes in NR just for accessing HA. There’s a node that will fire every time a entity state changes and put the state on the flow. You start with that.

Yes. See above. There’s tons of node types. Too many to name. Just get started building flows and kick the tires.

1 Like

Thanks for the confirmation.

I tested a little today - and yes it works…

I’ve now got to the point where every status change is sent to Telegram.

I have stored the texts in functions, there is certainly still a lot to optimize here, as I have not yet been able to address 2 Telegram IDs simultaneously in one function… but that will probably still happen.

The basic functions are in place and tested, the “old” HA automation is deactivated and IFTTT is no longer required.

I think I need to work a bit more with the strings under NR, they still cause me problems as a newcomer (several Telegram IDs in one function, formatting and variables… You grow with your tasks…

Not sure what you mean by “strings” but JSONata is a primary way to handle data in NR. There is some information here:


Just a note here. Jsonata is for use in HA nodes and nodered nodes except for a function node. Function nodes use javascript. You can use either w3 or mdn for reference of how to deal with different types of data.

If you need further help please export and post your flow.


Sorry for the late reply…

Basically everything is running smoothly. However, I have made the workflow simple so that it works first.

  1. The status change disarmed/armed_home/armed_away call a function (3 statuses)
  2. The function passes a text matching the status
  3. I use one function each, because I somehow haven’t figured out how to send the text to 2 Telegram IDs at the same time…

Optimization 1 would be:
Status change via one node (if possible)
Optimization 2 would be:
Customize the functions (one?) so that it takes all status changes into account and sends the corresponding message to 2 Telegram ID’s.


NodeRed basic workflow :slight_smile:

Node for every (3) status change (disarmed/armed_home/armed_away)

Function for every Telegram ID (My wife & me) Different ID same text

You can use one event state by leaving state blank. It will send all state changes this way. Delete message data and topic output by clicking the x so that payload = entity state is the only output.

Then use this for the function

const alarmState = msg.payload;

// create empty msg. this clears all incoming messages parts
msg = {};

// create an empty string text
let text = '';

if (alarmState == 'armed_away') {
    text = 'Armed away text';
else if ( alarmState == 'armed_home') {
    text = 'Armed home text';
else if ( alarmState == 'disarmed') {
    text = 'Disarmed text';
else { // this is a catch all should the state not match any of the above
    text = 'Alarm state is not available';

msg.payload = { chatID: 'id1 here', type: "message", content: text};

//slight delay between messages
setTimeout(() => {
    msg.payload = { chatID: 'id2 here', type: "message", content: text };
}, 500);// delay in milliseconds

In the end you wind up with this



Many thanks for the great help.

I tried to implement the whole thing today. I came across an error that I can’t get rid of.

I have done everything as described. The status change is recognized and passed correctly according to the debug. However, the function cannot be sent because errors occur here.

I have (among other things) already tried to send the chat ID differently (‘Chat ID’ changed to Chat ID). Unfortunately, nothing helps.

I have now found the error!

  1. the ChatID must be entered as a pure number, i.e. 12345678 not ‘12345678’ (no apostrophe character)
  2. The ChatId spelling is important (the D must be a small d)
    I compared the output with my non-cortable solution and then saw/correlated the differences in the debug.

Now everything works, thank you very much, without you I would not have been able to do it so quickly!!!

1 Like