Is there an example using Triggers?
meltwater2000 opened this issue · comments
Just starting out using this library so sorry if it is obvious, but I am hoping to use a trigger.
Are there any examples of using triggers with the library since it isn't too clear how to check the status of the trigger once it is set.
Q1: Is there a function do this, or do we need to go down to the level of handling the POST requests? Not a major problem either way, but would be handy to know if I've missed something.
Q2: Would it be possible to create a "manual" trigger on the dashboard which presents a button, which when pressed activates the trigger (and then sends a POST command)? Would allow controls to be added.
NOTE: Edited request, as original question was not valid.
Traceback (most recent call last):
File "xively_triggers.py", line 176, in <module>
run()
File "xively_triggers.py", line 117, in run
trigger = api.triggers.create(environment_id=FEED_ID, stream_id="mem_free", url=POSTURL, trigger_type="lt", threshold_value="1.0")
File "/usr/local/lib/python3.2/dist-packages/xively_python-0.1.0_rc2-py3.2.egg/xively/managers.py", line 852, in create
response.raise_for_status()
File "/usr/local/lib/python3.2/dist-packages/requests-1.2.3-py3.2.egg/requests/models.py", line 683, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden
I've also tried using the feed object and the datastream object but get the same result.
I've even created a trigger directly on the dashboard using the same settings and it works.
Any idea what I may be doing wrong? Would really like to be able to get this to work if possible.
You will need to use a master API key in order to create triggers, it looks like you are using a device-level key.
Thanks for your reply, creating and using a master API key (didn't even know about them before) did work.
May be worth adding a note to the documentation to clarify why etc.
Thanks.