Unable to get binary sensor status and send to telegram

Hi Guys,

I am new to home assistant and NodeRed.

Currently I have having a door sensor installed,

Here is my flow. However I able to get pass to call service, but no message is send out. Able to assist me?


Secondly, I would like to send the status of the the currently binary sensor stat to telegram. Can advice on this?

Nothing is send to telegram....

does the msg contain a chat ID? (use a debug node after the function node)

Also add a debug to the telegram node, set it to complete message. The telegram node has reasonable good error reporting.

Hi,

I had added the debug node after the function and the telegram node.

Here are the reply for the debug
1
It seems debug after telegram node does not show anything

Add a debug node showing what is coming from the Both Gate Open node.

It would seem that msg.payload coming from the HA node is a string of value "off". So your function can not add object properties to a string.
In your function before the lines that are trying to add properties to the payload string, add the line msg.payload = {}; This will convert msg.payload to a object. If you require the value "off" move it to another variable to use later, if required.

Hi, thanks for replying,

After adding msg.payload = {}, which the function node would be like this

msg.payload = {};
msg.payload.content = "Gate is opening... Please wait a moment"
msg.payload.type = 'message'

return [ msg ];

i get the following from the debug
1

Hi i added the debug not into "Both gate open" Node, it came out "off"

So the error from Telegram says no chat_id, so all you need to do is add a chat_id to the function node
Here is how to find a chat_id

Thanks for the advice and guidance, after adding the chatid, the fucntion node able to work