Mercurial > code > home > repos > homeauto
changeset 930:23d47a9a968b
shuttlepro post your events to reasoning service
Ignore-this: e60b39a5b1639955a0c3d5a46ec09b23
darcs-hash:20131008054530-312f9-19af39421106afb2d0486bbd0449e09eaa7e005a
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Mon, 07 Oct 2013 22:45:30 -0700 |
parents | e7532dfa1a39 |
children | e9fbd5d15e30 |
files | service/shuttlepro/shuttlepro.py |
diffstat | 1 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/service/shuttlepro/shuttlepro.py Sun Sep 29 02:16:49 2013 -0700 +++ b/service/shuttlepro/shuttlepro.py Mon Oct 07 22:45:30 2013 -0700 @@ -355,17 +355,25 @@ import restkit reasoning = restkit.Resource("http://bang:9071/", timeout=1) -from rdflib import Namespace +from rdflib import Namespace, Graph SHUTTLEPRO = Namespace("http://projects.bigasterisk.com/room/livingRoom/shuttlepro/") ROOM = Namespace("http://projects.bigasterisk.com/room/") if __name__ == '__main__': - import restkit, urllib - mpd = restkit.Resource("http://slash:9009/") + import restkit + reasoning = restkit.Resource("http://plus:9071/") def ev(what): print 'ev', what if 'key' in what and what['press']: - print mpd.post("addAndPlay/%s" % what['key']['button']).body_string() + g = Graph() + g.add((SHUTTLEPRO, ROOM['press'], + SHUTTLEPRO['b' + what['key']['button']])) + reasoning.post( + "oneShot", + payload=g.serialize(format='text/n3'), + headers={'Content-Type': 'text/n3'} + ).body_string() + p = powermate("/dev/input/by-id/usb-Contour_Design_ShuttlePRO-event-if00", ev) while True: p.read_next()