Mercurial > code > home > repos > homeauto
comparison service/shuttlepro/shuttlepro.py @ 128:06ad4a0f42c0
fix shuttlepro outgoing uri
Ignore-this: c07186778bb07dab9e78c92f10f53a9b
author | drewp@bigasterisk.com |
---|---|
date | Tue, 08 Oct 2013 21:39:06 -0700 |
parents | f5d8d6124434 |
children | 57ae7dc0f417 |
comparison
equal
deleted
inserted
replaced
127:f5d8d6124434 | 128:06ad4a0f42c0 |
---|---|
356 | 356 |
357 import restkit | 357 import restkit |
358 reasoning = restkit.Resource("http://bang:9071/", timeout=1) | 358 reasoning = restkit.Resource("http://bang:9071/", timeout=1) |
359 | 359 |
360 from rdflib import Namespace, Graph, Literal | 360 from rdflib import Namespace, Graph, Literal |
361 SHUTTLEPRO = Namespace("http://projects.bigasterisk.com/room/livingRoom/shuttlepro/") | 361 SHUTTLEPRO = Namespace("http://bigasterisk.com/room/livingRoom/shuttlepro/") |
362 ROOM = Namespace("http://projects.bigasterisk.com/room/") | 362 ROOM = Namespace("http://projects.bigasterisk.com/room/") |
363 | 363 |
364 if __name__ == '__main__': | 364 if __name__ == '__main__': |
365 import restkit | 365 import restkit |
366 reasoning = restkit.Resource("http://bang:9071/", timeout=1) | 366 reasoning = restkit.Resource("http://bang:9071/", timeout=1) |
367 | |
368 # this should serve a graph of the current state as well, not just all oneshots | |
369 | |
367 def ev(what): | 370 def ev(what): |
368 print 'ev', what | 371 print 'ev', what |
369 g = Graph() | 372 g = Graph() |
370 if 'key' in what: | 373 if 'key' in what: |
371 g.add((SHUTTLEPRO['button%s' % what['key']['button']], | 374 g.add((SHUTTLEPRO['button%s' % what['key']['button']], |
378 elif 'dial' in what: | 381 elif 'dial' in what: |
379 g.add((SHUTTLEPRO['dial'], ROOM['change'], | 382 g.add((SHUTTLEPRO['dial'], ROOM['change'], |
380 ROOM['clockwise'] if what['dial'] == 1 else | 383 ROOM['clockwise'] if what['dial'] == 1 else |
381 ROOM['counterclockwise'])) | 384 ROOM['counterclockwise'])) |
382 try: | 385 try: |
386 nt = g.serialize(format='nt') | |
383 reasoning.post( | 387 reasoning.post( |
384 "oneShot", | 388 "oneShot", |
385 payload=g.serialize(format='nt'), | 389 payload=nt, |
386 headers={'Content-Type': 'text/n3'} | 390 headers={'Content-Type': 'text/n3'}, |
387 ).body_string() | 391 ).body_string() |
388 except restkit.errors.RequestTimeout, e: | 392 except restkit.errors.RequestTimeout, e: |
389 log.error(e) | 393 log.error(e) |
390 | 394 |
391 p = powermate("/dev/input/by-id/usb-Contour_Design_ShuttlePRO-event-if00", ev) | 395 p = powermate("/dev/input/by-id/usb-Contour_Design_ShuttlePRO-event-if00", ev) |