From fe5caa9126e9de709ca63b5f86aaf064571c0fa7 Mon Sep 17 00:00:00 2001 From: Johan Bloemberg Date: Mon, 7 Nov 2016 20:08:28 +0100 Subject: [PATCH] Test and fix parsing of gas unit. --- dsmr_parser/objects.py | 2 +- test/test_parse.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dsmr_parser/objects.py b/dsmr_parser/objects.py index e96df9f..f09fda5 100644 --- a/dsmr_parser/objects.py +++ b/dsmr_parser/objects.py @@ -31,7 +31,7 @@ class MBusObjectV2_2(DSMRObject): @property def unit(self): - return self.values[4]['unit'] + return self.values[4]['value'] class CosemObject(DSMRObject): diff --git a/test/test_parse.py b/test/test_parse.py index 460b509..433fd15 100644 --- a/test/test_parse.py +++ b/test/test_parse.py @@ -35,4 +35,6 @@ def test_parse_v2_2(): result = parser.parse(TELEGRAM_V2_2) assert float(result[CURRENT_ELECTRICITY_USAGE].value) == 1.01 + assert result[CURRENT_ELECTRICITY_USAGE].unit == 'kW' assert float(result[GAS_METER_READING].value) == 1.001 + assert result[GAS_METER_READING].unit == 'm3'