It's pretty easy to use Pachube's new trigger feature (also known as notifications and webhooks, etc). You might use the API to create a trigger, but the easiest way to get going is to use the web interface.
Triggers send HTTP POST requests to a URL of your choice when conditions that you set up on a datastream have been satisfied (e.g. value change, value exceeds threshold, value equals, etc.). The POST includes the parameter "body" that consists of JSON that looks like this:
{
"environment": {
"description": "",
"feed": "http:\/\/www.pachube.com\/api\/feeds\/343",
"id": 343,
"location": {
"lat": 55.74479,
"lng": -3.18157,
"name": "location description"
},
"title": "test feed yes"
},
"id": 1,
"threshold_value": 9.0,
"timestamp": "2009-09-07T12:16:02Z",
"triggering_datastream": {
"id": "0",
"url": "http:\/\/www.pachube.com\/api\/feeds\/343\/datastreams\/0",
"value": {
"value": "9.07624035140473",
"max_value": 9.99650150341,
"min_value": 0.00471012639984
}
},
"type": "gte",
"url": "http:\/\/www.pachube.com\/api\/triggers\/1"
}
Trigger notifications will be sent whenever your datastream breaches the triggering threshold, but only at the actual point that the threshold is crossed. This means that for a '>' trigger, you will only be notified at the point that your datastream value changes from being less than the triggering threshold to greater than it. Thereafter you won't receive further notifications until the datastream drops back below the threshold, and a subsequent update takes it over again. The same logic applies to other trigger types, i.e. '==' will only fire when your datastream value previously wasn't equal to the triggering value, and an update changes it to become equal to it. Thereafter it won't fire until it changes away and then back again.
This is a change to the previous delivery logic where we would notify you continuously while the datastream was in a triggering state, but only once every 5 minutes.
This also means that a 'change' type trigger will potentially generate a lot more outgoing notifications as we now will send out a notification whenever we receive a changed value for the datastream, rather than as previously also being limited to once every 5 minutes, so whatever script you have receiving the notifications needs to be able to deal with this.
Trigger tutorial
This tutorial will show how to set up a trigger on somebody else's feed that sends you an email when it exceeds a certain value. It's written in PHP, but you can of course use any scripting language to do something similar. For a script that sends Twitter tweets try this tutorial instead.
(If you don't have a host with PHP enabled, try googling for 'free php hosting').
- First select a feed and datastream that you're interested in. This doesn't have to be your own feed -- you can create a trigger on anybody's feed. Make sure you're logged in, then click on the "embed,history,triggers" link on the right under the datastream. You should find a slide-out panel appearing that looks like this:
- Next, if you want to test quickest, you can use PostBin, which is a web service that helps you debug triggers and webhooks: you set up a unique URL and then POST to that URL. When you browse to the URL you can see all POST requests logged there. Let's try that first since it gives quickest results (you don't have to do this).
- Once you're happy that it's working and that Pachube is sending data successfully, create your own script to deal with the POST data. Here is a little self-explanatory PHP script that takes POST data, extracts some variables from it and emails the info to you.
- Upload the script to your server and note the URL, something like http://www.mydomain.com/triggers/emailme.php -- this is the URL you will send your trigger to. (((If you want to trigger an Arduino, then you would have to set it up as a webserver, and extract POST variables. We'll get some tutorial code as soon as we can, but you might also check Arduino Webserver for more hints on how to do this))).
- Go back to the Pachube datastream, replace the previous URL (if you used PostBin first) and paste in your own URL. Click "update" (or create if this is a new one) and then debug, just as before.
- You should receive an email that looks a little like this:
To: Subject: trigger activated From: Date: Thu, 01 Oct 2009 12:10:11 +0000 Trigger activated by feed 1233, datastream 0, with a value of 22.1 at 2009-10-01T12:09:54Z. Complete trigger message: {"type":"change","environment":{"feed":"http:\/\/www.pachube.com\/api\/feeds\/1233","location":{"lat":51.5660000445388,"lng":-0.100593566894531,"name":null},"description":"Cross-platform app (built in Processing\/Java) to make the CurrentCost --> Pachube connection easier... almost plug'n'play... See http:\/\/community.pachube.com\/currentcost for more info.","id":1233,"title":"Current Cost plug-n-play"},"triggering_datastream":{"value":{"max_value":31.5,"min_value":17.5,"current_value":"22.1"},"url":"http:\/\/www.pachube.com\/api\/feeds\/1233\/datastreams\/0","id":"0"},"timestamp":"2009-10-01T12:09:54Z","threshold_value":"25.0","url":"http:\/\/www.pachube.com\/api\/triggers\/12","id":12} - Finally, click "close" to hide the panel. From now on, whenever that datastream exceeds the threshold value, you'll receive an email alerting you to the fact. Now go and build some more triggers!
Go to http://www.postbin.org/ and click "Make a PostBin". It will send you to a URL that looks something like http://www.postbin.org/1ijyltn
Now, go back to the Pachube datastream trigger input window and paste that URL into the URL input box. Set up the condition using the drop down menu to read "is >", enter in a triggering value (e.g. 20.0 means the trigger will actuate when that datastream value exceeds 20.0) and click "create".

You will now see two extra buttons, "delete" and "debug". If you click "debug" Pachube will make a POST to the URL you provided even though the condition may not have been satisfied. Click "debug", click "OK" to the two following pop-up windows and then go back to the PostBin URL you used (e.g. http://www.postbin.org/1ijyltn) and refresh it. You should see the page now containing the data that Pachube sent to it.

<?php
// retrieve the POST variable 'body' and stripslashes
// since PHP escapes strings in POST variables
$trigger = substr(stripslashes(file_get_contents('php://input')),5);
// decode the JSON
$json = json_decode($trigger);
// extract the variables
$environment_id = $json->{'environment'}->{'id'};
$datastream_id = $json->{'triggering_datastream'}->{'id'};
$value = $json->{'triggering_datastream'}->{'value'}->{'current_value'};
$timestamp = $json->{'timestamp'};
// build the message
$message = "Trigger activated by feed $environment_id, datastream $datastream_id, with a value of $value at $timestamp.\n\n";
$message .= "Complete trigger message: \n $trigger";
// use wordwrap in case lines are too long for email
$message = wordwrap($message, 70);
// then send the email -- be sure to enter your email address below!
if ( mail("youremail@domain.com", "trigger activated", $message) )
{
echo("email message sent. \n\n $message");
}
else
{
echo("problem sending email message. \n\n $message");
}
?>
Comments
Thanks: Nice to be able to set a trigger on someone else's feed :-)
Suggestion: even better if you could take multiple feeds and trigger on some expression that incorporates them e.g.
.. local outside temperature < 5 degC (from one feed)
.. and monthly_average (gas used) < budget (from another)
.. and time=5am
.. => trigger heating to come on earlier
If all these feeds were local to the application you would not need pachube to do something like this. It would, however, be very powerful if feeds from elsewhere needed to be part of the logic.
Re: Triggers (aka webhooks, notifications, etc.)
this could be possible, but probably quite complex to build (in terms of interface and api -- i.e. how do clients specify, in a simple programming sense, the various interdependent conditionals?); it's more efficient i think to build this kind of complex conditional-checking on the client side. i.e. set up a trigger on temperature for <5 degC, then when the client is triggered check (by pulling) (a) monthly average < budget; and (b) time; then (c) edit (via an API call) the trigger condition for the heating.
Re: Triggers (aka webhooks, notifications, etc.)
That's an eminently reasonable POV given that you are bearing the cost of development and I do agree that it could all be done client side.
The one idea that you might think about retaining is date/time. Without this some triggers would be firing *much* more frequently than needed and loading up the system unnecessarily.
To continue the example, if I have a temp threshold of 5 degC and the actual temperature crosses it several times daily I will receive and ignore a lot of triggers outside my time threshold.
I suppose I'm kind of anti-polling but I would justify that in terms of scalability.
Paul
BTW. For the same kind of reason, you may want to consider some kind of hysteresis to moderate traffic when a value hovers around a trigger threshold.
Re: Triggers (aka webhooks, notifications, etc.)
Hooked up my daily coffee counter [0] to a web-enabled tri color LED controlled by an Arduino Duemilanove with a WIZnet Ethernet shield [1]. The LED turns from green to red if the counter value is > 7. It was not even necessary to change the server code on the Arduino as the URI contains the entire command, e.g. POST /~arduino/led/00ff00 and the HTTP body is ignored anyway.
The debug triggers work fine! But until now (since more than 5 minutes), no real trigger event happened. This seems strange, as the trigger condition is clearly met. Any hints?
(UPDATE: To be sure it's not my Arduino server's fault, I added a PostBin trigger which does not fire either, except in debug mode.)
(UPDATE 2: Ok, now it seems everything works perfectly. Maybe I was not patient enough - the whole trigger idea is pretty thrilling!)
Regards,
tamberg
[0] http://www.pachube.com/feeds/1569
[1] http://212.126.162.83/~arduino/led (not always online)
Re: Triggers (aka webhooks, notifications, etc.)
Hi tamberg,
No, you were patient enough, it was another minor glitch in our implementation which hopefully should all be resolved now. Thanks for the feedback, and if you have any further problems/comments/suggestions, then please let us know.
sam@pachube
Re: Triggers (aka webhooks, notifications, etc.)
@paul_tanner
Hmm, I quite like the time related idea.
If I understand you correctly, you're suggesting that when creating a trigger you should be able to specify that the trigger should go off (if you'll excuse the terminology):
but I think I agree that for more complex compound conditions, like you describe in your first post, that that sort of functionality probably belongs outside the main Pachube codebase, either locally in the consuming client application, or in some external webhook/trigger aggregator app that could look for and notify of compound events occurring within arbitrary time windows.
I'm not entirely sure what you mean by the term hysteresis in this context. At the moment we have a simple fixed time constraint which controls how often notifications are sent out for a trigger, but I suspect you are talking about something more sophisticated.
Re: Triggers (aka webhooks, notifications, etc.)
As to the first point, I was thinking of something like a crontab to let you execute a trigger script periodically (when the specified condition is met). What you suggest above is one possible implementation.
The point about hysteresis also relates to the frequency of firing a trigger when the condition is a point on a curve that could have a low slope. Control systems will typically activate and deactivate at differnt points on such a curve. Thinking about that again now, this could be done with two triggers but they would fire frequently when the slope of the feed fluctuated near a threshold. This is, of course, managable at application level but the facility to get just one trigger at each threshold would be nice to have.
Paul
Re: Triggers (aka webhooks, notifications, etc.)
@sam: Providing means to pass HTTP(S) basic authentication credentials for a trigger would be useful to prevent unauthorized access to trigger URIs controlling actors. On the other hand, as long as the trigger URI is not published this might not be such a problem in practice.
Another suggestion is to somehow indicate that other users have installed triggers on your feed. So you have a chance to decide if a feed can be deleted without infuriating other users.
Regards,
tamberg
Re: Triggers (aka webhooks, notifications, etc.)
paul: re. hysteresis, i agree - this could be done relatively simply with some kind of 'margin' parameter (e.g. trigger >50 with a margin of 5 would mean that the datastream would trigger once when >50, and would not reset until it sinks below 45.
tamberg: we had a brief discussion about basic auth for trigger URLs but since we felt that either pachube users trust us not to publish their trigger URLs or, if they don't then they probably wouldn't trust us to protect basic auth credentials either! but do let me know what you think about this - we would certainly be willing to reconsider. one simple (though not, of course, super secure way) to minimise unauthorized access is to include a security-by-obscurity parameter in the trigger URL that you then check for server side. the second suggestion is a good one - perhaps there should be some means to tell at least who has created a trigger on your datastream (to encourage human-to-human conversations!).
thanks both for feedback!
Re: Triggers (aka webhooks, notifications, etc.)
@uh: Unfortunately you're not the only one I have to trust. And security by obscurity is not an option if someone listens to your traffic. But in such a scenario even basic auth makes sense only together with HTTPS. So for now I'm quite happy with your offer as it is.
Regards,
tamberg
Re: Triggers (aka webhooks, notifications, etc.)
Useful posts on security, Thx.
I think I would do a reverse lookup on the IP of any hit calling my triggerable process and check that it's attributable to pachube. Not perfect but useful nevertheless.
Paul
Re: Triggers (aka webhooks, notifications, etc.)
@paul_tanner: IP lookups get tricky if you're behind a gateway. Most internet-of-things related servers (as the one running on my Arduino) can not afford their own public IP address, so probably such gateways will be the norm.
Re: Triggers (aka webhooks, notifications, etc.)
Is it possible to add a trigger to the state of the feed (i.e. the 'live' / 'frozen' state) ?
I've not found it mentioned anywhere so, I'm going to presume not - however I would be particularly interested in having this available.
I currently have an arduino posting data, and there is the possibility that my internet connection could go down, the arduino gets stuck somewhere in the code etc... all of which would lead to the feed ceasing to be updated. If I was able to set a trigger to either email me, or trigger a similar script on my current webhosting (like a regular trigger currently does), then I could debug the problem more quickly, and get the sensor back online.
I'm thinking maybe a checkbox selection for notification on state change to 'live', and to 'frozen', and then an aditional config box to say 'and then every [x] minutes', which is similar to the kind of features other have already been requesting from what I can see.
This would no doubt help enourmously to keep the uptime of our sensors high.
regards,
-Andy
Re: Triggers (aka webhooks, notifications, etc.)
Hi Andy, thanks for the suggestion - we're going to be expanding the trigger conditions and this sounds like a useful one to include.
Re: Triggers (aka webhooks, notifications, etc.)
Having thought about this a bit more, changing from live to frozen might not be the best plan, as that is assuming that you are updating more frequently than the timeout period to trigger a change to frozen state.
A more likely scenario is to specify your own timeout, and then the every [x] minutes I mentioned before.
Re: Triggers (aka webhooks, notifications, etc.)
Very nicely done guys! Haven't great fun making Twitter bots based on the webhooks!
Re: Triggers (aka webhooks, notifications, etc.)
i've noticed that current_value is now value, when did this change? thankfully using postbin helped me work out why my code didn't work. good tip guys!
Re: Triggers (aka webhooks, notifications, etc.)
You're quite right - some of the JSON formatting for the site in general changed recently, partly because of the way that Rails handles it. We're going to be finalising the format soon, so that there aren't any unexpected changes like this, and we'll post back asap.
- Pachube support
Re: Triggers (aka webhooks, notifications, etc.)
Apologies for hitting the system rather hard this weekend (I was polling several feeds and received a rate limit slap, justifiably). We should have been using a set of triggers.
Coincidentally, at the beginning of this post you will see my earlier conversation with @uh on the subject. The app we are prototyping requires to detect changes on a growing number of energy feeds. So one issue is provisioning these triggers from our app (an energy usage aggregator).
The other concern is about the load on both pachube and our app with loads of data flying around in a fairly inefficient form. I'd quite like to reopen the discussions about somehow putting the part of the app that does the change detection inside a pachube app. Is this at all possible?
Paul
Re: Triggers (aka webhooks, notifications, etc.)
Created a trigger on 1539/1 and nothing happens when I press debug.
Is the system running OK?
Maybe there's some security feature I don't know about?
(Tried last night late and this morning.) Paul
Re: Triggers (aka webhooks, notifications, etc.)
The system is running fine, and we can confirm that triggers are working OK on other feeds, but for some reason feed 1539 in particular is having some issues -- looking into it now.
Re: Triggers (aka webhooks, notifications, etc.)
Hi Paul,
there was a new issue with your trigger caused by an incompatibility between the headers our delivery agent was trying to send, and a new proxy server we are now sending all outgoing requests through. This only affected trigger notifications of a certain size, which is why other notifications had been continuing to be sent ok.
---
Aside from this issue there has been a change to trigger sending logic, so they are now fire once rather than fire continuously. Hopefully this will make triggers a bit more useful, and a bit more efficient, but any feedback on this would be welcome.
We'll try and get the docs above updated to reflect this change as soon as possible.
---
If you're still having problems, then either mail us back, or reply here and I'll have another look at what's going on.
Re: Triggers (aka webhooks, notifications, etc.)
Minor feature request:
If you are processing a lot of triggers with a single script you get enough information to do so but with only ids and value it's necessary to call back to pachube to get any other parameters from the feed.
In my example I'm getting called from triggers on a lot of electricity feeds. These are in different units so I have to call back each time for those units.
I wonder if there could be a way to tell a trigger to send additional fields in its message??
THx. Paul
Re: Triggers (aka webhooks, notifications, etc.)
I'm trying to get a trigger working using the sample script above. I checked out the post using PostBin and it looks ok to me. I get an email at the specified address - but no content is sent along.
<?php // retrieve the POST variable 'body' and stripslashes // since PHP escapes strings in POST variables $trigger = stripslashes($_POST["body"]); // decode the JSON $json = json_decode($trigger); // extract the variables $environment_id = $json->{'environment'}->{'id'}; $datastream_id = $json->{'triggering_datastream'}->{'id'}; $value = $json->{'triggering_datastream'}->{'value'}->{'current_value'}; $timestamp = $json->{'timestamp'}; // build the message $message = "Trigger activated by feed $environment_id, datastream $datastream_id, with a value of $value at $timestamp.\n\n"; $message .= "Complete trigger message: \n $trigger"; // use wordwrap in case lines are too long for email $message = wordwrap($message, 70); $from = 'From: You < pachube>'; // then send the email -- be sure to enter your email address below! if ( mail("bluejay117@gmail.com", "trigger activated", $message, $from) ) { echo("email message sent. \n\n $message"); } else { echo("problem sending email message. \n\n $message"); } ?>Any suggestions to find out why an apparently good post is not getting decoded in the php script? The script is the same as above except for putting my email address in.
Thanks.
Re: Triggers (aka webhooks, notifications, etc.)
Try changing
to
$trigger = substr(stripslashes(file_get_contents('php://input')),5);which is more compatible. (Tutorial updated above too).
Re: Triggers (aka webhooks, notifications, etc.)
Yes - this definitely works for getting the post into the $trigger string. Should I be able to extract the variables in the same was as before? It seems like the json_decode doesn't work on this new string.
Re: Triggers (aka webhooks, notifications, etc.)
Yes, and json_decode is working fine (just tested) -- but if you're having PHP issues, best is to include more debug code in your php file -- we're not able to help very much because PHP is not our core expertise....
Re: Triggers (aka webhooks, notifications, etc.)
I appreciate the help. It seems like I'm getting a null in the $json_decode based on my test with this bit of code. Is there a better way to check that the decode is working for me than just trying to write this value to a file?
<?php $trigger = substr(stripslashes(file_get_contents('php://input')),5); // decode the JSON $json = json_decode($trigger,true); $environment_id = $json->{'environment'}->{'id'}; $File = "json-test.txt"; $Handle = fopen($File, 'w'); fwrite($Handle, "test4...\n\n"); fwrite($Handle, $trigger); fwrite($Handle, $json); fclose($Handle);Here's the output from this code (only part of the $trigger string here - it is one long line unlike what is shown below). There is nothing from the $json write.
test4...
{"triggering_datastream":{"value":{"max_value":1023.0,"value":"OPEN","min_value":0.0},"url":"http://api.pachube.com/v2/feeds/8803............
Re: Triggers (aka webhooks, notifications, etc.)
You could try taking the output code and pasting it into a test PHP script as a variable and finding out / debugging why json_decode is not working properly on your system. For info, this is a sample output of $trigger:
{"type":"change","timestamp":"2010-12-29T12:16:47Z","threshold_value":null,"url":"http://api.pachube.com/v2/triggers/981","debug":true,"triggering_datastream":{"value":{"max_value":688.0,"value":"684","min_value":650.0},"url":"http://api.pachube.com/v2/feeds/14080/datastreams/0","units":{"type":"","label":"","symbol":""},"id":"0"},"environment":{"description":"","title":"l test","id":14080,"feed":"http://api.pachube.com/v2/feeds/14080"},"id":981}note: that 'substr(...,5)' where $trigger is defined is to cut off the first five characters of 'php://input', which are "body=" -- is that the same for your system.
Re: Triggers (aka webhooks, notifications, etc.)
What version of PHP are you using for this check? I've seen some PHP comments about changes in behavior between versions 5.2.6 and 5.2.9 with json 1.2.1, for example.
Also, a test using this little bit of code:
produces the following results. So this some indication that the json_decode is working for at least this case:
{"type":"change","timestamp":"2010-12-31T06:37:31Z","url":"http://api.pachube.com/v2/triggers/983","debug":true,"threshold_value":null,"triggering_datastream":{"value":{"max_value":1023.0,"value":"CLOSED","min_value":0.0},"url":"http://api.pachube.com/v2/feeds/8803/datastreams/1","units":{"type":"","label":"","symbol":""},"id":"1"},"environment":{"location":{"lon":"-121.732753515244","lat":"37.9910599818292","name":"tbd"},"description":"Status of door limit switches and light sensor for chicken barn doors","title":"switch status","id":8803,"feed":"http://api.pachube.com/v2/feeds/8803"},"id":983} var2 = Array ( [a] => 1 [b] => 2 [c] => 3 [d] => 4 [e] => 5 )Re: Triggers (aka webhooks, notifications, etc.)
(If you don't have a host with PHP enabled, try googling for 'free php hosting').
Dont think so .....you need version 5.3 to have JSON support otherwise json_encode/decode error !!
So tried Google App Engine what a mess to setup GAE , Remail , python SDK , gem Ruby ........gave up
Is there a simple solution out there that just mails a trigger alert to an email address ?.
In your next versions include a box to type an email address to send trigger alert or does that mean pachube becomes a mailing service?
great product still very happy !!!!!
Re: Triggers (aka webhooks, notifications, etc.)
I you need to use PHP4 json_encode/ decode are not built-in. However, there are classes for that.
See http://techblog.willshouse.com/2009/06/12/using-json_encode-and-json_decode-in-php4/
Paul.
Re: Triggers (aka webhooks, notifications, etc.)
ok thanks for that suggestion still takes a skilled man to set all that up anything more simple that one can follow for the average user who wants to alert on a trigger value without having to go on a PHP course or having to find out if your Web hosting service supports it all ? (assuming you have an one).
Google App Engine is one way but does that mean you need to have that running on an "always on" computer to receive the HTTP post and "remail" it to your final destination email address. Notifo for Iphone supposed to work but doesnt which would be one way to get notification on a trigger value.
Any ideas/easyish tutorials welcome !!
Jean
Re: Triggers (aka webhooks, notifications, etc.)
@voodoocr
The current offering is intended for people with programming experience.
However, coming real soon (and already in beta) are "pachube Apps" that anyone (technical) can contribute and anyone (non-technical) can use.
You need one of these. I can't offer to write it for you now (pressure of of work) but may be able to help at some future time if no one beats me to it.
Paul
Re: Triggers (aka webhooks, notifications, etc.)
first of all:
thanks a lot for pachube - i really like it a lot !!!
................................................................................
TECHNICAL SKILLS ...
being not too much into programming
i agree to paul -
it might be more easy if one was able to simply send
a url to update/receive current data
(... as practiced at thingspeak - pls. see samples below -)
it would make things so much more easy (for me) ...
though i can imagine that there might be security concerns
that keeps the creators of pachube from offering this option;
................................................................................
... THINGSPEAK SAMPLES
.... change data on a thingspeak feed
http://api.thingspeak.com/update?key=USERSECURITYCODE&field1=0
.... download json, csv, xml data for a thingspeak feed
http://api.thingspeak.com/channels/0000/feed.json?key= USERSECURITYCODE
http://api.thingspeak.com/channels/0000/feed.csv?key= USERSECURITYCODE
http://api.thingspeak.com/channels/0000/feed.xml?key= USERSECURITYCODE
.... view chart for a thingspeak feed
https://www.thingspeak.com/channels/0000?public=true
Re: Triggers (aka webhooks, notifications, etc.)
@PchbmarcAccnt
Pachube has all the facilities you suggest, albeit with slightly different url structures. This topic is about triggers and it sounds like you don't need these at the moment. The security is a little tighter on updates (POST or PUT must be used) but this doesn't require programming as such. Go to the main API doc page for details.
Re: Triggers (aka webhooks, notifications, etc.)
thanks, paul - for the immediate reply and link!
i went through numberous tutorials and the API DOC,
could not find an answer ... am sure that it's described somwhere
but may you please give me a hint?
due to my lack of knowledge i tried the following
to simulate an input ...
......................................................................................................
TRYING TO ADD A VALUE MANUALLY
(... what do i need to change?)
... "00000" being a placeholder for my channel number ...
http://api.pachube.com/v2/feeds/00000/datastreams/1/datapoints
RESULT ------> "Method Not Allowed Only post requests are allowed."
......................................................................................................
......................................................................................................
......................................................................................................
THINGS THAT WORKED
all other tests worked, evaluating the csv etc. files is not a problem as well
......................................................................................................
ACCESSING THE CHANNEL'S JSON FILE
https://api.pachube.com/v2/feeds/00000.json
RESULT ------>
{"status":"live","location":{"ele":"0","domain":"physical","exposure":"outdoor","name":"marc's place","lat":50.0359736721955,"disposition":"mobile","lon":8.7451171875},"feed":"https://api.pachube.com/v2/feeds/00000.json","tags":["test"],"creator":"https://pachube.com/users/pchbmarcaccnt","title":"testfeed","private":"false","datastreams":[{"at":"2011-10-09T20:31:17.937441Z","current_value":"test","id":"0"}],"id":00000,"description":"just testing options","version":"1.0.0","updated":"2011-10-09T20:31:17.937441Z"}
......................................................................................................
ACCESSING THE CHANNEL'S XML FILE
https://api.pachube.com/v2/feeds/00000.xml
RESULT ------>
testfeed https://api.pachube.com/v2/feeds/00000.xml frozen just testing options false test marc's place 50.0359736721955 8.7451171875 0 test
......................................................................................................
ACCESSING THE CHANNEL'S CSV FILE
https://api.pachube.com/v2/feeds/00000.csv
RESULT ------>
0,2011-10-09T20:31:17.937441Z,test
Re: Triggers (aka webhooks, notifications, etc.)
@PchbmarcAccnt
As you saw from the error message, Pachube requires input to the performed using PUT or POST.
Have another look at the API docs and you will see how to do the post. You need to put an access key into one of the post headers. Ideally this should not be your master key. See the section on key generation also on the API page.
For a quick test you can also use CURL from a command line.
Re: Triggers (aka webhooks, notifications, etc.)
Thanks for your reply!
will have a look & try ....
Re: Triggers (aka webhooks, notifications, etc.)
I don't know PHP, or Java or Python, but I want to get emails or SMS when a trigger is generated. I found an article (http://www.webdigi.co.uk/blog/2009/run-php-on-the-google-app-engine/) that gives instructions on how to run PHP on Google App Engine (GAE) for java. Looking at the comments it appears to work quite well.
I took the php script example in step 3 and inserted my email where instructed (using notepad). I saved it as pachube_email.php along with the test php files that came with the file referenced in the article. I created the app: pachubetrigger.appspot.com and I used the Google App Engine SDK command line (Windows 7) to upload my app to google. It all seemed to work okay. The php script is not located at:
http://pachubetrigger.appspot.com/pachube_email.php
I then put this URL into a trigger and did a test. Not surprisingly it didn't work; I didn't get an email. I'd appreciate any suggestions to get this working. If I can get it to work, it would be a good solution for other people, so far, it hasn't required any programming expertise, but it's not working yet, so it may end up being very difficult. I hope not.
Re: Triggers (aka webhooks, notifications, etc.)