Use IFTTT to save value to Google Spreadsheet

I connected my energy meter to openHAB and can now see the current meter readings. However I want to record these values to a Google Spreadsheet. IFTTT can connect the openHAB item to Google, however I’m still unclear how to define the recipe.

The following does not work:
IF Item_State changes to [blank] THEN add a row to spreadsheet
IF Item_State raises above 1 THEN add a row to spreadsheet

Assuming that the current item state is 4711 the following works:
IF Item_State raises above 4711 THEN add a row to spreadsheet

The latter is not practicable since it would mean that I always have to update the recipe with the most current value.

So any ideas how to create a recipe that records the values which are increasing by 1 over time like:
IF Item_State raises by 1 THEN add a row to spreadsheeet


Have you considered just saving every update to the spreadsheet even if there is no change? Then you could do some sort of unique filter in the spreadsheet?

Why not, but how to create an appropriate IFTTT recipe? As far as I got it currently only state changes with fixed values are supported.

Is there any possiblity to check whether the value is odd or even? A recipe could then look like:
IF value changes to true THEN …

Currently IFTTT / openHAB integration seems to be very limited - or to put it the other way round: Is anybody using IFTTT with openHAB and if yes what is the application?

What energy meter have you got connected ( directly?), just i have an EnvIR unit connected by serial port that i used to use with a web gui/logger but not figured how to get the data into openhab, Thanks


Had no such scenario in my head. I think we will add an ‘Item changed state’ trigger which will be triggered every time when item value changes, then you will be able to log such changes to google spreadsheet.
Configuring certain period of persistence in persistence config for this item in openHAB will enable you to adjust a period of such events and log the value once a day, for example.

Best regards,
Victor Belov

That would be great, thanks! Have an EMH-ITZ meter connected via the Volkszähler USB IR reader. If you are interested I can tell you more.

Any news about the IFTTT integration?

Have you tried messing about with the IFTTT Maker channel?

After adding the channel and setting it up with your key you and then trigger recipes with it, and send data to it.

You could set up a recipe that listens for a event trigger (e.g. energy_updated )

In openHAB you would set up a script that is triggered by whatever rule you fancy.

The script then sends a curl request to the maker channel

curl -X POST -H "Content-Type: application/json" -d '{"value1":"new value fa la la","value2":"new value fa la la","value3":"new value fa la la"}'

Then voila:

It is not super pretty and I am sure there are many more efficient ways to achieve the same thing, but it gives you an idea of how you can link things up using anything you can send a HTTP request from (pretty much everything)

The Developer APIs from Google are also very good, though they do require a seasoned developer’s hand :slight_smile:

Good luck

1 Like

Thanks, I’ll try that!

Is there an update on the original question?

Is maker still the way to go? IMHO having any value change triggering the recipe should be very useful.


I nearly got there. Only fighting with the exact string format.

Curl from command line works:

curl -X POST -H “Content-Type: application/json” -d ‘{“value1”:“some value1”,“value2”:“some value2”}’

In my script the following calls Maker but doesn’t seem to pass values correctly. The resulting line in Google Spreadsheet is empty:




Victor: any progress on being able to accept any kind of item changes as an IFTTT trigger? I’m trying to forward text from a String Item to my phone so I need to trigger the rule every time there is new text.


1 Like

I don’t really understand the quirks myself, but I have managed to get the following working

// item

Number   Temp_Outdoors_F "Outside Temp [%.1f °F]"  <temperature>   (gAll, gChart)   {rfxcom="<33536:Temperature"}
// rule

rule "send temperature to IFTTT then Google Sheets"
    Item Temp_Outdoors_F changed
    var String value_1 = Temp_Outdoors_F.state.toString()
    var String command = String::format("curl@@-X@@POST@@-H@@Content-Type: application/json@@-d@@{\"value1\":" + value_1 + "}@@")



I can’t get the second or third value to parse though. I have tried all sorts of combinations of escaping the comma and quotes. As well as using @@ between parameters as mentioned in the wiki

Notice the “@@”. This is neccessary, because the executeCommandLine does not support using quotationmarks. To send the http header as one string, all other spaces need to be replaced by the delimiter “@@”.

It will do for now I suppose.

… I just tried to send the post request to IFTTT using NodeRed and MQTT, it was very easy to do. So I think I will move to that solution. I highly recommend NodeRed, it is very handy (though I feel like I am cheating when I use it ) :slightly_smiling:


Hello everyone,
due to the fact that i lost some experimental stuff i did, i recently had to rework my rule to push values to Google Spreadsheet via IFTTT Webhook.

I wanted a slim solution only from Rule DSL and hat a bit a hard time regarding all the formatting (again).

Problems i had

  • Slim conversion of Date-timestamp of yesterday
  • Numeric value needs , instead of . for spreadsheets
  • Correct usage of executeCommandLine for OH3
  • Missing Values if multiple executeCommandLine are executed without sleep inbetween

So for others having the same intention → See my code below

Im not a very advanced openHAB user but i think the implementation is ok
ATTENTION: This code only works with OH3 since executeCommandLine needs each argument separately, divided by comma

I use the maximum of 3 values for

  • Name/Tag
  • Timestamp for provided value
  • Value

→ this way i just push all numbers i want to into the spreadsheed
→ The filtering / searching / post-processing of the acquired data can then be done in spreadsheets directly

Improvements could be done:

  1. Create Date & curl-ingredients only once at start → For my approach i kept it individual for each value
  2. Somehow get it done to use the executeCommandLine as function with providing val* as parameter → Maybe someone has a solution for that
  3. If you see more, feel free to suggest some

I hope this is helpful and thanks for the informations in this topic

rule "Spreadsheets"
    Time cron "0 0 3 * * ?"

    // Variable declaration (Directly as String, because executeCommandLine needs strings)
    var String val1
    var String val2
    var String val3

    val1 = "PowerConsumptionLivingRoom" // Naming
    val2 = String::format( "%1$te.%1$tm.%1$tY", now.minusDays(1)) // Timestamp for Value
    val3 = (NUMBERITEM1.state as DecimalType).toString.replaceAll("\\.",",") // Numeric value, with replacing of . by ,
    executeCommandLine("curl","-X","POST","-H","Content-Type: application/json","-d","{\"value1\":\"" + val1 + "\",\"value2\":\"" + val2 + "\",\"value3\":\"" + val3 + "\"}","") // curl-command with right formatting
    Thread::sleep(5000) // I discovered that executing multiple curls can cause lost data if there is not enough time inbetween

    // Next curl (only as example)
    val1 = "PowerConsumptionBedRoom"
    val2 = String::format( "%1$te.%1$tm.%1$tY", now.minusDays(1))
    val3 = (NUMBERITEM2.state as DecimalType).toString.replaceAll("\\.",",")
    executeCommandLine("curl","-X","POST","-H","Content-Type: application/json","-d","{\"value1\":\"" + val1 + "\",\"value2\":\"" + val2 + "\",\"value3\":\"" + val3 + "\"}","")