I'd like to create an IFTTT action that allows triggers based upon a certain electricity price threshold. This Xively feed can return the current price in either JSON, XML, or CSV formats. Xively's API reference is here.

Is there any IFTTT channel/tool that will allow me to read a single value and act accordingly from any of these formats? Or is there a workaround I can use to translate the data for use with a channel that might not allow it directly?

  • You can have a Google Spreadsheet with a script acting as an intermediate tool: it can get the data using ImportData, ImportXML or ImportFeed, extract the number you want, and send an email based on the value. – user79865 Aug 1 '15 at 16:14

Based on Normal Human's answer, I've created a Google sheets script that will parse and email IFTTT based on a price threshold. Google sheet cells won't update ImportXml() or other external site data more than once every hour or so, even using workarounds. However, accessing external sites via the script works. Use the following script and set up a trigger to have it run every one minute.

I've bypassed the Xively feed and gone straight to the source at Comed, since I'm writing the parsing script. There appears to be no XML/CSV/JSON parsing channel at this time on IFTTT.

Customize the threshold (presently 5.0) to whatever you'd like. You can also modify the code and use hash tags in the subject to create more complicated actions in IFTTT based on different price thresholds. For example, if the price was >5 you could tag the email #MEDIUM_PRICE, and set your thermostat to 78 degrees. If it were >10 you could tag it #HIGH_PRICE and set your thermostat to 82 degrees.

function myFunction() {
  var lastPriceCell = getThisCell(1,1);
  var lastPrice = lastPriceCell.getValue();
  var currentPrice = getPrice();
  var threshold = 5.0;
  var notify = false;

  if(currentPrice==null) {
    currentPrice = lastPrice;
  } else {
    // Notify only if last price was below threshold and current price is above threshold
    if(lastPrice <= threshold && currentPrice > threshold)
      notify = true;

  if(notify) {
    var text = "Price Alert!" + currentPrice; 
    MailApp.sendEmail("trigger@recipe.ifttt.com", text, text);

function getThisCell(i, j) {
  return SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1").getRange(i,j);

function getPrice() {
  var price = (/([\d\.]+)]]/).exec(getData());
    return price[1];

function getData() {
  return UrlFetchApp.fetch("https://rrtp.comed.com/rrtp/ServletFeed?type=pricechartfiveminute");
| improve this answer | |

My suggestion:

  1. Create a Google Spreadsheet with either ImportData (for CSV), ImportXML (for XML) or ImportFeed (for RSS/Atom). There is a trick to make it update more often than the Google default (whatever it is).

  2. Have a Google Apps script comparing the data in a particular cell to a given threshold. It can run every hour, and send an email when needed.

For example, you can scrape the aforementioned xively page with the following spreadsheet commands:

  A1 =IMPORTXML("https://personal.xively.com/feeds/4014","//script[3]")
  B1 =REGEXEXTRACT(A2,"current_value[^,]*")
  C1 =VALUE(REGEXEXTRACT(B1,"[\d.]+"))

The cell C1 contains 2.6 as of now.

| improve this answer | |
  • One other issue I'm working through with this solution: The particular feed I referenced requires authentication. So far in my searches I'm not finding an easy solution to using ImportData with simple authentication. – glenviewjeff Aug 2 '15 at 1:57
  • 1
    The personal.xively.com page appears to be publicly accessible, though. The spreadsheet can get the data from it. It's slighly cumbersome, since the number is JS-inserted, but possible -- see the updated answer. – user79865 Aug 2 '15 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.