Jump to content
C4 Forums | Control4

Data Capture


cdepaola

Recommended Posts

So web programming is not my forte what so ever but I know there are a lot of smart folks here, thought I'd throw this out.

My utility, ComEd publishes live pricing information for those of us on the Residential Real Time Pricing program. I'd like to capture this data, if possible, to import into C4 and use as programming variable. The problem is they have no API or this would be an easy project and take me about 10 min of work to program. The website the data is published on is a public site, no log-in is needed and it can be found here ComEd RRTP Live Pricing .

With a little help from FireBug I can isolate the code showing the data to this:

<script>
$(document).ready(function() {
$(".actual").load("/rrtp/ServletFeed?type=instanthourly");
$(".predicted").load("/rrtp/ServletFeed?type=instantpredicted");
$(".instant").load("/rrtp/ServletFeed?type=instant");
});
</script>
<div id="price-bar" class="clearfix">
<div class="price-bar-bg">
<div class="container">
<div class="actual prices">
<p class="price">
7.1
<small>¢</small>
<strong> per kWh </strong>
</p>
<p>Real-Time Hourly Price 4-5 PM CT</p>
</div>

If I go to the web address that the script references - rrtp/ServletFeed?type=instanthourly then I see...

<html>
<head></head>
<body>
<p class="price">
7.1
<small>¢</small>
<strong> per kWh </strong>
</p>
<p>Real-Time Hourly Price 4-5 PM CT</p>
</body>
</html>

Thats is, nothing else on the page that the script references. So with this, and if you care to look at the website, any insight into if this data can be captured?

Thanks!

Link to comment
Share on other sites


So, you would need to modify the weatherbug driver for that url, and parse the html result like an xml file and store your value in the <body> tag, first child, <p> value.

Beyond that, you need to know LUA, drivers, and web requests and headers. But take a look at the sample weatherbug driver and shouldn't be too hard to go from there.

Link to comment
Share on other sites

I don't suggest people use the WeatherBug driver as a sample anymore, it was one of the first DriverWorks drivers, and has a ton of bad programming in it.

If you're in 2.X, there are much easier ways to get web data (C4:urlGet, for example), and better ways to parse it (XML or JSON parsers in Lua).

RyanE

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.