Control OH2 with Telegram and Node-RED?

Tags: #<Tag:0x00007f1e5c0e0750> #<Tag:0x00007f1e5c0e02f0> #<Tag:0x00007f1e5c0e7de8>
(Fredrik Marklund) #1

How can you control openHAB with Telegram and Node-RED? Any tutorials out there?


(Spottyq) #2

I do not know about Telegram (a quick google search tells me it is a messenging service ?) but you can certainly use Node-RED with OH.
I personally do, with MQTT as a communication bus between OH, Node-RED (and some actuators.)

This post might be interesting.

1 Like

(Joachim Boeddeker) #3

Currently only a Telegram-action exists. With that you are able to send messages to a telegram client. The other way round, reading a chat to control openHAB via messages doesn’t exist yet.

It’s on my list, but not started yet. Have a look here:

1 Like

(Rgerrans) #4

A quick Google search turned up this Telegram addon for Node-Red:. []

It looks like it should be straight forward to set it up as a receiver in Node-Red. You could then use switch nodes to filter for your command messages and change nodes to set your actions to send back to OH either through the OH nodes or through MQTT.

1 Like

(Fredrik Marklund) #5

node-red with node-red-contrib-telegrambot and node-red-contrib-openhab2 installed and working. My openHAB string item only receives the text msg.payload and not actual text from Telegram. What’s missing?


(Rgerrans) #6

Since I don’t use the Telegram bot myself I don’t know their payload json structure. Likely the text is a sub value inside the payload. Easiest way to figure it out is hook up a debug node and set it to report the full object. Then you can expand it to see the value it is assigned to. You can then check that value in your switch node or if you wanted use a change node to move it to the msg.payload.

The value structure will be along the lines of msg.payload.valueid if it’s inside the payload when you expand the object. If it’s at the same level then it’s just msg.valueid

1 Like

(Fredrik Marklund) #7

I get this from the debug node when i send the word Testing: type: “message”, content: “Testing”

It’s working! I used

msg.payload = msg.payload.content.toString();

in a function node. Thanks for the help!


(Rgerrans) #8

You shouldn’t need the function node. You should be able to evaluate msg.payload.content in a switch node directly.


(Jens) #9

I just did a little test to switch on a hue light with nodered via telegram. That worked quite well.
Need to play with it a bit more during the weekend.


(David De Marco) #10

Have been looking for a way to have OH2 ask me a question and then take an action on my response. Bit of researched on Telegram pulled up gold. There is a Node-RED node

That does this really well. Took about 10 mins to setup using the instructions on the site and bam, I’m am getting notifications sent to my iphone asking me a question with various responses.

Give the age of this thread and a few request for a tutorial I’ll experiment abit more and create one.


(Spottyq) #11

What are your use cases for this ?