Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text script or JSON creator
#1
Hello to all. New to Virtuino IoT.

I have a question on how to use the test script or Json creator widget.

My JSON text is the following:

{
"CID":
{
"deviceID":"SN23030001"
},
"measurments":
{
"weight":{"value":$C1_V1,"valid":$C1_V5},
"tempe1":{"value":23,"valid":true},
"tempe2":{"value":14,"valid":true}
},
"status":
{
"power":
{
"Battery":$C1_V2,
"mains":$C1_V4,
"devicePower":$C1_V3},
"health":
{
"code":0
}}}

I made it as the examples says so.
I selected the OUTPUT variable to be one of my MQTT connection (e.g V10)
and now I need to create / activate this function of JSON->Variable

There is no input or enable variable to do so.
How can I have the final JSON text to my V10 variable to send it via MQTT?

Thank you.
Reply
#2
Hi,

use $C1_Vx.value instead of $C1_Vx1
like this:

{
"CID":
{
"deviceID":"SN23030001"
},
"measurments":
{
"weight":{"value":$C1_V1.value,"valid":$C1_V5.value},
"tempe1":{"value":23,"valid":true},
"tempe2":{"value":14,"valid":true}
},
"status":
{
"power":
{
"Battery":$C1_V2.value,
"mains":$C1_V4.value,
"devicePower":$C1_V3.value},
"health":
{
"code":0
}}}


I have checked. It works fine!
Reply
#3
Good morning,

Thank you for your reply.
I missed the (.value). It is working fine now.
Are there any other .properties availble?

Also, I noticed something that I do not understand.
I use NodeRED for debbuging / testing mqtt messages.

With my project unalerted, sometimes the reception of the JSON message in nodeRED is in Text format and sometimes an Object

I uploaded an image.


Attached Files Thumbnail(s)
   
Reply
#4
Hi,

you can use the suffix  .date except of the .value
You will get the timestamp of the value.

The app sends the messages as Strings. I don't know why it happens. 
it's strange behavior. Υou can check the values of the variables. They are the only ones who change.
Reply
#5
Thank you.

the .date suffix is very useful to me.

As for the Text /object representation in nodeRED, I will test it more.
It is not critical for now.

I think this tread must close.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)