diff options
author | root <root@krebs> | 2011-09-25 02:53:05 +0200 |
---|---|---|
committer | root <root@krebs> | 2011-09-25 02:53:05 +0200 |
commit | 18e0376ffd9dee51f554f422b8e83bcfaa0ab218 (patch) | |
tree | e5cda395701b7b89d5a4d930f50e6302c14880ea /commands | |
parent | 821f9a450a9140f1ef63fb317a564d0251bc967e (diff) |
Reaktor/UDP: working release
Reaktor/UDP is customizable via a single json config parsed at the very beginning,
starting a number of asynchronous UDP listeners. See Readme for more info
Diffstat (limited to 'commands')
-rwxr-xr-x | commands/licht_resolver | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/commands/licht_resolver b/commands/licht_resolver new file mode 100755 index 0000000..5bdb651 --- /dev/null +++ b/commands/licht_resolver @@ -0,0 +1,37 @@ +#! /usr/bin/python +# -*- coding: utf-8 -*- + +map = { + 'shackspace': { + 'device': { + 0: 'Licht0, Zickenzone; Fenster', + 1: 'Licht1, Sofaecke; Fenster', + 2: 'Licht2, Zickenzone; Ghetto', + 3: 'Licht3, Sofaecke; Ghetto', + 4: 'Licht4, Richtung Getränkelager', + 5: 'Licht5, Porschekonsole', + 6: 'Licht6, Tomatenecke', + 7: 'Licht7, Ghetto', + 10: 'Hauptschalter' + }, + 'state': { + 0: 'aus', + 1: 'an', + 2: 'aus in T-10s' + }, + '->': 'ist' + } +} + +from struct import unpack +import json +from os import environ as env + +location = "shackspace" + +map = map[location] +print (env["payload"]+"") +did, sid= unpack('BB', json.loads(env['payload'])) +device,state = map['device'][did], map['state'][sid] +arrow = map['->'] +print ' '.join([device, arrow, state]) |