MB Pro templates and Conditional Expressions **solved**

All about the standard Meteobridge devices based on mobile routers from TP-Link, D-Link, ASUS

Moderator: Mattk

Post Reply
Tiktok
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: Sat Jan 09, 2016 11:52 pm

MB Pro templates and Conditional Expressions **solved**

Post by Tiktok »

"Add on services - additional features of Meteobridge Pro" describes the facility to store templates in the /data/templates/ network share and call them using http://ip-of-meteobridge/cgi-bin/templa ... ydata.http. I am trying to use this feature with a template which includes conditional expressions but cannot get the conditonal expressions to work - are conditional expressions allowed in templates used this way?

I have tried using the example conditional expression from the end of the Templates examples on its own in a template file stored in /data/templates/:

Max gust in last 10 minutes was: #if#{*[wind0wind-age:999]>600*}#then#--#else#[wind0wind-max10.1:0]m/s, {*[wind0wind-max10.1:0] * 3.6 *1}kph#fi#

but this then returns the following when called from the URL :

Max gust in last 10 minutes was: #if#0.00#then#--#else#6.6m/s, 23.8kph#fi#

The numerical expression is being evaluated but the conditional expression is not then processed.
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7874
Joined: Mon Oct 01, 2007 10:51 pm

Re: MB Pro templates and Conditional Expressions

Post by admin »

Good finding! I checked the source and if-then-else evaluation was missing for that use case.
I added this. If you send me your MAC, I can make the changed code available for you so that
you can give it a try, before it goes into production later on.

Please send MAC to "info(at)meteobridge.com".
Tiktok
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: Sat Jan 09, 2016 11:52 pm

Re: MB Pro templates and Conditional Expressions

Post by Tiktok »

I have sent the MAC to info(at)meteo...
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7874
Joined: Mon Oct 01, 2007 10:51 pm

Re: MB Pro templates and Conditional Expressions

Post by admin »

Thanks. I made your unit working with latest beta code and now calling "http://ip-of-your-mbpro/cgi-bin/templat ... urrent.url" returns this:

Code: Select all

Data for .....
DayofWeek, Month 11, 2016 13:17

3.3°C (high 3.4°C 12:57, low 1.8°C 08:57)
DP 1.8°C
Humidity 90.0%

Wind (10 min avg) 1.1 mph, High 4.3 mph WSW
Max gust 7.4 mph 04:27

980.9mb steady (high 983.2mb 00:00, low 979.5mb 06:46)

0.0 mm rain last 24 hours
94.6mm rain this month
94.6mm rain this year
The "if-then-else" clause is now evaluated. Next update will bring these changes to the public.
Tiktok
Fresh Boarder
Fresh Boarder
Posts: 15
Joined: Sat Jan 09, 2016 11:52 pm

Re: MB Pro templates and Conditional Expressions **solved**

Post by Tiktok »

Perfect thankyou :D
Post Reply