CloudDB incorrect values received

I’m trying to update sensor values using CloudDB.
I’m using redislab server with free subscription.

The issue is, I update a tag say “x:val” with a comma-seperated value=“50,60,70,80,90”.
However, the CloudDB GotValue block only receives “50” trimming the rest of stuff from and after the comma.

I rechecked the tag values from redis-cli and the values are stored correctly on the server.
However the GotValue is unable to retrieve the complete string.

Is it a bug?
Is there another way to achieve what I’m trying to do?

You probably need to use a different delimiter, one that CloudDB/Redis won’t treat as a field separator.

Try “|” or “-” between your numbers 50|60|70… or 50-60-70. You will need to do a bit more work on your code going up and coming back, but hopefully you will get it all!

Thanks Tim!
I used “|” as separator and that works flawlessly!

That said, it’s still a bug with GotValue block!
Maybe To-Do for subsequent versions.
Using comma-seperated data would be very helpful.

I checked it with Firebase, and firebase has the same issue with GotValue block.
It seems the block thinks comma as a field seperator.

Sarvesh

If I send 50,60,70,80 as a value to store, getValue is returning all of it

What format are you sending the data up with, plain text or as a list/json ?

I am sending data up using the arduino-redis library.
The method takes a char array as parameter.
So I’m converting a string using toCharArray() method.

Why not just send the string?

No String method available in the arduino-redis library.

Although I do not use it (arduino-redis) and have no experience of it, I find that quite hard to believe...surely one must be able to send a string value. How would you set a key value pair of "myValue":"Hello World" ?

The method definition to set key value pair in arduino-redis library is
set(const char *key, const char *value)

http://arduino-redis.com/classRedis.html

Meanwhile, I have found a workaround!

If I store the comma-seperated values between quotes, then the CloudDB components correctly retrieves the string WITHOUT quotes.

For example, in redis server, I store the string as “50,60,70,80” (including quotes) and CloudDB GetValue retrieves it as 50,60,70,80 but as I said, it could be improved in subsequent releases.

Sarvesh

That is not a workaround, that is how you should store it if you want to avoid to online storage from using the delimiters. AI2 stores it that way, you just don’t see the double quotes because they are “in” the text block.

Thanks Tim!
However, wouldn’t it be an issues when you need to append the values?

But you are posting a string myVals:“50,60,70”, so you would replace it with a string myVals:“50,60,70,80”, or add another field with more values myVals:[[“50,60,70”],[“80”]] or post your data as individual fields in the first place myVals:[“50”,“60”,“70”] - you can probably post this as a string and it will be recognised as a list.

The CloudDB component serializes and deserializes the values as JSON. By wrapping the CSV in quotes you are turning it into a JSON string. You could just as well wrap it in square brackets to make it deserialize as a list. This is not a bug but is the intended behavior.

Oh that’s great!
In that case I might be able to use any of the JSON extensions to compile/extract data.

or the new dictionary blocks :wink:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.