From 7c9c59308e2284a9807e1a1e21cc93bc00bbf138 Mon Sep 17 00:00:00 2001 From: Rick van Hattem Date: Thu, 12 Dec 2019 22:20:16 +0100 Subject: [PATCH 1/5] `create_tcp_dsmr_reader` accepts `loop=None` but always expects a loop. Fixes #36 --- dsmr_parser/clients/protocol.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dsmr_parser/clients/protocol.py b/dsmr_parser/clients/protocol.py index 141a389..2c9650e 100644 --- a/dsmr_parser/clients/protocol.py +++ b/dsmr_parser/clients/protocol.py @@ -49,12 +49,13 @@ def create_dsmr_reader(port, dsmr_version, telegram_callback, loop=None): def create_tcp_dsmr_reader(host, port, dsmr_version, telegram_callback, loop=None): """Creates a DSMR asyncio protocol coroutine using TCP connection.""" + if not loop: + loop = asyncio.get_event_loop() protocol, _ = create_dsmr_protocol( - dsmr_version, telegram_callback, loop=None) + dsmr_version, telegram_callback, loop=loop) conn = loop.create_connection(protocol, host, port) return conn - class DSMRProtocol(asyncio.Protocol): """Assemble and handle incoming data into complete DSM telegrams.""" From 12aa003799ee3240f8c523e9133101dcd37778a1 Mon Sep 17 00:00:00 2001 From: Nigel Dokter Date: Thu, 12 Dec 2019 22:29:18 +0100 Subject: [PATCH 2/5] Updated version number --- CHANGELOG.rst | 4 ++++ setup.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5fac8e7..3b334c9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,10 @@ Change Log ---------- +**0.15** (2019-12-12) + +- Fixed asyncio loop issue (`pull request #37 `_). + **0.14** (2019-10-08) - Changed serial reading to reduce CPU usage (`pull request #37 `_). diff --git a/setup.py b/setup.py index b20a2a8..673267f 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( author='Nigel Dokter', author_email='nigel@nldr.net', url='https://github.com/ndokter/dsmr_parser', - version='0.14', + version='0.15', packages=find_packages(), install_requires=[ 'pyserial>=3,<4', From 3a8b4d24582d299751df0645ad4f5de7411a9baa Mon Sep 17 00:00:00 2001 From: Nigel Dokter Date: Thu, 12 Dec 2019 22:33:14 +0100 Subject: [PATCH 3/5] Corrected changelog --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3b334c9..584c593 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,7 +3,7 @@ Change Log **0.15** (2019-12-12) -- Fixed asyncio loop issue (`pull request #37 `_). +- Fixed asyncio loop issue (`pull request #43 `_). **0.14** (2019-10-08) From 3bfb555d0ea94cb623bdd64ce1c1ad5f47eeb9e1 Mon Sep 17 00:00:00 2001 From: Jean-Louis Dupond Date: Thu, 19 Dec 2019 04:19:29 +0100 Subject: [PATCH 4/5] 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)), +}) From a01e67364630c10da635b9d43eaa535f05feff63 Mon Sep 17 00:00:00 2001 From: Nigel Dokter Date: Sat, 21 Dec 2019 15:02:13 +0100 Subject: [PATCH 5/5] updated changelog for new release --- CHANGELOG.rst | 4 ++++ setup.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 584c593..babab7c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,10 @@ Change Log ---------- +**0.16** (2019-12-21) + +- Add support for Belgian and Smarty meters (`pull request #44 `_). + **0.15** (2019-12-12) - Fixed asyncio loop issue (`pull request #43 `_). diff --git a/setup.py b/setup.py index 673267f..fe434f6 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( author='Nigel Dokter', author_email='nigel@nldr.net', url='https://github.com/ndokter/dsmr_parser', - version='0.15', + version='0.16', packages=find_packages(), install_requires=[ 'pyserial>=3,<4',