Ubidots_in - fail return value

Hi!
I’m using IOT2040 from Siemens.
I’m using simple readout data from my S7-1200 PLC with Ubidots_out and this works fine.

BUT, I’m trying to use Ubidots_in and it fails.


I have configured a Switch in Ubidots account. Then I connected a Ubidotd_in node to the Switch.
After the Ubidots in node I have put a function node to process the data from Ubidots on my Node-red.
With the following code:

var A=msg.payload.value;
msg.payload=A;
return msg;

Then I have a Debug node and getting the following error, each time I switch the state of the switch.

msg : error
“TypeError: send is not a function”

Do you have some idea what is the problem ?

Hi @htrendafilov ,

If you have a close read to the Ubidots_in node Docs, you’ll see that the output of the node has the below structure when the “Last value” checkbox is selected:

{
  "cmd_send_email": {
    "value": VALUE
  }
}

Which means that your function node should look as follows to work correctly, as least as yo expect

var A=msg.payload.cmd_send_email.value;
msg.payload=A;
return msg;

Furthermore, is there any particular reason why you’re sending a down command to have your Node-red flow sending an e-email instead of using Ubidots built-in events engine which support Email alerts?

–David

I think we are in a small misunderstanding :slight_smile:
The send_email is just coincidence.
My idea is just to send a command or some number to my PLC.
For example I would like to send command - Open a Valve to my PLC from Unidots.
But when I make a switch on my dashboard and try to connect “Ubidots in” node to that switch
there is an error.
I also tried your code but it didn’t help.
The error message ig generated each time I operate the switch on my dashboard!
My idea is later to send to my PLC the % open position of the valve too - vith a slider on the dashboard.

But there is something wrong :slightly_frowning_face:

002 Open valve 1|690x299

.

@htrendafilov

Can you attach a debug node right after the ubidots_in node and print msg.payload and then send a screenshot of whatever is printed with the debug node?

Did you mean that ?
I pressed the switch 2 times.

@htrendafilov

Yes that’s what I meant. It seems as there’s an issue with the ubidots_in node. Can you please advise the version of the nodes you’re using, it should be v2.0.1. This can seen as follows:

  1. Click the hamburger icon in the top-tight corner
  2. Select the Manage palette option
  3. Look for Ubidots nodes and see the version

I went ahead and did a test myself with the same flow I asked you to test and it worked:

Also, can you make sure that your Node-Red version is greater to v1.0 and if not, update your Node-Red package running the command (as described here):

sudo npm install -g --unsafe-perm node-red

–David

Hi!
I’m back and still have the same problem with Ubidots_in.
I reimaged my SD card and run some commands to be sure I have the latest versions.
But I’m not sure I do it right.

  1. I reimaged the SD card from image for Siemens IOT2040
  2. I got to changed directory “cd .node-red” and then I ran “npm install -g --unsafe-perm node-red” to update my node-red
  3. Then I chaned to directory “cd /usr/lib/node-modules/” and ran “npm install ubidots-nodered@2.0.1”

I rebooted several times meanwhile. Set the Node-Red to auto start on reboot.
But still the same fail.
I’m not sure, do I have the correct version of Node-Red and do I install the nodes and node-red on right place.

I also registered a file in directory “/etc/opkg/iotd.conf”
with the following definitions:

src iotdk-all http://iotdk.intel.com/repos/2.0/iotdk/all
src iotdk-i586 http://iotdk.intel.com/repos/2.0/iotdk/i586
src iotdk-quark http://iotdk.intel.com/repos/2.0/iotdk/quark
src iotdk-x86 http://iotdk.intel.com/repos/2.0/iotdk/x86

Still I don’t understend why Ubidots_in is not working.
I have reimaged my SD card several times, and I remember the first time I did it I could use Ubidots_in. So I’m missing something now.

[Hello!
I’m continuing my struggling to get my Node-Red receive commands and data with Ubidots_in node.
Now I have bought Raspberry PI 4 to check if it works better than IOT2040, but if you watch my video you will se the same problem. Ubidots_in is generating a Fail when I try use it.
I have read out the version data from Raspberry PI 4
Ubidots-nodered 2.0.1
npm 6.14.4
Node-Red 12.18.0

I was really hoping to add IOT as a part of my company services.
And your server functionality seems very interesting to combine with PLC.
But we have to make that working.

Please check what could be the reason.
While I was testing IOT2040 on my first tests everything worked fine.
But then I needed to reimage the SD card and after that it is not working.
So may be there is some version mismatch or I’m missing some preinstalled components which are used particularly from Ubidots_in node.

Thank you!

Here is a link to my video I have uploadet to my youtube:]

(https://www.youtube.com/playlist?list=PLNGzTye0NxwkyXvVHvK-5WInfcuhBgE5C)

Hi there, please find at the end of this message an export of an example node that I have just deployed at my local server that subscribes properly to the variable demo inside the device labeled as demo

You will need just to modify both device and variable labels and also to add your account token:

If this node does not work properly at your side, your network is probably blocking the secure port 8883, so you may try without TLS or to use another network.

I hope it helps you

example node

[{"id":"233473d4.7641cc","type":"ubidots_in","z":"8fc92465.403c18","tier":"business","name":"Ubidots in","token":"","device_label":"demo","tls_checkbox_in":true,"custom_topic_checkbox":false,"label_variable_1":"demo","label_variable_2":"","label_variable_3":"","label_variable_4":"","label_variable_5":"","label_variable_6":"","label_variable_7":"","label_variable_8":"","label_variable_9":"","label_variable_10":"","checkbox_variable_1_last_value":true,"checkbox_variable_2_last_value":true,"checkbox_variable_3_last_value":true,"checkbox_variable_4_last_value":true,"checkbox_variable_5_last_value":true,"checkbox_variable_6_last_value":true,"checkbox_variable_7_last_value":true,"checkbox_variable_8_last_value":true,"checkbox_variable_9_last_value":true,"checkbox_variable_10_last_value":true,"x":400,"y":180,"wires":[["d3084e1.9cfa8b"]]}]

Hello Jose!
I understand, your example is quite easy and should work.
But something is wrong and Ubidots_in doesn’t work for me.
I have reimaged my SD card for IOT2040 many times but no luck.
I was thinking… kan this be a version mismatch/problem.
Can I install an older version of Ubidots nodes? - please tell me how if I can.

You can see my Node-red, npm versions and Ubidots versions.

And each time I activate a Switch on Ubidots there comes the Error message to my IOT2040.
That’s why I think the connection is good between your server and my device, but
somthing is not good for Ubidots_in node.
I will repeat Ubidots_out works just fine.

image

image

Hi there, you can find my setup below:

image

I think that your issue is not related with your raspbian image but with a wrong setup or a network port blocking. My advices for you:

  1. Try upgrading your node version, it is too old and outdated versions usually comes with security risks.

  2. Use just the example that I have sent you, I see that you have other nodes in your deployment and I am not sure if your error is related with some of those nodes. Try to connect with ubidots in a clean environment and once you make it work you may begin to add more nodes.

All the best

Hello @htrendafilov,

I was finally able to reproduce the error you’re having. It’s all because your Node-Red version. Ubidots’ nodes require Node-Red v1 or above. I tested with your setup and the last Node-Red version before the v1 release:

image

And this is what had in return:

Now, after updating node to a more updated version as advised by @jotathebest, and updating Node-Red to v1.0.6

image

I get the Ubidots_in node working like a charm:

–David

THANK YOU VERY MUCH David !!!
So that is a version problem any way :slight_smile:
I have now updatet my Raspberry Pi to your versions (shown here) and I have contact with your server.
May I ask some more questions - as a beginner :slight_smile:

  1. Can you please give me an exapmple script to read boolean, integer / real , text values from Ubidots to my device (raspberry Pi -> PLC) I will use Ubidots_in node.
  2. I still have to make my Siemens IOT2040 working. Yesterday I couldn’t suceed to upgrade nodejs on it, if you have som instructions for update?
  3. Is it possible to install an older versions of Ubidots node ? And eventually how ?

Thank you once again !!!

Hi there, answering your questions:

  1. Can you please give me an exapmple script to read boolean, integer / real , text values from Ubidots to my device (raspberry Pi -> PLC) I will use Ubidots_in node.

All the Ubidots’ variable values are float type, and the nodered node_in will return this type of value every time that you use it. If you need to read text, you will need to send that text first using the dot’s context, you can find several examples to do that at our docs. The way to obtain context values is using the node_in without the last value option and parsing the key context in your node red function. You can find an example here of the node_in values format here.

  1. I still have to make my Siemens IOT2040 working. Yesterday I couldn’t suceed to upgrade nodejs on it, if you have som instructions for update?

As we just offer ways to send data to our platfom, this sort of support is better to be handled directly with Siemens.

  1. Is it possible to install an older versions of Ubidots node ? And eventually how ?

We strongly advice you to avoid to use old versions of our libraries, many bugs are solved with each new release including not only security risks but connection and data sending problems. If you wish to use older versions, under your own risk, you can find them at our github repository. Keep in mind that we do not give support to these old versions.

All the best