Page 1 of 1

Template confusion. **solved**

Posted: Sun Jan 14, 2024 12:02 am
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.

Re: Template confusion

Posted: Sun Jan 14, 2024 12:25 am
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

Re: Template confusion

Posted: Sun Jan 14, 2024 12:44 am
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!

Re: Template confusion

Posted: Fri Jan 19, 2024 7:47 am
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)

Re: Template confusion

Posted: Tue Jan 30, 2024 10:49 am
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
.

Re: Template confusion

Posted: Mon Feb 12, 2024 12:01 am
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).

Re: Template confusion

Posted: Mon Feb 12, 2024 12:34 am
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!