Virtuino Forum

Full Version: Text script or JSON creator
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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!
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.
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.
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.