From 3bfb555d0ea94cb623bdd64ce1c1ad5f47eeb9e1 Mon Sep 17 00:00:00 2001 From: Jean-Louis Dupond Date: Thu, 19 Dec 2019 04:19:29 +0100 Subject: [PATCH] Add support for Belgian and Smarty meters --- dsmr_parser/clients/protocol.py | 3 +++ dsmr_parser/obis_references.py | 5 +++++ dsmr_parser/telegram_specifications.py | 16 ++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/dsmr_parser/clients/protocol.py b/dsmr_parser/clients/protocol.py index 2c9650e..7e8e260 100644 --- a/dsmr_parser/clients/protocol.py +++ b/dsmr_parser/clients/protocol.py @@ -26,6 +26,9 @@ def create_dsmr_protocol(dsmr_version, telegram_callback, loop=None): elif dsmr_version == '5': specification = telegram_specifications.V5 serial_settings = SERIAL_SETTINGS_V5 + elif dsmr_version == '5B': + specification = telegram_specifications.BELGIUM_FLUVIUS + serial_settings = SERIAL_SETTINGS_V5 else: raise NotImplementedError("No telegram parser found for version: %s", dsmr_version) diff --git a/dsmr_parser/obis_references.py b/dsmr_parser/obis_references.py index 5050f43..cb7b158 100644 --- a/dsmr_parser/obis_references.py +++ b/dsmr_parser/obis_references.py @@ -60,3 +60,8 @@ ELECTRICITY_DELIVERED_TARIFF_ALL = ( ELECTRICITY_DELIVERED_TARIFF_1, ELECTRICITY_DELIVERED_TARIFF_2 ) + +# Alternate codes for foreign countries. +BELGIUM_HOURLY_GAS_METER_READING = r'\d-\d:24\.2\.3.+?\r\n' # Different code, same format. +LUXEMBOURG_ELECTRICITY_USED_TARIFF_GLOBAL = r'\d-\d:1\.8\.0.+?\r\n' # Total imported energy register (P+) +LUXEMBOURG_ELECTRICITY_DELIVERED_TARIFF_GLOBAL = r'\d-\d:2\.8\.0.+?\r\n' # Total exported energy register (P-) diff --git a/dsmr_parser/telegram_specifications.py b/dsmr_parser/telegram_specifications.py index e2c0bf5..a42806f 100644 --- a/dsmr_parser/telegram_specifications.py +++ b/dsmr_parser/telegram_specifications.py @@ -1,4 +1,5 @@ from decimal import Decimal +from copy import deepcopy from dsmr_parser import obis_references as obis from dsmr_parser.parsers import CosemParser, ValueParser, MBusParser @@ -128,3 +129,18 @@ V5 = { } ALL = (V2_2, V3, V4, V5) + + +BELGIUM_FLUVIUS = deepcopy(V5) +BELGIUM_FLUVIUS['objects'].update({ + obis.BELGIUM_HOURLY_GAS_METER_READING: MBusParser( + ValueParser(timestamp), + ValueParser(Decimal) + ) +}) + +LUXEMBOURG_SMARTY = deepcopy(V5) +LUXEMBOURG_SMARTY['objects'].update({ + obis.LUXEMBOURG_ELECTRICITY_USED_TARIFF_GLOBAL: CosemParser(ValueParser(Decimal)), + obis.LUXEMBOURG_ELECTRICITY_DELIVERED_TARIFF_GLOBAL: CosemParser(ValueParser(Decimal)), +})