diff options
author | equinox <equinox@diac24.net> | 2013-03-18 14:04:46 +0100 |
---|---|---|
committer | Christian Franke <nobody@nowhere.ws> | 2013-03-19 15:41:48 +0100 |
commit | 27c8954bc7de4e1003cf4aa5ae8d5255b72e4920 (patch) | |
tree | 536877e726bae96c9b5e69c95689a5f1e3259df6 | |
parent | 238cbeb11e12bbdfdee8c539658f006b71b1707a (diff) |
ethcan: write addr & class info to json
-rw-r--r-- | ethcan.py | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -25,6 +25,10 @@ class SubCANDevice(object): s.actorval = None s.actorupd = None s.actorchg = None + def dict(s): + rv = {} + rv['addr'] = s.addr + return rv class SubCANBool(SubCANDevice): def __init__(s, addr, name, falseval, trueval): @@ -35,7 +39,8 @@ class SubCANBool(SubCANDevice): return 'None' return s.vals[s.lastval & 1] def dict(s): - rv = {} + rv = SubCANDevice.dict(s) + rv['klass'] = 'beancounter' if s.lastval is not None: rv['raw'] = s.lastval rv['value'] = bool(s.lastval & 1) @@ -50,7 +55,8 @@ class SubCANDALI(SubCANDevice): return '' return 'set: %02x actual: %02x' % (s.actorval, s.lastval) def dict(s): - rv = {} + rv = SubCANDevice.dict(s) + rv['klass'] = 'light' if s.lastval is not None: rv['actual'] = s.lastval rv['actual_ts'] = int(s.lastupd) |