Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06d2ae246e | ||
|
|
391c3f7824 | ||
|
|
739419e3ee | ||
|
|
d2ff6f4bb9 | ||
|
|
a316d93082 | ||
|
|
01d7622c40 | ||
|
|
e8a86272ea | ||
|
|
389bcefb50 |
@@ -17,6 +17,7 @@ jobs:
|
||||
- '3.9'
|
||||
- '3.10'
|
||||
- '3.11'
|
||||
- '3.12'
|
||||
|
||||
name: Python ${{ matrix.python-version }}
|
||||
steps:
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
Change Log
|
||||
----------
|
||||
|
||||
**1.3.1** (2023-11-06)
|
||||
- Fix parsing peak usage with invalid timestamps
|
||||
(`PR #143 <https://github.com/ndokter/dsmr_parser/pull/143>`_ by `dupondje <https://github.com/dupondje>`_)
|
||||
|
||||
**1.3.0** (2023-08-01)
|
||||
|
||||
- added E.ON Hungary; refactored DSMR specifications to fix obis reference conflicts
|
||||
|
||||
@@ -43,6 +43,9 @@ INSTANTANEOUS_VOLTAGE_L3 = r'^\d-\d:72\.7\.0.+?\r\n'
|
||||
INSTANTANEOUS_CURRENT_L1 = r'^\d-\d:31\.7\.0.+?\r\n'
|
||||
INSTANTANEOUS_CURRENT_L2 = r'^\d-\d:51\.7\.0.+?\r\n'
|
||||
INSTANTANEOUS_CURRENT_L3 = r'^\d-\d:71\.7\.0.+?\r\n'
|
||||
FUSE_THRESHOLD_L1 = r'^\d-\d:31\.4\.0.+?\r\n' # Applicable when current limitation is active
|
||||
FUSE_THRESHOLD_L2 = r'^\d-\d:51\.4\.0.+?\r\n' # Applicable when current limitation is active
|
||||
FUSE_THRESHOLD_L3 = r'^\d-\d:71\.4\.0.+?\r\n' # Applicable when current limitation is active
|
||||
TEXT_MESSAGE_CODE = r'^\d-\d:96\.13\.1.+?\r\n'
|
||||
TEXT_MESSAGE = r'^\d-\d:96\.13\.0.+?\r\n'
|
||||
DEVICE_TYPE = r'^\d-\d:24\.1\.0.+?\r\n'
|
||||
@@ -88,8 +91,6 @@ BELGIUM_EQUIPMENT_IDENTIFIER = r'^\d-0:96\.1\.1.+?\r\n'
|
||||
BELGIUM_CURRENT_AVERAGE_DEMAND = r'^\d-\d:1\.4\.0.+?\r\n'
|
||||
BELGIUM_MAXIMUM_DEMAND_MONTH = r'^\d-\d:1\.6\.0.+?\r\n'
|
||||
BELGIUM_MAXIMUM_DEMAND_13_MONTHS = r'^\d-\d:98\.1\.0.+?\r\n'
|
||||
BELGIUM_MAX_POWER_PER_PHASE = r'^\d-\d:17\.0\.0.+?\r\n' # Applicable when power limitation is active
|
||||
BELGIUM_MAX_CURRENT_PER_PHASE = r'^\d-\d:31\.4\.0.+?\r\n' # Applicable when current limitation is active
|
||||
|
||||
# Multiple 'slaves' can be linked to the main device.
|
||||
# Mostly MBUS1 = GAS METER with values on 24.2.3
|
||||
@@ -142,5 +143,3 @@ EON_HU_INSTANTANEOUS_REACTIVE_POWER_Q1 = r'^\d-\d:5\.7\.0.+?\r\n'
|
||||
EON_HU_INSTANTANEOUS_REACTIVE_POWER_Q2 = r'^\d-\d:6\.7\.0.+?\r\n'
|
||||
EON_HU_INSTANTANEOUS_REACTIVE_POWER_Q3 = r'^\d-\d:7\.7\.0.+?\r\n'
|
||||
EON_HU_INSTANTANEOUS_REACTIVE_POWER_Q4 = r'^\d-\d:8\.7\.0.+?\r\n'
|
||||
EON_HU_MAX_POWER_ON_L2 = r'^\d-\d:51\.4\.0.+?\r\n'
|
||||
EON_HU_MAX_POWER_ON_L3 = r'^\d-\d:71\.4\.0.+?\r\n'
|
||||
|
||||
+30
-17
@@ -140,22 +140,25 @@ class MBusObject(DSMRObject):
|
||||
return self.values[1]['unit']
|
||||
|
||||
def __str__(self):
|
||||
timestamp = self.datetime
|
||||
if isinstance(timestamp, datetime.datetime):
|
||||
timestamp = timestamp.astimezone().astimezone(pytz.utc).isoformat()
|
||||
output = "{}\t[{}] at {}".format(
|
||||
str(self.value),
|
||||
str(self.unit),
|
||||
str(self.datetime.astimezone().astimezone(pytz.utc).isoformat())
|
||||
str(timestamp)
|
||||
)
|
||||
return output
|
||||
|
||||
def to_json(self):
|
||||
timestamp = self.datetime
|
||||
if isinstance(self.datetime, datetime.datetime):
|
||||
timestamp = self.datetime.astimezone().astimezone(pytz.utc).isoformat()
|
||||
if isinstance(timestamp, datetime.datetime):
|
||||
timestamp = timestamp.astimezone().astimezone(pytz.utc).isoformat()
|
||||
value = self.value
|
||||
if isinstance(self.value, datetime.datetime):
|
||||
value = self.value.astimezone().astimezone(pytz.utc).isoformat()
|
||||
if isinstance(self.value, Decimal):
|
||||
value = float(self.value)
|
||||
if isinstance(value, datetime.datetime):
|
||||
value = value.astimezone().astimezone(pytz.utc).isoformat()
|
||||
if isinstance(value, Decimal):
|
||||
value = float(value)
|
||||
output = {
|
||||
'datetime': timestamp,
|
||||
'value': value,
|
||||
@@ -183,23 +186,33 @@ class MBusObjectPeak(DSMRObject):
|
||||
return self.values[2]['unit']
|
||||
|
||||
def __str__(self):
|
||||
timestamp = self.datetime
|
||||
if isinstance(timestamp, datetime.datetime):
|
||||
timestamp = timestamp.astimezone().astimezone(pytz.utc).isoformat()
|
||||
timestamp_occurred = self.occurred
|
||||
if isinstance(timestamp_occurred, datetime.datetime):
|
||||
timestamp_occurred = timestamp_occurred.astimezone().astimezone(pytz.utc).isoformat()
|
||||
value = self.value
|
||||
if isinstance(value, datetime.datetime):
|
||||
value = value.astimezone().astimezone(pytz.utc).isoformat()
|
||||
if isinstance(value, Decimal):
|
||||
value = float(value)
|
||||
output = "{}\t[{}] at {} occurred {}"\
|
||||
.format(str(self.value), str(self.unit), str(self.datetime.astimezone().astimezone(pytz.utc).isoformat()),
|
||||
str(self.occurred.astimezone().astimezone(pytz.utc).isoformat()))
|
||||
.format(str(value), str(self.unit), str(timestamp), str(timestamp_occurred))
|
||||
return output
|
||||
|
||||
def to_json(self):
|
||||
timestamp = self.datetime
|
||||
if isinstance(self.datetime, datetime.datetime):
|
||||
timestamp = self.datetime.astimezone().astimezone(pytz.utc).isoformat()
|
||||
if isinstance(timestamp, datetime.datetime):
|
||||
timestamp = timestamp.astimezone().astimezone(pytz.utc).isoformat()
|
||||
timestamp_occurred = self.occurred
|
||||
if isinstance(self.occurred, datetime.datetime):
|
||||
timestamp_occurred = self.occurred.astimezone().astimezone(pytz.utc).isoformat()
|
||||
if isinstance(timestamp_occurred, datetime.datetime):
|
||||
timestamp_occurred = timestamp_occurred.astimezone().astimezone(pytz.utc).isoformat()
|
||||
value = self.value
|
||||
if isinstance(self.value, datetime.datetime):
|
||||
value = self.value.astimezone().astimezone(pytz.utc).isoformat()
|
||||
if isinstance(self.value, Decimal):
|
||||
value = float(self.value)
|
||||
if isinstance(value, datetime.datetime):
|
||||
value = value.astimezone().astimezone(pytz.utc).isoformat()
|
||||
if isinstance(value, Decimal):
|
||||
value = float(value)
|
||||
output = {
|
||||
'datetime': timestamp,
|
||||
'occurred': timestamp_occurred,
|
||||
|
||||
@@ -625,14 +625,14 @@ BELGIUM_FLUVIUS = {
|
||||
'value_name': 'ACTUAL_TRESHOLD_ELECTRICITY'
|
||||
},
|
||||
{
|
||||
'obis_reference': obis.BELGIUM_MAX_POWER_PER_PHASE,
|
||||
'obis_reference': obis.ACTUAL_TRESHOLD_ELECTRICITY,
|
||||
'value_parser': CosemParser(ValueParser(Decimal)),
|
||||
'value_name': 'BELGIUM_MAX_POWER_PER_PHASE'
|
||||
'value_name': 'ACTUAL_TRESHOLD_ELECTRICITY'
|
||||
},
|
||||
{
|
||||
'obis_reference': obis.BELGIUM_MAX_CURRENT_PER_PHASE,
|
||||
'obis_reference': obis.FUSE_THRESHOLD_L1,
|
||||
'value_parser': CosemParser(ValueParser(Decimal)),
|
||||
'value_name': 'BELGIUM_MAX_CURRENT_PER_PHASE'
|
||||
'value_name': 'FUSE_THRESHOLD_L1'
|
||||
},
|
||||
{
|
||||
'obis_reference': obis.TEXT_MESSAGE,
|
||||
@@ -1233,7 +1233,7 @@ EON_HUNGARY = {
|
||||
# This seems to be wrong in documentation, it's not 0-0:96.50.68, but 0-0:96.3.10
|
||||
},
|
||||
{
|
||||
'obis_reference': obis.BELGIUM_MAX_POWER_PER_PHASE,
|
||||
'obis_reference': obis.ACTUAL_TRESHOLD_ELECTRICITY,
|
||||
'value_parser': CosemParser(ValueParser(Decimal)),
|
||||
'value_name': 'ACTUAL_TRESHOLD_ELECTRICITY'
|
||||
},
|
||||
@@ -1414,20 +1414,20 @@ EON_HUNGARY = {
|
||||
'value_name': 'INSTANTANEOUS_REACTIVE_POWER_Q4'
|
||||
},
|
||||
{
|
||||
'obis_reference': obis.BELGIUM_MAX_CURRENT_PER_PHASE,
|
||||
'obis_reference': obis.FUSE_THRESHOLD_L1,
|
||||
'value_parser': CosemParser(ValueParser(Decimal)),
|
||||
'value_name': 'MAX_POWER_ON_L1'
|
||||
'value_name': 'FUSE_THRESHOLD_L1'
|
||||
},
|
||||
{
|
||||
'obis_reference': obis.EON_HU_MAX_POWER_ON_L2,
|
||||
'obis_reference': obis.FUSE_THRESHOLD_L2,
|
||||
'value_parser': CosemParser(ValueParser(Decimal)),
|
||||
'value_name': 'MAX_POWER_ON_L2'
|
||||
'value_name': 'FUSE_THRESHOLD_L2'
|
||||
# Only with 3 phase meters
|
||||
},
|
||||
{
|
||||
'obis_reference': obis.EON_HU_MAX_POWER_ON_L3,
|
||||
'obis_reference': obis.FUSE_THRESHOLD_L3,
|
||||
'value_parser': CosemParser(ValueParser(Decimal)),
|
||||
'value_name': 'MAX_POWER_ON_L3'
|
||||
'value_name': 'FUSE_THRESHOLD_L3'
|
||||
# Only with 3 phase meters
|
||||
},
|
||||
# I'm not sure which datas does this line containes. It should be the data of last minute of last month.
|
||||
|
||||
@@ -7,7 +7,7 @@ setup(
|
||||
author_email='mail@nldr.net',
|
||||
license='MIT',
|
||||
url='https://github.com/ndokter/dsmr_parser',
|
||||
version='1.3.0',
|
||||
version='1.3.1',
|
||||
packages=find_packages(exclude=('test', 'test.*')),
|
||||
install_requires=[
|
||||
'pyserial>=3,<4',
|
||||
|
||||
@@ -175,7 +175,7 @@ TELEGRAM_V5_TWO_MBUS = (
|
||||
)
|
||||
|
||||
TELEGRAM_FLUVIUS_V171 = (
|
||||
'/FLU5\253769484_A\r\n'
|
||||
'/FLU5\\253769484_A\r\n'
|
||||
'\r\n'
|
||||
'0-0:96.1.4(50217)\r\n'
|
||||
'0-0:96.1.1(3153414733313031303231363035)\r\n'
|
||||
@@ -213,7 +213,49 @@ TELEGRAM_FLUVIUS_V171 = (
|
||||
'0-2:24.1.0(007)\r\n'
|
||||
'0-2:96.1.1(3853414731323334353637383930)\r\n'
|
||||
'0-2:24.2.1(200512134558S)(00872.234*m3)\r\n'
|
||||
'!911C\r\n'
|
||||
'!3AD7\r\n'
|
||||
)
|
||||
|
||||
TELEGRAM_FLUVIUS_V171_ALT = (
|
||||
'/FLU5\\253769484_A\r\n'
|
||||
'\r\n'
|
||||
'0-0:96.1.4(50217)\r\n'
|
||||
'0-0:96.1.1(3153414733313030373231333236)\r\n'
|
||||
'0-0:1.0.0(231102121548W)\r\n'
|
||||
'1-0:1.8.1(000301.548*kWh)\r\n'
|
||||
'1-0:1.8.2(000270.014*kWh)\r\n'
|
||||
'1-0:2.8.1(000000.005*kWh)\r\n'
|
||||
'1-0:2.8.2(000000.000*kWh)\r\n'
|
||||
'0-0:96.14.0(0001)\r\n'
|
||||
'1-0:1.4.0(00.052*kW)\r\n'
|
||||
'1-0:1.6.0(231102114500W)(03.064*kW)\r\n'
|
||||
'0-0:98.1.0(4)(1-0:1.6.0)(1-0:1.6.0)(230801000000S)(632525252525W)(00.000*kW)(230901000000S)(230831181500S)(01.862*kW)(231001000000S)(230910183000S)(04.229*kW)(231101000000W)(231016130000S)(04.927*kW)\r\n'
|
||||
'1-0:1.7.0(00.338*kW)\r\n'
|
||||
'1-0:2.7.0(00.000*kW)\r\n'
|
||||
'1-0:21.7.0(00.047*kW)\r\n'
|
||||
'1-0:41.7.0(00.179*kW)\r\n'
|
||||
'1-0:61.7.0(00.111*kW)\r\n'
|
||||
'1-0:22.7.0(00.000*kW)\r\n'
|
||||
'1-0:42.7.0(00.000*kW)\r\n'
|
||||
'1-0:62.7.0(00.000*kW)\r\n'
|
||||
'1-0:32.7.0(232.9*V)\r\n'
|
||||
'1-0:52.7.0(228.1*V)\r\n'
|
||||
'1-0:72.7.0(228.1*V)\r\n'
|
||||
'1-0:31.7.0(000.27*A)\r\n'
|
||||
'1-0:51.7.0(000.88*A)\r\n'
|
||||
'1-0:71.7.0(000.52*A)\r\n'
|
||||
'0-0:96.3.10(1)\r\n'
|
||||
'0-0:17.0.0(999.9*kW)\r\n'
|
||||
'1-0:31.4.0(999*A)\r\n'
|
||||
'0-0:96.13.0()\r\n'
|
||||
'0-1:24.1.0(003)\r\n'
|
||||
'0-1:96.1.1(37464C4F32313233303838303237)\r\n'
|
||||
'0-1:24.4.0(1)\r\n'
|
||||
'0-1:24.2.3(231102121002W)(00092.287*m3)\r\n'
|
||||
'0-2:24.1.0(007)\r\n'
|
||||
'0-2:96.1.1(3853455430303030393631313733)\r\n'
|
||||
'0-2:24.2.1(231102121532W)(00008.579*m3)\r\n'
|
||||
'!C4B0\r\n'
|
||||
)
|
||||
|
||||
# EasyMeter via COM-1 Ethernet Gateway
|
||||
|
||||
+140
-12
@@ -1,6 +1,7 @@
|
||||
from decimal import Decimal
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import unittest
|
||||
|
||||
import pytz
|
||||
@@ -9,7 +10,7 @@ from dsmr_parser import telegram_specifications
|
||||
from dsmr_parser.exceptions import InvalidChecksumError, ParseError
|
||||
from dsmr_parser.objects import CosemObject, MBusObject, MBusObjectPeak
|
||||
from dsmr_parser.parsers import TelegramParser
|
||||
from test.example_telegrams import TELEGRAM_FLUVIUS_V171
|
||||
from test.example_telegrams import TELEGRAM_FLUVIUS_V171, TELEGRAM_FLUVIUS_V171_ALT
|
||||
|
||||
|
||||
class TelegramParserFluviusTest(unittest.TestCase):
|
||||
@@ -210,17 +211,17 @@ class TelegramParserFluviusTest(unittest.TestCase):
|
||||
assert isinstance(result.ACTUAL_SWITCH_POSITION.value, int)
|
||||
assert result.ACTUAL_SWITCH_POSITION.value == 1
|
||||
|
||||
# BELGIUM_MAX_POWER_PER_PHASE (0-0:17.0.0)
|
||||
assert isinstance(result.BELGIUM_MAX_POWER_PER_PHASE, CosemObject)
|
||||
assert result.BELGIUM_MAX_POWER_PER_PHASE.unit == 'kW'
|
||||
assert isinstance(result.BELGIUM_MAX_POWER_PER_PHASE.value, Decimal)
|
||||
assert result.BELGIUM_MAX_POWER_PER_PHASE.value == Decimal('999.9')
|
||||
# ACTUAL_TRESHOLD_ELECTRICITY (0-0:17.0.0)
|
||||
assert isinstance(result.ACTUAL_TRESHOLD_ELECTRICITY, CosemObject)
|
||||
assert result.ACTUAL_TRESHOLD_ELECTRICITY.unit == 'kW'
|
||||
assert isinstance(result.ACTUAL_TRESHOLD_ELECTRICITY.value, Decimal)
|
||||
assert result.ACTUAL_TRESHOLD_ELECTRICITY.value == Decimal('999.9')
|
||||
|
||||
# BELGIUM_MAX_POWER_PER_PHASE (1-0:31.4.0)
|
||||
assert isinstance(result.BELGIUM_MAX_CURRENT_PER_PHASE, CosemObject)
|
||||
assert result.BELGIUM_MAX_CURRENT_PER_PHASE.unit == 'A'
|
||||
assert isinstance(result.BELGIUM_MAX_CURRENT_PER_PHASE.value, Decimal)
|
||||
assert result.BELGIUM_MAX_CURRENT_PER_PHASE.value == Decimal('999')
|
||||
# FUSE_THRESHOLD_L1 (1-0:31.4.0)
|
||||
assert isinstance(result.FUSE_THRESHOLD_L1, CosemObject)
|
||||
assert result.FUSE_THRESHOLD_L1.unit == 'A'
|
||||
assert isinstance(result.FUSE_THRESHOLD_L1.value, Decimal)
|
||||
assert result.FUSE_THRESHOLD_L1.value == Decimal('999')
|
||||
|
||||
# TEXT_MESSAGE (0-0:96.13.0)
|
||||
assert isinstance(result.TEXT_MESSAGE, CosemObject)
|
||||
@@ -286,6 +287,133 @@ class TelegramParserFluviusTest(unittest.TestCase):
|
||||
|
||||
def test_checksum_missing(self):
|
||||
# Remove the checksum value causing a ParseError.
|
||||
corrupted_telegram = TELEGRAM_FLUVIUS_V171.replace('!911C\r\n', '')
|
||||
corrupted_telegram = TELEGRAM_FLUVIUS_V171.replace('!3AD7\r\n', '')
|
||||
with self.assertRaises(ParseError):
|
||||
TelegramParser.validate_checksum(corrupted_telegram)
|
||||
|
||||
def test_to_json(self):
|
||||
parser = TelegramParser(telegram_specifications.BELGIUM_FLUVIUS)
|
||||
telegram = parser.parse(TELEGRAM_FLUVIUS_V171_ALT)
|
||||
json_data = json.loads(telegram.to_json())
|
||||
|
||||
self.assertEqual(
|
||||
json_data,
|
||||
{'BELGIUM_VERSION_INFORMATION': {'value': '50217', 'unit': None},
|
||||
'BELGIUM_EQUIPMENT_IDENTIFIER': {'value': '3153414733313030373231333236', 'unit': None},
|
||||
'P1_MESSAGE_TIMESTAMP': {'value': '2023-11-02T11:15:48+00:00', 'unit': None},
|
||||
'ELECTRICITY_USED_TARIFF_1': {'value': 301.548, 'unit': 'kWh'},
|
||||
'ELECTRICITY_USED_TARIFF_2': {'value': 270.014, 'unit': 'kWh'},
|
||||
'ELECTRICITY_DELIVERED_TARIFF_1': {'value': 0.005, 'unit': 'kWh'},
|
||||
'ELECTRICITY_DELIVERED_TARIFF_2': {'value': 0.0, 'unit': 'kWh'},
|
||||
'ELECTRICITY_ACTIVE_TARIFF': {'value': '0001', 'unit': None},
|
||||
'BELGIUM_CURRENT_AVERAGE_DEMAND': {'value': 0.052, 'unit': 'kW'},
|
||||
'BELGIUM_MAXIMUM_DEMAND_MONTH': {'datetime': '2023-11-02T10:45:00+00:00',
|
||||
'value': 3.064, 'unit': 'kW'},
|
||||
'BELGIUM_MAXIMUM_DEMAND_13_MONTHS': [{'datetime': '2023-07-31T22:00:00+00:00',
|
||||
'occurred': None, 'value': 0.0, 'unit': 'kW'},
|
||||
{'datetime': '2023-08-31T22:00:00+00:00',
|
||||
'occurred': '2023-08-31T16:15:00+00:00',
|
||||
'value': 1.862, 'unit': 'kW'},
|
||||
{'datetime': '2023-09-30T22:00:00+00:00',
|
||||
'occurred': '2023-09-10T16:30:00+00:00',
|
||||
'value': 4.229, 'unit': 'kW'},
|
||||
{'datetime': '2023-10-31T23:00:00+00:00',
|
||||
'occurred': '2023-10-16T11:00:00+00:00',
|
||||
'value': 4.927, 'unit': 'kW'}],
|
||||
'CURRENT_ELECTRICITY_USAGE': {'value': 0.338, 'unit': 'kW'},
|
||||
'CURRENT_ELECTRICITY_DELIVERY': {'value': 0.0, 'unit': 'kW'},
|
||||
'INSTANTANEOUS_ACTIVE_POWER_L1_POSITIVE': {'value': 0.047, 'unit': 'kW'},
|
||||
'INSTANTANEOUS_ACTIVE_POWER_L2_POSITIVE': {'value': 0.179, 'unit': 'kW'},
|
||||
'INSTANTANEOUS_ACTIVE_POWER_L3_POSITIVE': {'value': 0.111, 'unit': 'kW'},
|
||||
'INSTANTANEOUS_ACTIVE_POWER_L1_NEGATIVE': {'value': 0.0, 'unit': 'kW'},
|
||||
'INSTANTANEOUS_ACTIVE_POWER_L2_NEGATIVE': {'value': 0.0, 'unit': 'kW'},
|
||||
'INSTANTANEOUS_ACTIVE_POWER_L3_NEGATIVE': {'value': 0.0, 'unit': 'kW'},
|
||||
'INSTANTANEOUS_VOLTAGE_L1': {'value': 232.9, 'unit': 'V'},
|
||||
'INSTANTANEOUS_VOLTAGE_L2': {'value': 228.1, 'unit': 'V'},
|
||||
'INSTANTANEOUS_VOLTAGE_L3': {'value': 228.1, 'unit': 'V'},
|
||||
'INSTANTANEOUS_CURRENT_L1': {'value': 0.27, 'unit': 'A'},
|
||||
'INSTANTANEOUS_CURRENT_L2': {'value': 0.88, 'unit': 'A'},
|
||||
'INSTANTANEOUS_CURRENT_L3': {'value': 0.52, 'unit': 'A'},
|
||||
'ACTUAL_SWITCH_POSITION': {'value': 1, 'unit': None},
|
||||
'ACTUAL_TRESHOLD_ELECTRICITY': {'value': 999.9, 'unit': 'kW'},
|
||||
'FUSE_THRESHOLD_L1': {'value': 999.0, 'unit': 'A'},
|
||||
'TEXT_MESSAGE': {'value': None, 'unit': None},
|
||||
'BELGIUM_MBUS1_DEVICE_TYPE': {'value': 3, 'unit': None},
|
||||
'MBUS_DEVICES': [{'BELGIUM_MBUS1_DEVICE_TYPE': {'value': 3, 'unit': None},
|
||||
'BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER': {'value': '37464C4F32313233303838303237',
|
||||
'unit': None},
|
||||
'BELGIUM_MBUS1_VALVE_POSITION': {'value': 1, 'unit': None},
|
||||
'BELGIUM_MBUS1_METER_READING2': {'datetime': '2023-11-02T11:10:02+00:00',
|
||||
'value': 92.287, 'unit': 'm3'},
|
||||
'CHANNEL_ID': 1},
|
||||
{'BELGIUM_MBUS2_DEVICE_TYPE': {'value': 7, 'unit': None},
|
||||
'BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER': {'value': '3853455430303030393631313733',
|
||||
'unit': None},
|
||||
'BELGIUM_MBUS2_METER_READING1': {'datetime': '2023-11-02T11:15:32+00:00',
|
||||
'value': 8.579, 'unit': 'm3'},
|
||||
'CHANNEL_ID': 2}],
|
||||
'BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER': {'value': '37464C4F32313233303838303237', 'unit': None},
|
||||
'BELGIUM_MBUS1_VALVE_POSITION': {'value': 1, 'unit': None},
|
||||
'BELGIUM_MBUS1_METER_READING2': {'datetime': '2023-11-02T11:10:02+00:00', 'value': 92.287, 'unit': 'm3'},
|
||||
'BELGIUM_MBUS2_DEVICE_TYPE': {'value': 7, 'unit': None},
|
||||
'BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER': {'value': '3853455430303030393631313733', 'unit': None},
|
||||
'BELGIUM_MBUS2_METER_READING1': {'datetime': '2023-11-02T11:15:32+00:00', 'value': 8.579, 'unit': 'm3'}}
|
||||
)
|
||||
|
||||
def test_to_str(self):
|
||||
parser = TelegramParser(telegram_specifications.BELGIUM_FLUVIUS)
|
||||
telegram = parser.parse(TELEGRAM_FLUVIUS_V171_ALT)
|
||||
|
||||
self.assertEqual(
|
||||
str(telegram),
|
||||
(
|
||||
'BELGIUM_VERSION_INFORMATION: 50217 [None]\n'
|
||||
'BELGIUM_EQUIPMENT_IDENTIFIER: 3153414733313030373231333236 [None]\n'
|
||||
'P1_MESSAGE_TIMESTAMP: 2023-11-02T11:15:48+00:00 [None]\n'
|
||||
'ELECTRICITY_USED_TARIFF_1: 301.548 [kWh]\n'
|
||||
'ELECTRICITY_USED_TARIFF_2: 270.014 [kWh]\n'
|
||||
'ELECTRICITY_DELIVERED_TARIFF_1: 0.005 [kWh]\n'
|
||||
'ELECTRICITY_DELIVERED_TARIFF_2: 0.000 [kWh]\n'
|
||||
'ELECTRICITY_ACTIVE_TARIFF: 0001 [None]\n'
|
||||
'BELGIUM_CURRENT_AVERAGE_DEMAND: 0.052 [kW]\n'
|
||||
'BELGIUM_MAXIMUM_DEMAND_MONTH: 3.064 [kW] at 2023-11-02T10:45:00+00:00\n'
|
||||
'0.0 [kW] at 2023-07-31T22:00:00+00:00 occurred None'
|
||||
'1.862 [kW] at 2023-08-31T22:00:00+00:00 occurred 2023-08-31T16:15:00+00:00'
|
||||
'4.229 [kW] at 2023-09-30T22:00:00+00:00 occurred 2023-09-10T16:30:00+00:00'
|
||||
'4.927 [kW] at 2023-10-31T23:00:00+00:00 occurred 2023-10-16T11:00:00+00:00'
|
||||
'CURRENT_ELECTRICITY_USAGE: 0.338 [kW]\n'
|
||||
'CURRENT_ELECTRICITY_DELIVERY: 0.000 [kW]\n'
|
||||
'INSTANTANEOUS_ACTIVE_POWER_L1_POSITIVE: 0.047 [kW]\n'
|
||||
'INSTANTANEOUS_ACTIVE_POWER_L2_POSITIVE: 0.179 [kW]\n'
|
||||
'INSTANTANEOUS_ACTIVE_POWER_L3_POSITIVE: 0.111 [kW]\n'
|
||||
'INSTANTANEOUS_ACTIVE_POWER_L1_NEGATIVE: 0.000 [kW]\n'
|
||||
'INSTANTANEOUS_ACTIVE_POWER_L2_NEGATIVE: 0.000 [kW]\n'
|
||||
'INSTANTANEOUS_ACTIVE_POWER_L3_NEGATIVE: 0.000 [kW]\n'
|
||||
'INSTANTANEOUS_VOLTAGE_L1: 232.9 [V]\n'
|
||||
'INSTANTANEOUS_VOLTAGE_L2: 228.1 [V]\n'
|
||||
'INSTANTANEOUS_VOLTAGE_L3: 228.1 [V]\n'
|
||||
'INSTANTANEOUS_CURRENT_L1: 0.27 [A]\n'
|
||||
'INSTANTANEOUS_CURRENT_L2: 0.88 [A]\n'
|
||||
'INSTANTANEOUS_CURRENT_L3: 0.52 [A]\n'
|
||||
'ACTUAL_SWITCH_POSITION: 1 [None]\n'
|
||||
'ACTUAL_TRESHOLD_ELECTRICITY: 999.9 [kW]\n'
|
||||
'FUSE_THRESHOLD_L1: 999 [A]\n'
|
||||
'TEXT_MESSAGE: None [None]\n'
|
||||
'BELGIUM_MBUS1_DEVICE_TYPE: 3 [None]\n'
|
||||
'MBUS DEVICE (channel 1)\n'
|
||||
' BELGIUM_MBUS1_DEVICE_TYPE: 3 [None]\n'
|
||||
' BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER: 37464C4F32313233303838303237 [None]\n'
|
||||
' BELGIUM_MBUS1_VALVE_POSITION: 1 [None]\n'
|
||||
' BELGIUM_MBUS1_METER_READING2: 92.287 [m3] at 2023-11-02T11:10:02+00:00\n'
|
||||
'MBUS DEVICE (channel 2)\n'
|
||||
' BELGIUM_MBUS2_DEVICE_TYPE: 7 [None]\n'
|
||||
' BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER: 3853455430303030393631313733 [None]\n'
|
||||
' BELGIUM_MBUS2_METER_READING1: 8.579 [m3] at 2023-11-02T11:15:32+00:00\n'
|
||||
'BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER: 37464C4F32313233303838303237 [None]\n'
|
||||
'BELGIUM_MBUS1_VALVE_POSITION: 1 [None]\n'
|
||||
'BELGIUM_MBUS1_METER_READING2: 92.287 [m3] at 2023-11-02T11:10:02+00:00\n'
|
||||
'BELGIUM_MBUS2_DEVICE_TYPE: 7 [None]\n'
|
||||
'BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER: 3853455430303030393631313733 [None]\n'
|
||||
'BELGIUM_MBUS2_METER_READING1: 8.579 [m3] at 2023-11-02T11:15:32+00:00\n'
|
||||
)
|
||||
)
|
||||
|
||||
@@ -263,23 +263,23 @@ class TelegramParserV5EONHUTest(unittest.TestCase):
|
||||
assert isinstance(telegram.INSTANTANEOUS_REACTIVE_POWER_Q4.value, Decimal)
|
||||
assert telegram.INSTANTANEOUS_REACTIVE_POWER_Q4.value == Decimal('00.000')
|
||||
|
||||
# EON_HU_MAX_POWER_ON_L1 (1-0:31.4.0)
|
||||
assert isinstance(telegram.MAX_POWER_ON_L1, CosemObject)
|
||||
assert telegram.MAX_POWER_ON_L1.unit == 'A'
|
||||
assert isinstance(telegram.MAX_POWER_ON_L1.value, Decimal)
|
||||
assert telegram.MAX_POWER_ON_L1.value == Decimal('200.00')
|
||||
# FUSE_THRESHOLD_L1 (1-0:31.4.0)
|
||||
assert isinstance(telegram.FUSE_THRESHOLD_L1, CosemObject)
|
||||
assert telegram.FUSE_THRESHOLD_L1.unit == 'A'
|
||||
assert isinstance(telegram.FUSE_THRESHOLD_L1.value, Decimal)
|
||||
assert telegram.FUSE_THRESHOLD_L1.value == Decimal('200.00')
|
||||
|
||||
# EON_HU_MAX_POWER_ON_L2 (1-0:31.4.0)
|
||||
assert isinstance(telegram.MAX_POWER_ON_L2, CosemObject)
|
||||
assert telegram.MAX_POWER_ON_L2.unit == 'A'
|
||||
assert isinstance(telegram.MAX_POWER_ON_L2.value, Decimal)
|
||||
assert telegram.MAX_POWER_ON_L2.value == Decimal('200.00')
|
||||
# FUSE_THRESHOLD_L2 (1-0:31.4.0)
|
||||
assert isinstance(telegram.FUSE_THRESHOLD_L2, CosemObject)
|
||||
assert telegram.FUSE_THRESHOLD_L2.unit == 'A'
|
||||
assert isinstance(telegram.FUSE_THRESHOLD_L2.value, Decimal)
|
||||
assert telegram.FUSE_THRESHOLD_L2.value == Decimal('200.00')
|
||||
|
||||
# EON_HU_MAX_POWER_ON_L3 (1-0:31.4.0)
|
||||
assert isinstance(telegram.MAX_POWER_ON_L3, CosemObject)
|
||||
assert telegram.MAX_POWER_ON_L3.unit == 'A'
|
||||
assert isinstance(telegram.MAX_POWER_ON_L3.value, Decimal)
|
||||
assert telegram.MAX_POWER_ON_L3.value == Decimal('200.00')
|
||||
# FUSE_THRESHOLD_L3 (1-0:31.4.0)
|
||||
assert isinstance(telegram.FUSE_THRESHOLD_L3, CosemObject)
|
||||
assert telegram.FUSE_THRESHOLD_L3.unit == 'A'
|
||||
assert isinstance(telegram.FUSE_THRESHOLD_L3.value, Decimal)
|
||||
assert telegram.FUSE_THRESHOLD_L3.value == Decimal('200.00')
|
||||
|
||||
# TEXT_MESSAGE (0-0:96.13.0)
|
||||
assert isinstance(telegram.TEXT_MESSAGE, CosemObject)
|
||||
|
||||
@@ -68,6 +68,6 @@ class ProtocolTest(unittest.TestCase):
|
||||
|
||||
# 2nd call of keep_alive should close the transport
|
||||
self.protocol.keep_alive()
|
||||
assert mock_transport.close.called_once()
|
||||
mock_transport.close.assert_called_once()
|
||||
|
||||
self.protocol.connection_lost(None)
|
||||
|
||||
Reference in New Issue
Block a user