50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
class DSMRObject(object):
|
|
"""
|
|
Represents all data from a single telegram line.
|
|
"""
|
|
|
|
def __init__(self, values):
|
|
self.values = values
|
|
|
|
|
|
class MBusObject(DSMRObject):
|
|
|
|
@property
|
|
def datetime(self):
|
|
return self.values[0]['value']
|
|
|
|
@property
|
|
def value(self):
|
|
# TODO temporary workaround for DSMR v2.2. Maybe use the same type of
|
|
# TODO object, but let the parse set them differently? So don't use
|
|
# TODO hardcoded indexes here.
|
|
if len(self.values) != 2: # v2
|
|
return self.values[5]['value']
|
|
else:
|
|
return self.values[1]['value']
|
|
|
|
@property
|
|
def unit(self):
|
|
# TODO temporary workaround for DSMR v2.2. Maybe use the same type of
|
|
# TODO object, but let the parse set them differently? So don't use
|
|
# TODO hardcoded indexes here.
|
|
if len(self.values) != 2: # v2
|
|
return self.values[4]['value']
|
|
else:
|
|
return self.values[1]['unit']
|
|
|
|
|
|
class CosemObject(DSMRObject):
|
|
|
|
@property
|
|
def value(self):
|
|
return self.values[0]['value']
|
|
|
|
@property
|
|
def unit(self):
|
|
return self.values[0]['unit']
|
|
|
|
|
|
class ProfileGeneric(DSMRObject):
|
|
pass # TODO implement
|