Template confusion. **solved**

This section covers the Meteobridge PRO, PRO2, NANO SD, Raspberry Pi and VM platforms exclusively

Moderator: Mattk

Post Reply
User avatar
staze
Gold Boarder
Gold Boarder
Posts: 197
Joined: Fri Jan 18, 2019 2:56 am
Contact:

Template confusion. **solved**

Post by staze »

Hi All,

I'm trying to make a simple template that generates a very simple XML file, and I cannot figure out what the heck I'm doing wrong.

I have a NanoSD.

Template file has been added into the templates folder in data, I called it "weathercat.exp" (not sure if this is right). It's just

Code: Select all

<value>
	<name>AirTemp_C</name>
	<data>[th0temp]</data>
</value>
<value>
	<name>IntTemp_C</name>
	<data>[thb0temp]</data>
</value>
<value>
	<name>RH</name>
	<data>[th0hum]</data>
</value>
<value>
	<name>IntRH</name>
	<data>[thb0hum]</data>
</value>
<value>
	<name>Barometer_hPa</name>
	<data>[thb0press]</data>
</value>
<value>
	<name>WindSpeed_ms</name>
	<data>[wind0wind]</data>
</value>
<value>
	<name>WindDirect_deg</name>
	<data>[wind0dir]</data>
</value>
<value>
	<name>Rain_mm</name>
	<data>[rain0total-daysum]</data>
</value>
I'm trying to call it from HTML Generation, and that looks like

Template: weathercat
File: weathercat.xml

Hitting "test" it generates a weathercat.xml file in /data/html, but all that file contains is the word "weathercat". =(

I'm missing something obvious here. Or just doing this completely wrong.

Also not sure how to actually GET to that via (if I can) via web. http://<meteobridgeip>/html/weathercat.xml doesn't work. /data/html/weathercat doesn't work, etc.
Davis Vantage Vue, Weather Envoy, Meteobridge Nano SD
Mattk
Platinum Boarder
Platinum Boarder
Posts: 1387
Joined: Mon Sep 22, 2014 3:24 am

Re: Template confusion

Post by Mattk »

An .exp file is a specialized template file that when run as a [Data Export] creates a .txt file on a line by line basis relative to the Time Frame & Resolution. You won't be able to call a .exp file using HTML generation (as such).

Depending on your SMB config/password MBPro/Win version etc you should be able to reach the data folder with \\meteobridgeip\data\

With a HTML template I typically FTP that and access it from the server
User avatar
staze
Gold Boarder
Gold Boarder
Posts: 197
Joined: Fri Jan 18, 2019 2:56 am
Contact:

Re: Template confusion

Post by staze »

Hey MattK,

Okay, hmm. So the goal here is to create an XML file that Weathercat can ingest. Is my best bet writing some php that meteobridge sends values to (like the Saratoga template, basically)?

Thanks!
Davis Vantage Vue, Weather Envoy, Meteobridge Nano SD
User avatar
staze
Gold Boarder
Gold Boarder
Posts: 197
Joined: Fri Jan 18, 2019 2:56 am
Contact:

Re: Template confusion

Post by staze »

Is it possible to output a file locally on the meteobridge (maybe into a ram disk) that could be read by a local machine?

Just looking for more "traditional" XML (as referenced above) that Weathercat can understand (it doesn't understand the built in livexml output)
Davis Vantage Vue, Weather Envoy, Meteobridge Nano SD
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7854
Joined: Mon Oct 01, 2007 10:51 pm

Re: Template confusion

Post by admin »

when you put the file into the /data/templates/ folder and give it a ".txt" extension like "weathercat.txt" you should be able to reference this file from the http call to

Code: Select all

http://ip-of-your-meteobridge/cgi-bin/template.cgi?templatefile=weathercat.txt
.
User avatar
staze
Gold Boarder
Gold Boarder
Posts: 197
Joined: Fri Jan 18, 2019 2:56 am
Contact:

Re: Template confusion

Post by staze »

Perfect, thank you! Now I just need to get weathercat to actually recognize the output (the MB output looks exactly like I'd expect, I just had to change everything in my example to -act).
Davis Vantage Vue, Weather Envoy, Meteobridge Nano SD
User avatar
staze
Gold Boarder
Gold Boarder
Posts: 197
Joined: Fri Jan 18, 2019 2:56 am
Contact:

Re: Template confusion

Post by staze »

Would it be possible to implement an option to be able to set the Content-type in template files? Right now, templates just come back as "Content-type: text/plain". Would be nice if we could set something like "application/xml" (or text/xml) or "application/json", etc.

Could just be a variable set at the top of the template file?

Thanks!

oop, just noticed you can do "&contenttype=application/xml". Perfect!
Davis Vantage Vue, Weather Envoy, Meteobridge Nano SD
Post Reply