Help porting DTH from ST (meteobridge)

Not sure if this is the right place, but I'm needing some insight on how to port a DHT from ST.

I am really trying to get data from my personal weather station (Davis Vantage Vue) into HE. I have a Meteobridge Nano SD, that I really like. And turns out there's a DTH for talking to it.

But, the code doesn't "just work". Pasting it in, I get warnings about HubAction being an unsupported action.

Specifically the error is:

unable to resolve class physicalgraph.device.HubAction @ line 818, column 21. unable to resolve class physicalgraph.device.HubResponse @ line 836, column 26.

And while I didn't get a warning, I also note it's calling "include 'asynchttp_v1'" which I also thought was a no-go on the HE.

My Groovy experience is pretty low, but I'm starting to learn so I can handle potentially writing drivers, etc.

Anyone have any insight?

Thanks!

replace physicalgraph with hubitat is the first step.

1 Like

Awesome, thanks.

I at least got it to save now... it is still throwing an error about base64 encoding (guessing it's trying to save my meteobridge password at least partially encoded).

Going to keep looking into it. It's not returning any data... so something isn't working right.

okay, found solution on forums for that...

Hubitat supports asynchronous http calls as outlined below

1 Like

Okay, I'm stuck now. I've forked the code over, made changes, it saves, and it acts like it should work, but I think there's something wrong with just swapping physicalgraph with hubitat when it comes to line 839:

def meteoWeatherCallback(hubitat.device.HubResponse hubResponse) {

Would really love some help if anyone has any ideas.

https://raw.githubusercontent.com/staze/MeteoWeather/master/devicetypes/sandood/meteobridge-weather-station.src/meteobridge-weather-station.groovy

So for whatever reason, Hubitat doesn't store a json response in hubResponse.json, it stores it in hubResponse.body.

I... don't understand why.

To be more clear, I had to also parse hubResponse.body through jsonSlurper.

def jsonSlurper = new JsonSlurper()
variable = jsonSlurper.parseText(hubResponse.body)

You'll need to check the response coming back from the server and let us know. HubResponse.json is populated automatically if the server responds back with a content type of text/json or application/json. If it is returning that and it still is not populated then we can take a look to see where we might have a bug.

Also you can remove the entire tiles section in your code.

1 Like

Hi @chuck.schwer

So interestingly, it does respond with "content: text/plain". So it doesn't seem to be a bug... will have to ask the Meteobridge dev about that.

Thanks about tiles section info!

What I still can't figure out is why debug seems to be being set. Maybe I'm blind... but it's set to false up top.

Hi Chuck,

so, MIGHT be a bug after all. It looks like Hubitat may properly process text/json and populate HubResponse.json... but passing it application/json may not work.

Working on confirmation tests...

@chuck.schwer yup. text/json works, but application/json does not (hubitat doesn't auto-parse to hubResponse.json).

is there any more to the Content-Type header? I do see an problem where if the header includes extra information like charset it does not parse correctly. I put in an issue to fix it.

according to chrome, the header is only:

Connection: close
Content-type: application/json
Transfer-Encoding: chunked