Mercurial > code > home > repos > homeauto
diff service/shuttlepro/shuttlepro.py @ 125:bcf20b7ede56
shuttlepro post your events to reasoning service
Ignore-this: e60b39a5b1639955a0c3d5a46ec09b23
author | drewp@bigasterisk.com |
---|---|
date | Mon, 07 Oct 2013 22:45:30 -0700 |
parents | 1c1fcb71e10a |
children | a8e19321d63f |
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()