The Twine forums are now archived. If you need help, please visit http://help.supermechanical.com

API

2»

Answers

  • Thanks for sharing Jay, that scripts works great!
  • I've taken the twine.sh script above and have the temperature (just the first two digits, since it temp is returned as a four digit number) sent to a channel on ThingSpeak. 

    I then have React and ThingHTTP setup to use the Airgram push service (like Prowl but free and works on Android), to alert me if a certain temperature is reached.

  • Hey guys - 5 months since my last post. Any update on an API?
  • Looks like the link to fetch the JSON data from your twine is now dead.
  • Hmm, never mind.  The URL I had was different.  Strange.
  • An API for collecting data from the Twine would certainly be useful. The current 30 action per hour limit is very restrictive, and the current rule capabilities are trivial. Let's say i want to know if the temperature in my freezer goes above a certain limit *and stays above for 30 minutes* (because during a defrost cycle the temperature can exceed the limit, but i don't care). Or maybe i really care about the trending pattern in the sensor history in a custom way. Squwk.com can handle stuff like this, so it would be nice to be able to tell twine to deliver data there (while also checking the twine site for firmware upgrades and such).
  • Hmm, I wonder if something changed again. Just noticed that the wget is returning most of the information except everything in the values section is blank.

    Any ideas?
  • Ok, you have to change the url to use twine.cc for it to report the items properly again.

  • Is there any kind of data dictionary for the JSON that is returned here? 
    I'm trying to figure out the abbreviations and the difference between some of these fields. What does 

    {"gs_version": "Oct 31 2012-08:21:10", "age": 107688.28125, "ts": 1372774784.0, "values": [["0000b41e7bfd804900", "2.0.2"], ["0000b41e7bfd804901", 7100], ["0000b41e7bfd804903", "top"], ["0000b41e7bfd804905", 2687181], ["0000b41e7bfd804906", 0], ["0000b41e7bfd804907", 0], ["0000b41e7bfd804904", 0], ["0000b41e7bfd804902", 0]], "rssi": 198, "ruleset_id": "35075", "last_poll": 1372774528.0}

    Obviously 0000b41e7bfd8049 is my Twine ID. 
    I'm guessing age is the amount of time that's passed since the last reading in seconds.
    "top" would be the orientation of the Twine. 
    "7100" is the temperature with an implied decimal. 

    What are the rest? Is this documented anywhere outside this thread?

    Thanks,
    Tom

  • OK. To answer my own question, I found this other thread with input from John Kestner: 

    That explains all of the values. 

    I'm still unsure on gs_version, age, ts and last_poll. Any help?

    Thanks,
    Tom
  • gs_version = radio firmware version date  (hover over your twine, the date here will match that shown in radio version)
    age = how long it has been since the twine last submitted an update
    ts = ?? possibly a timestamp for something?
    last_poll = ?

  • Anybody had problems with the values coming back blank when calling from wget, curl. I get values when querying https://twine.cc/zzz/rt?cached=1 from the browser

    Fixed - Found I needed to use cookies in order to get the values
  • Jay Erickson,

    Thanks for your script.

    I ended up butchering it for my own use.

    One bit I ended up changing was the method for changing the 5-digit temperatures to 2-digit.

    Your truncation breaks for temperatures over 100°F.

    Initially, since the temperature of the external sensor I am using was always over 100°, I simply truncated at three digits. Imagine my surprise when it dipped below 100° - instantly my graph peaked to 997!

    In any case, I replaced:
    TEMP=${TEMP:0:2}

    With:
    let TEMP="TEMP/100"

    That seems to work as intended.
  • does anyone have a (near) complete list of (undocumented, unofficial, subject-to-change) API calls?

    i know about

    https://twine.cc/ID/rt?cached=1

    what i would like to know is how i can get the list of IDs associated with my login, and a list of sensors identifiers associated (i.e.., do i just care about the last octet, e.g., 7b=moisture, d6=magswitch,a6=breakout, or is there some other mapping involved)

    any pointers?

    thanks!
  • Take a look at the post several replies up.

    I've gone ahead and written a plugin for my Vera 3 ZWave Home Automation controller that lets me poll the twine and use things like its temperate in applications.

    Just another hack along the same lines as the script above.

    You can find information about it here (and get the Lua code for the plugin):


  • many thanks... i suspect i'll be asking you a question or two (-;
  • Some days has past and I want to know if there is something new to say to the API? Still no way to get data directly from twine device?
  • Is an API in the work or is this a dead prospect? Should I retire my Twine and move on to an Raspberry Pi + temperature options?
  • I also had blank values with the https://twine.cc/ID/rt?cached=1 URL, but fixed it by adding the access_key parameter.
Sign In or Register to comment.