Setting Hub variable from google sheet, issue with comma in string

Hi!
Not sure on the category but here the problem. I have a hub variable with string connector type. I fill this variable with google sheet cell (importdata from maker api) and its working. The only thing is that I use a cell value that is made by concatenate multiple cells with some text: name, lastname and email address.

The formula wont pass to the hub my string as soon as it contain coma. Even if I use texte() in formula or TO_TEXT() nothing to do!

Not sure on how to deal with this, the coma is still part of string...any ideas could help and also, maybe this would help adjusting the accepted character in the string type variable!

Thanks!

Is this a duplicate of the your other post?

I again think you are likely dealing with a Google Sheets problem, which I am not familiar with. Perhaps someone who is can help with that. Testing the /trigger/setHubVariable endpoing directly and URL-encoding the @ sign to %40 just worked for me in a test I tried with this URL directly. So, there does not seem to be anything wrong on the hub side,

Try testing with the URL yourself to verify, then you'll narrow down where the problem is.

Yes, I made this post to see and maybe it will give some clue if the variable part needs to be updated!
For now I use a doc at the place of coma and it’s working… coma seems to not be considered as string…

Commas are generally regarded as string separators...

2 Likes

Along the lines of the above, have you tried URL-encoding the comma (,) as %2C to see if that helps?

1 Like

no, inside my concatenate it cut the string one step before it. example: conacatenate("hello";"world";"this %2C is a test") will ruturn : hello world

using doc is ok but I just dont know what the problem could be and if its on the google sheet side or the variable side. If I try to add numbers or something, it wont pass the value, the variable stay empty like when I use the coma so hard to tell! Maybe someone that have access to test the code could help understand and see if updates are needed but its weird .
The @ is ok, I was thinking it was not but when removing all coma it pass it well.

There is an easy way to answer this question, and it's to leave Google Sheets out of the picture for a minute, as I did above when testing the URL directly.

For example:

http://192.168.0.5/apps/api/10249/trigger/setHubVariable=myVariable:example%20value?access_token=xxxxxx

Where the IP address is the IP address if your hub, 10249 is the app ID of your rule, myVariable is the name of your variable, and example%20value (i.e., "example value") is the URL-encoded value to set, and xxxxxx is your access token.

Most of these pieces will be provided for you in the Rule Machine UI when you create or edit the trigger, so just replace /trigger in the example URL with /trigger/setHubVariable=... and whatnot. (You might have a cloud URL instead of a local URL, and that's fine too -- just test this one in a similar manner using the rest of the URL pieces provided.)

I have not find how to make it works, I replace averything in the url but not working... I ll try to edit the value manually to see. The only utility for that coma is because I made a skills to make my alexa read a cell content so I activate it with a virtual sensor. So I replace the cell content and then activate the sensor that trigger a routine that use the skill...
So without coma she speak very quickly so I use a dot now to make her peused between certain words...
But I would like to know the issue in case of and for my knowledge! :slight_smile:

Obviously I can use coma when edit manually. So its within the importdata() formula. Its getting hard to know from there what the problem is and to speak with anyone from google... Probably its the way the formula convert the data. I had this trouble from calendar events but that was time and date value so by using text() I set the format and then consider it as string. But not the coma...

I am no longer sure what you think the problem is. The title of this topic claims that there is a problem with certain characters in hub variable strings when set via the HTTP API (or at least that last part is implied). If you still think this is the case, the only way you can substantiate that claim is to know exactly what you are sending to that HTTP API. Constructing a URL manually as I suggested is probably the easiest way to do that. If you can identify a problem there, it can probably be fixed. My suspicion would be lack of URL encoding. I am not sure if you have done this.

I have demonstrated that this works for me in the two cases I've tried.

If it works there, there is a problem with something in your Google Sheet. I do not know what data in your sheet, exactly how you are concatenating it into the string you are ultimately providing to this HTTP API, or what else might be going on there, but if you can rule out the above, you've ruled out a Hubitat problem and now know that you just need help with Google Sheets.

If you still need help, can you be more specific about exactly what you have tried that does and doesn't work?

(I still suspect you just need help with something in Google Sheets, which I am unlikely to be able to provide--but I don't even know exactly what you are doing there.)

Yes, thanks for your help! I think it should be in the formula so google side. I was not able to make the api address you gave me to works but if you say its working from your side its probably from the google side.
The concatenate is simply a cell with Hello&world&email and I use 3 different cells to extract hello in the first one, world in the second one and the email in the last one. I use find(), left() and mid() formula to extract the data. Then I use concatenate("hello here the data";cell1;cell2;cell3)

Then the importdata formula to fill the variable is linked to the concatenate() cell.

Another thing that I saw is that it cannot return empty value. I try to find how to empty the variable too, not sure if its possible.

A variable must have some value, but you can use an empty space for a string.

Or %20 for URL encoding. :slight_smile:

in my sheet I cannot because the empty string seems not to be returned. The variable not updating.
Its not too bad, I ll try to set it in webcore at the place, for what I do it ll be ok! :slight_smile:
Thanks for your help!

Thanks for this, but my connector is string type and I try to pass "hello, world" and its not working because of the coma, even if I use texte("hello, world";"") or TO_TEXT("hello, world"). Normally the coma inside string like this should be taken by the connector and set the variable correctly.

Here the print screen, look the formula, just because of the coma, my variable is set to: HELLO

Thanks, have a nice day!

here the formula

Thanks for your help!

encode url for a coma? looks a little overkill and my @ is working well, its pretty weird.
I ll try it but the need to encode my coma in a string makes no sense to me!

its not working, the coma part of the concat() not there. Everything I try to pass works perfect without urlencode except the coma that is not working.

Its returning: HELLOWORLD

we have not the same formula... mine comes from the api maker, like I found it in a post that explain how to extract cell value to hub variable...
Not sure on why I should use /trigger/ and not setvariable like in my formula?