Apple script to send temperature (or others) to pachube.com

Posted on
Sat Dec 26, 2009 9:45 pm
cullenfluffyjennings offline
Posts: 4
Joined: Sep 17, 2009

Apple script to send temperature (or others) to pachube.com

I wrote a script to send data from indigo up to pachube. From there you can make some interesting graphs and others of the data.

You can find the script and instructions at
http://www.dial911anddie.com/weblog/200 ... -software/

Posted on
Mon Dec 28, 2009 11:06 am
matt (support) offline
Site Admin
User avatar
Posts: 19173
Joined: Jan 27, 2003
Location: Texas

Re: Apple script to send temperature (or others) to pachube.

Great -- thanks for sharing. I signed up for a beta pachube account quite a while back, but never got around to trying it out with Indigo.

Image

Posted on
Sat Jan 02, 2010 2:29 pm
Matt offline
Posts: 406
Joined: Aug 13, 2006
Location: Northern Idaho

(No subject)

This is going to be awesome if I can get it to work :)

I created a Pachube.com account and started a manual feed with two data streams.

I copied and pasted your code and changed a few variables around. I entered my Pachube account keys where they belong, but I get an error everytime the time/date action triggers.

I had to change around a lof of " characters as the ones in your applescript were making my computer choke. I also noticed a bunch of ' or something so I got rid of those, and the applescript still does not run.

The log error is this: Problem with posting to pachube. curl result is:Unauthorized

The applescript I am using looks like this:

set myPachubeAPIKey to "myAPIKey"
set myPachubeFeed to "http://www.pachube.com/api/feeds/####.csv"

tell application "IndigoServer"
    set myTemp to value of variable "outside_Temp"
    set myHumidity to value of variable "outdoor_humidity"
end tell

try    
    set myRes to do shell script "curl –request PUT –header "X-PachubeApiKey:myAPIKey" & –data & myTemp & "," & myHumidity & " " & myPachubeFeed
    if myRes is not equal to " " then
    log "Problem with posting to pachube. curl result is:" & myRes        
    end if
on error
    log "Error execting curl to post to pachube.com: Result was " & myRes
end try

That has got to be close, I just can't figure out what is wrong. I have a hunch it has to do with the " and ' that I replaced or removed from the applescript.

Can you please help?

Posted on
Sat Jan 02, 2010 5:35 pm
asw24b offline
Posts: 222
Joined: Dec 30, 2007
Location: Los Altos Hills, CA

(No subject)

Matt wrote:
This is going to be awesome if I can get it to work :)

I created a Pachube.com account and started a manual feed with two data streams.

I copied and pasted your code and changed a few variables around. I entered my Pachube account keys where they belong, but I get an error everytime the time/date action triggers.

I had to change around a lof of " characters as the ones in your applescript were making my computer choke. I also noticed a bunch of ' or something so I got rid of those, and the applescript still does not run.

The log error is this: Problem with posting to pachube. curl result is:Unauthorized

The applescript I am using looks like this:

set myPachubeAPIKey to "myAPIKey"
set myPachubeFeed to "http://www.pachube.com/api/feeds/####.csv"

tell application "IndigoServer"
    set myTemp to value of variable "outside_Temp"
    set myHumidity to value of variable "outdoor_humidity"
end tell

try    
    set myRes to do shell script "curl –request PUT –header "X-PachubeApiKey:myAPIKey" & –data & myTemp & "," & myHumidity & " " & myPachubeFeed
    if myRes is not equal to " " then
    log "Problem with posting to pachube. curl result is:" & myRes        
    end if
on error
    log "Error execting curl to post to pachube.com: Result was " & myRes
end try

That has got to be close, I just can't figure out what is wrong. I have a hunch it has to do with the " and ' that I replaced or removed from the applescript.

Can you please help?


Yes... the sample code above seems to have gotten corrupted when it was pasted in.


I am sending only one temp value.

Here is the code that I am using:

(Thermotemp is the parsed temperature string that I get back from my Proliphix thermostat)


Code: Select all
            set myTemp to (Thermotemp as real)
            
            
            try
               set CommandString to "curl -m 120 -S --request PUT -H "X-PachubeApiKey: " & myPachubeAPIKey & "" " & "--data " & myTemp & " " & """ & myPachubeFeed & """
               set myRes to do shell script CommandString
               
               if myRes is not equal to " " then
                  log "Problem with posting to pachube. curl result is:" & myRes
               end if
            on error
               log "Error execting curl to post to pachube.com: Result was " & myRes
            end try
            
            log "ran the temp log script temp=" & myTemp

Posted on
Sun Jan 03, 2010 1:17 am
Matt offline
Posts: 406
Joined: Aug 13, 2006
Location: Northern Idaho

(No subject)

That fixed it. Thanks!!!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest