hello, the flow would stay like this, I have been trying things since this morning before asking and I am not able to solve it,
From telegram I ask for the temperature and the s7 node changed to content, but when making the swich I do not know how to configure it so that if I enter / Temperature it debuts me as content only the value of the temperature that I read from the PLC Please if you could show me an example, I would appreciate it
on the other hand, I would not know how to change the Home temperature msg to a content with the necessary fields to send it to telegram, the fields are those of the image content ,,
Previously there was a s7 node that also had an input but now it has changed to some other node I do not know either. The input would have allowed to trigger reading of the temperature when a message from Telegram arrives but now as there is no input on the HomeTemperature node, my previous example won't work.
I assume the HomeTemperature node is sending the temperature by itself by some interval? This would mean you would need to save the latest value somewhere. And that somewhere would be the flow context. You can read about it here: https://nodered.org/docs/user-guide/context
The idea would be to save the latest temperature in the flow context and then when a message requesting temperature arrives, you use a change node to set the msg.payload.content
to the value you have stored in the flow context.
I have also tried it, but it gives me an error when sending the telegram and I understand that it is because it does not have the structure of the message it is waiting for
this structure and I don't know how to create it
Add a debug node after the s7 node to see what it outputs. It was only a guess previously that it would send the value as msg.payload
. Then you will known where to move the value in the change node. As I don't know how the Telegram node you have works either, you need to read the instructions from the sidebar to know the data format.
If you still have problems, you can post a screenshot of what the s7 node output to debug is and also another screenshot of the Telegram Sender node instructions from the sidebar. Otherwise I would just be making guesswork.
You can set all the values in a change node. I doubt you need to have all that data filled. Check what the node instructions tell.
telegram message structure
Ok so the value is stored as the first index of an array msg.payload.value
. To read it in change node you would use msg.payload.value[0]
. The temperature value looks like it would need a conversion to a human readable value though. Possibly @Steve-Mcl could help with interpreting that if needed(?)
You have sent this already. I was asking to send the help text you get on the sidebar info tab when you have the Telegram Sender node selected. It would likely help also if you could send a screenshot of its configuration (you can first erase any personal info if it has).
does not put any relevant information in the help text
telegram input node configuration
telegram output node configuration
Ok. I wonder if the documentation it has here is everything there is then https://flows.nodered.org/node/node-red-contrib-chatbot? The example isn't very helpful.
Have you tried to create the simple 3 node example flow there? Did you get the message sent that way? If so, what you could do is add a debug node after the Message node and this will tell the format of the message to be sent. Or was the screenshot you sent earlier done like this already?
yes I did but I implement it in a moment and I'll show it to you
Maybe the easiest would be to add a Message node after your /Temperature node and then use change node to just change the msg.payload.content
. Everything else would be filled in already. The problem is that if you would then pass it through the s7 node, it would replace the payload
. This would not be a problem with the flow context approach I described earlier.
So you would have a flow:
Telegram Receiver - /Temperature - Message - Change node - Telegram Sender
In the change node you would replace msg.payload.content
with the temperature value from a flow
context where you would periodically update the latest temperature in a separate flow.
There would be multiple ways to accomplish the same but I'm too tired for the day to think of a better one. Hopefully someone else can chime in with their ideas.