Use HTTP GET to log your TWINE triggers
  • TL/DR:  Log your twine triggers with my server: http://twinelog.yoyo-pete.com

    I see people trying to get their device working and there are issue about 'Did Rules Trigger?' or 'Did it not trigger or did I just not get the SMS'.

    I created a way for anyone (with a twine and internet access) to configure their twine with an HTTP POST rule and have it log their trigger actions.

    Example:

    Rule is "When TEMP is GREATER THAN 72 degrees"

    Action is "Send me an SMS"

    For some reason, I'm not getting SMS alerts.  Is my twine really triggering?  Well to find out I can add a HTTP POST call to my rule.  When the rule triggers, that HTTP POST will create a record on my server and then when you view my server, it will show all the requests that have come from your IP.

    Note that you must supply a URL variable with the GET REQUEST.


    Here's how to set it up:

    1. Log into your twine's web console. https://twine.supermechanical.com/ 
    2. Click on the 'Rules >' button to view your rules.
    3. On an existing rule, click 'Add an Action' and select 'HTTP Request'. 
    4. Enter the following into the field for URL to log the temperature. 
    5. Click the 'Test URL' button. 
    6. Visit the page in your browser to see the log from your twine:   http://twinelog.yoyo.pete.com

    Note:
    YOU MUST HAVE A URL VARIABLE FOR THIS TO WORK. 

    TWINE WILL ONLY SEND THE FIRST VARIABLE
     http://twinelog.yoyo.pete.com?test=anything   will log 'test=anything
    This is an issue with Twine's servers as only the first variable is sent in the request string.

    Post questions and comments below and I'll do my best to help and address things.


  • 14 Comments sorted by
  • Thank you!!  I will give it a try.
  • Hmm.  Doesn't seem to be working for me yet.  The URL is:


    and I did just get an email trigger that is supposed to be the same rule as this, but it didn't get logged.  I'm sure the new ruleset was saved because I changed the email text slightly and I got an email with the new text, but either the HTTP didn't fire, or else the HTTP query isn't coming from the same IP as my house.  Your site works fine when I just enter a URL with a variable directly in my browser.

    Does the HTTP query come from the Twine?  Or from Twine's servers?  If it comes from Twine's servers then it seems like your log won't work for me unless I know what the Twine's ruleset server IP address is.
  • And indeed, that is the issue.  When I substiute 107.21.16.90 (the IP of twine.supermechanical.com) for my own home URL, I can see the log file of my most recent attempts to get it to work (I assume it's mine since it has the same info that my Twine was showing in my browser window).
  • Ah... You are right.   I built this at work while my twine was home.  Seeing it log the IP, I assumed it was my home, but it's the twine.supermechanical server logging it.

    I should change the text on my page and remove the IP stuff so it can be used, but note that your twine would be intermixed with anyone else using it... Still it can be used for validation/troubleshooting.


  • Updated it to ignore the IP stuff since it only comes from one IP.

    Also, here is source (in case someone wanted to see how the php side works).

  • As an aside: I tried to use NimBits but the URL appears to be too long? Is there a limit on the HTTP string length?

    many thanks

    _Chris
  • Yes... Not sure how many characters, but the form truncates it if you get too long.

    And you can only have one variable.  So  URL?a=1&b=2 will only submit a=1.  Not sure if you're running into an issue like that.  I dont know how nimbits works.  Can you post an example of the URL?
  • an example would be 

    http://nimbits1.appspot.com/service//service/currentvalue?value=[Temperature]&point=test&email=bsautner@gmail.com&format=double&secret=yournimbitssecet

    I think! I haven't been able to test using the web interface.
  • Each & symbol represents another variable in the string.  So your GET really is like this:

    Submit to: http://nimbits1.appspot.com/service//service/currentvalue

    Fields
    value=[Temperature]
    point=test
    email=bsautner@gmail.com
    format=double
    secret=yournimbitssecet

    The problem is that the twine server only sends the first field in the get, so what is going out would be:
    http://nimbits1.appspot.com/service//service/currentvalue?value=[Temperature]

    The rest of it will be truncated.
  • @YoYo Pete: It's strange that you're only getting the first variable. I'm passing two variables to ThingSpeak (a key and a value), and it is working well.
  • I dont know...

    I make this call in my browser:  http://twinelog.yoyo-pete.com?v1=A&v2=B

    And it logged this: 
    2013-01-25 15:46:07 v1=A&v2=B

    When I used the same from the Twine dashboard, it logged this:
    2013-01-25 15:46:50 V1=A





  • Does anyone know if Twine is working on a solution to get a second variable sent? Or are people just creating a second rule? 
  • I'm sending my variable like this:  

    http:/twinelog.yoyo-pete.com?v=YoYo-Pete.[temperature].[orientation].[open/closed].[shaking/still]

    The output is:

    Date Time Request String
    2013-01-29 23:12:29 v=YoYo-Pete.Door.Open.78.unknown

    Then on my server, I can use php exploded to get an array of variables to work with.

    $twine = explode(".", $_GET["v"]);

    That should create an array.

    $twine[1] = YoYo-Pete
    $twine[2] = Door   (This is so I know it's a mag switch mounted on the door that triggers when it opens)
    $twine[3] = Open  (Status of switch)

    And so on.

    My rule says:

    trigger after open for 1 second
    untrigger after closed for 10 seconds

    (Because my housemate likes to stand with door open)
    P.S.  This is just code I typed in and not compiled or tested.
  • I just discovered this: http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/

    I'm going to set this up for myself (since it's free {I think} compared to 'Notify my Android' which is a real nice service but if you use more than 5 alerts a day, you have to pay).

    My thought is that I set this up for myself at first, using the POST method from twine (as that's most reliable it seems) and see if I can get an alert to my phone.   I "might" be able to set it up for other folks to leverage, but Android development is new to me (but I actually am a programmer, so I have that going for me).

    I'll start a new thread about the Android Push Notifications using Google Cloud Messaging (GCM) when I get it started.  I've got my server and database setup, so just need time to code.  Unfortunately, dont have that today.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!