Any way to scrape getChildAndRouteInfo?

I have created my own dashboard in html/javascript on my local windows webserver and I'm really happy with it. However, I am having difficulty with my Zigbee network quality and I'm frustrated with the lack of tools provided to assess it. The getChildAndRouteInfo webpage provides some data, but it's extremely difficult to read the unformatted data (can't they at least put it in a table?). I'd like to grab that content and display it within my own code, but the web is very unforgiving of any web scraping and loves to hand out CORS errors when trying it.

Is there any API that I can use or other ways to get the data from the Hubitat into my webserver? I'm not trying to steal anything here - just get the data from devices I own.

This community app has better info that the built in feature IMO, and you could probably see how he is gathering it. [Zigbee] Visual render for getChildAndRouteInfo

Or use the built in graph:
image

2 Likes

After he created that graph, HE staff added a new endpoint getChildAndRouteInfoJson to make it trivial to scrape.

3 Likes

You should be able to avoid CORS issues by having the webserver request the data from the hub and make it available to your dashboard. (Something like a reverse proxy configuration.)

(Note that, assuming you have hub security enabled, the request probably needs to be authorized, so you may need to have some code on the server that handles the login process.)

Glad to see that getChildAndRouteInfoJson is now available. However I'm still unable to get it into my webpage because of CORS. (the graph is great but doesn't provide quantified data). Being a coding novice I'm very frustrated with everything I 've read about cors. I don't have hub security enabled and I'm just running my own dashboard code on my local webserver (192.168.1.199:12345) but this code just will won't run. Can anyone give me an example of what I need to do here?

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>Trying to scrape something from Hubitat...
 and Getting CORS errors.</p>

<script>
  url = 'http://192.168.1.137/hub/zigbee/getChildAndRouteInfoJson';
  fetch(url)
    .then((response) => {
      return response.json();
    })
    .then((data) => {
		console.log("DATA:" + data);
    })
    .catch(function(error) {
      console.log(error);
    });
</script>
</body>
</html>

Here's the errors:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://192.168.1.137/hub/zigbee/getChildAndRouteInfoJson. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.

TypeError: NetworkError when attempting to fetch resource. test3.html:19:15