From c2dea29c83d5818581d2821db6bef073208dad42 Mon Sep 17 00:00:00 2001 From: Hans Erik van Elburg Date: Sun, 17 May 2020 16:49:29 +0200 Subject: [PATCH] add a value property to GenericProfileObject, return a dict --- dsmr_parser/objects.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dsmr_parser/objects.py b/dsmr_parser/objects.py index ce48a01..3e99d53 100644 --- a/dsmr_parser/objects.py +++ b/dsmr_parser/objects.py @@ -140,6 +140,18 @@ class ProfileGenericObject(DSMRObject): self._buffer_list.append(MBusObject([self.values[offset], self.values[offset + 1]])) return self._buffer_list + @property + def value(self): + list = [['buffer_length', self.buffer_length]] + list.append(['buffer_type', self.buffer_type]) + buffer_repr = [ + (['datetime', buffer_item.datetime], + ['value', buffer_item.value]) + for buffer_item in self.buffer + ] + list.append(['buffer', buffer_repr]) + return dict(list) + def __str__(self): output = "\t buffer length: {}\n".format(self.buffer_length) output += "\t buffer type: {}".format(self.buffer_type)