template.cgi document type not json **solved**

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

Moderator: Mattk

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

template.cgi document type not json **solved**

Post by staze » Tue Mar 19, 2019 9:14 pm

Hi all,

I've been working on some integration with home automation, and noticed that template.cgi doesn't return "content-type: text/json" it returns "content-type: text/plain" in the headers.

Is this intentional?

For reference, here's my call to template:

http://<meteobridge ip>/cgi-bin/template.cgi?template=%7B%22forecast%22:%7B%22text%22:%22[forecast-text:]%22,%22code%22:[forecast-rule]%7D,%22current%22:%7B%22date%22:%22[M]/[D]/[YY]%22,%22time%22:%22[H]:[mm]:[ss]%20[apm]%22,%22humidity%22:[th0hum-act=.2:null],%22indoorHum%22:[thb0hum-act=.2:null],%22temperature%22:[th0temp-act=F.2:null],%22dewpoint%22:[th0dew-act=F.2:null],%22heatIndex%22:[th0heatindex-act=F.2:null],%22windChill%22:[wind0chill-act=F.2:null],%22indoorTemp%22:[thb0temp-act=F.2:null],%22indoorDew%22:[thb0dew-act=F.2:null],%22highTemp%22:[th0temp-dmax=F.2:null],%22lowTemp%22:[th0temp-dmin=F.2:null],%22rainfall%22:[rain0total-daysum=in.3:null],%22rainLastHour%22:[rain0total-sum1h=in.3:null],%22evapotranspiration%22:[sol0evo-act=in.3:null],%22rainRate%22:[rain0rate-act=in.3:null],%22pressure%22:[thb0seapress-act=inHg.2:null],%22windGust%22:[wind0wind-max10=mph.2:null],%22windAvg%22:[wind0wind-act=mph.2:null],%22windDegrees%22:[wind0dir-act:null],%22windSpeed%22:[wind0wind-act=mph.2:null],%22windDirText%22:%22[wind0dir-act=endir:null]%22,%22pressureTrend%22:%22[thb0seapress-delta1=enbarotrend:N/A]%22,%22dayHours%22:%22[mbsystem-daylength:]%22,%22highHum%22:[th0hum-dmax=.2:null],%22lowHum%22:[th0hum-dmin=.2:null],%22sunrise%22:%22[mbsystem-sunrise:]%22,%22sunset%22:%22[mbsystem-sunset:]%22,%22dayMinutes%22:[mbsystem-daylength=mins.0:null],%22uvIndex%22:[uv0index-act:null],%22solarRadiation%22:[sol0rad-act:null],%22lunarAge%22:[mbsystem-lunarage:],%22lunarPercent%22:[mbsystem-lunarpercent:],%22lunarSegment%22:[mbsystem-lunarsegment:null],%22moonrise%22:%22[mbsystem-moonrise:]%22,%22moonset%22:%22[mbsystem-moonset:]%22,%22isDay%22:[mbsystem-isday=.0],%22isNight%22:[mbsystem-isnight=.0]%7D%7D#

Maybe there's something wrong with that call (some way to specify for meteobridge to return json typed data)? This is on a Meteobridge Nano SD, btw. Running 3.9 (17/3/2019)
Last edited by staze on Wed Mar 20, 2019 2:35 am, edited 1 time in total.
Davis Vantage Vue, Weather Envoy, Meteobridge Nano SD

User avatar
staze
Expert Boarder
Expert Boarder
Posts: 86
Joined: Fri Jan 18, 2019 2:56 am
Contact:

Re: template.cgi document type not json

Post by staze » Wed Mar 20, 2019 2:31 am

Found it here: https://www.meteobridge.com/wiki/index. ... n_Services

Specifically, needed to add "&contenttype=text/json" to the end.
Davis Vantage Vue, Weather Envoy, Meteobridge Nano SD

SANdood
Senior Boarder
Senior Boarder
Posts: 54
Joined: Wed Jan 28, 2015 1:36 pm

Re: SOLVED: template.cgi document type not json

Post by SANdood » Wed Mar 20, 2019 7:05 pm

I've been working this with @staze, and the problem turns out to be that his platform (Hubitat) does not accept "&contenttype=application/json" as specified by my application (although SmartThings does). Hubitat wants "&contenttype=text/json", which of course SmartThings doesn't recognize.

So, the solution was that I had to modify my code to specify the supported contenttype for each platform.

Post Reply