Page 1 of 1

Numerical Expressions **solved**

Posted: Thu Jan 21, 2021 9:49 pm
by hymrog
Hi

I have been testing out different computations using info provided in the Numerical Expressions of the wiki. All seem to work as expected with the exception of the addition/plus function.

I am just using the ip adderess of my RPI with following for testing:

Code: Select all

 http://myip address/cgi-bin/template.cgi?template={*[th0temp-act=F]+[th0temp-act=F]*}
Not sure if the issue is something new as this is the first time I have tried to use the numerical expressions.

Platform: Raspberry Pi Model B+
SW Version: Meteobridge 5.1 (Jan 18 2021, build 1915), FW 1.3

Thanks
g

Re: Numerical Expressions

Posted: Fri Jan 22, 2021 5:59 am
by AlaskaWX
I can't get addition with the "+" operator either. Must be a bug...

Re: Numerical Expressions

Posted: Fri Jan 22, 2021 8:11 pm
by galfert
There is no bug. Your math is correct and it works exactly like that if you decided to use it in a script or event.

But since you are attempting to format it in a URL then you need to properly escape special characters. URL formatting has its own set of requirements. In this case the + sign is a special character. You can escape it with %2B as follows:

http://<your-IP>/cgi-bin/template.cgi?template={*[th0temp-act=F]%2B[th0temp-act=F]*}

If you need escape codes (also called percent-encoding) for other characters, you can reference this table or others like it:
https://www.w3schools.com/tags/ref_urlencode.ASP

Re: Numerical Expressions

Posted: Fri Jan 22, 2021 9:56 pm
by hymrog
Hello -

Confirmed that your solution works. Did not even think of this since all other expressions appeared to work within the URL without using the escape characters.

Much appreciated
g