Skip to content

Commit

Permalink
Revert to BELGIUM_5MIN_GAS_METER_READING for HA 2023.11
Browse files Browse the repository at this point in the history
  • Loading branch information
dupondje committed Nov 4, 2023
1 parent f796db1 commit bf3150e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 223 deletions.
30 changes: 1 addition & 29 deletions dsmr_parser/obis_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,35 +91,7 @@
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
# While WATER METER reports it's values on 24.2.1
# The GAS METER also reports its valve state on 24.4.0
# Dev type for gas = 7 and water = 8
BELGIUM_MBUS1_DEVICE_TYPE = r'^\d-1:24\.1\.0.+?\r\n'
BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER = r'^\d-1:96\.1\.1.+?\r\n'
BELGIUM_MBUS1_VALVE_POSITION = r'^\d-1:24\.4\.0.+?\r\n'
BELGIUM_MBUS1_METER_READING1 = r'^\d-1:24\.2\.1.+?\r\n'
BELGIUM_MBUS1_METER_READING2 = r'^\d-1:24\.2\.3.+?\r\n'

BELGIUM_MBUS2_DEVICE_TYPE = r'^\d-2:24\.1\.0.+?\r\n'
BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER = r'^\d-2:96\.1\.1.+?\r\n'
BELGIUM_MBUS2_VALVE_POSITION = r'^\d-2:24\.4\.0.+?\r\n'
BELGIUM_MBUS2_METER_READING1 = r'^\d-2:24\.2\.1.+?\r\n'
BELGIUM_MBUS2_METER_READING2 = r'^\d-2:24\.2\.3.+?\r\n'

BELGIUM_MBUS3_DEVICE_TYPE = r'^\d-3:24\.1\.0.+?\r\n'
BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER = r'^\d-3:96\.1\.1.+?\r\n'
BELGIUM_MBUS3_VALVE_POSITION = r'^\d-3:24\.4\.0.+?\r\n'
BELGIUM_MBUS3_METER_READING1 = r'^\d-3:24\.2\.1.+?\r\n'
BELGIUM_MBUS3_METER_READING2 = r'^\d-3:24\.2\.3.+?\r\n'

BELGIUM_MBUS4_DEVICE_TYPE = r'^\d-4:24\.1\.0.+?\r\n'
BELGIUM_MBUS4_EQUIPMENT_IDENTIFIER = r'^\d-4:96\.1\.1.+?\r\n'
BELGIUM_MBUS4_VALVE_POSITION = r'^\d-4:24\.4\.0.+?\r\n'
BELGIUM_MBUS4_METER_READING1 = r'^\d-4:24\.2\.1.+?\r\n'
BELGIUM_MBUS4_METER_READING2 = r'^\d-4:24\.2\.3.+?\r\n'

BELGIUM_5MIN_GAS_METER_READING = r'\d-\d:24\.2\.3.+?\r\n' # Different code, same format.

LUXEMBOURG_EQUIPMENT_IDENTIFIER = r'^\d-\d:42\.0\.0.+?\r\n' # Logical device name

Expand Down
120 changes: 2 additions & 118 deletions dsmr_parser/telegram_specifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,128 +640,12 @@
'value_name': 'TEXT_MESSAGE'
},
{
'obis_reference': obis.BELGIUM_MBUS1_DEVICE_TYPE,
'value_parser': CosemParser(ValueParser(int)),
'value_name': 'BELGIUM_MBUS1_DEVICE_TYPE'
},
{
'obis_reference': obis.BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER,
'value_parser': CosemParser(ValueParser(str)),
'value_name': 'BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER'
},
{
'obis_reference': obis.BELGIUM_MBUS1_VALVE_POSITION,
'value_parser': CosemParser(ValueParser(int)),
'value_name': 'BELGIUM_MBUS1_VALVE_POSITION'
},
{
'obis_reference': obis.BELGIUM_MBUS1_METER_READING1,
'value_parser': MBusParser(
ValueParser(timestamp),
ValueParser(Decimal)
),
'value_name': 'BELGIUM_MBUS1_METER_READING1'
},
{
'obis_reference': obis.BELGIUM_MBUS1_METER_READING2,
'value_parser': MBusParser(
ValueParser(timestamp),
ValueParser(Decimal)
),
'value_name': 'BELGIUM_MBUS1_METER_READING2'
},
{
'obis_reference': obis.BELGIUM_MBUS2_DEVICE_TYPE,
'value_parser': CosemParser(ValueParser(int)),
'value_name': 'BELGIUM_MBUS2_DEVICE_TYPE'
},
{
'obis_reference': obis.BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER,
'value_parser': CosemParser(ValueParser(str)),
'value_name': 'BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER'
},
{
'obis_reference': obis.BELGIUM_MBUS2_VALVE_POSITION,
'value_parser': CosemParser(ValueParser(int)),
'value_name': 'BELGIUM_MBUS2_VALVE_POSITION'
},
{
'obis_reference': obis.BELGIUM_MBUS2_METER_READING1,
'value_parser': MBusParser(
ValueParser(timestamp),
ValueParser(Decimal)
),
'value_name': 'BELGIUM_MBUS2_METER_READING1'
},
{
'obis_reference': obis.BELGIUM_MBUS2_METER_READING2,
'value_parser': MBusParser(
ValueParser(timestamp),
ValueParser(Decimal)
),
'value_name': 'BELGIUM_MBUS2_METER_READING2'
},
{
'obis_reference': obis.BELGIUM_MBUS3_DEVICE_TYPE,
'value_parser': CosemParser(ValueParser(int)),
'value_name': 'BELGIUM_MBUS3_DEVICE_TYPE'
},
{
'obis_reference': obis.BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER,
'value_parser': CosemParser(ValueParser(str)),
'value_name': 'BELGIUM_MBUS3_EQUIPMENT_IDENTIFIER'
},
{
'obis_reference': obis.BELGIUM_MBUS3_VALVE_POSITION,
'value_parser': CosemParser(ValueParser(int)),
'value_name': 'BELGIUM_MBUS3_VALVE_POSITION'
},
{
'obis_reference': obis.BELGIUM_MBUS3_METER_READING1,
'value_parser': MBusParser(
ValueParser(timestamp),
ValueParser(Decimal)
),
'value_name': 'BELGIUM_MBUS3_METER_READING1'
},
{
'obis_reference': obis.BELGIUM_MBUS3_METER_READING2,
'value_parser': MBusParser(
ValueParser(timestamp),
ValueParser(Decimal)
),
'value_name': 'BELGIUM_MBUS3_METER_READING2'
},
{
'obis_reference': obis.BELGIUM_MBUS4_DEVICE_TYPE,
'value_parser': CosemParser(ValueParser(int)),
'value_name': 'BELGIUM_MBUS4_DEVICE_TYPE'
},
{
'obis_reference': obis.BELGIUM_MBUS4_EQUIPMENT_IDENTIFIER,
'value_parser': CosemParser(ValueParser(str)),
'value_name': 'BELGIUM_MBUS4_EQUIPMENT_IDENTIFIER'
},
{
'obis_reference': obis.BELGIUM_MBUS4_VALVE_POSITION,
'value_parser': CosemParser(ValueParser(int)),
'value_name': 'BELGIUM_MBUS4_VALVE_POSITION'
},
{
'obis_reference': obis.BELGIUM_MBUS4_METER_READING1,
'value_parser': MBusParser(
ValueParser(timestamp),
ValueParser(Decimal)
),
'value_name': 'BELGIUM_MBUS4_METER_READING1'
},
{
'obis_reference': obis.BELGIUM_MBUS4_METER_READING2,
'obis_reference': obis.BELGIUM_5MIN_GAS_METER_READING,
'value_parser': MBusParser(
ValueParser(timestamp),
ValueParser(Decimal)
),
'value_name': 'BELGIUM_MBUS4_METER_READING2'
'value_name': 'BELGIUM_5MIN_GAS_METER_READING'
},
]
}
Expand Down
90 changes: 14 additions & 76 deletions test/test_parse_fluvius.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,47 +228,11 @@ def test_parse(self):
assert result.TEXT_MESSAGE.unit is None
assert result.TEXT_MESSAGE.value is None

# BELGIUM_MBUS1_DEVICE_TYPE (0-1:24.1.0)
assert isinstance(result.BELGIUM_MBUS1_DEVICE_TYPE, CosemObject)
assert result.BELGIUM_MBUS1_DEVICE_TYPE.unit is None
assert isinstance(result.BELGIUM_MBUS1_DEVICE_TYPE.value, int)
assert result.BELGIUM_MBUS1_DEVICE_TYPE.value == 3

# BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER (0-1:96.1.1)
assert isinstance(result.BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER, CosemObject)
assert result.BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER.unit is None
assert isinstance(result.BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER.value, str)
assert result.BELGIUM_MBUS1_EQUIPMENT_IDENTIFIER.value == '37464C4F32313139303333373333'

# BELGIUM_MBUS1_VALVE_POSITION (0-1:24.4.0)
assert isinstance(result.BELGIUM_MBUS1_VALVE_POSITION, CosemObject)
assert result.BELGIUM_MBUS1_VALVE_POSITION.unit is None
assert isinstance(result.BELGIUM_MBUS1_VALVE_POSITION.value, int)
assert result.BELGIUM_MBUS1_VALVE_POSITION.value == 1

# BELGIUM_MBUS1_METER_READING2 (0-1:24.2.3)
assert isinstance(result.BELGIUM_MBUS1_METER_READING2, MBusObject)
assert result.BELGIUM_MBUS1_METER_READING2.unit == 'm3'
assert isinstance(result.BELGIUM_MBUS1_METER_READING2.value, Decimal)
assert result.BELGIUM_MBUS1_METER_READING2.value == Decimal('112.384')

# BELGIUM_MBUS2_DEVICE_TYPE (0-2:24.1.0)
assert isinstance(result.BELGIUM_MBUS2_DEVICE_TYPE, CosemObject)
assert result.BELGIUM_MBUS2_DEVICE_TYPE.unit is None
assert isinstance(result.BELGIUM_MBUS2_DEVICE_TYPE.value, int)
assert result.BELGIUM_MBUS2_DEVICE_TYPE.value == 7

# BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER (0-2:96.1.1)
assert isinstance(result.BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER, CosemObject)
assert result.BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER.unit is None
assert isinstance(result.BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER.value, str)
assert result.BELGIUM_MBUS2_EQUIPMENT_IDENTIFIER.value == '3853414731323334353637383930'

# BELGIUM_MBUS2_METER_READING1 (0-1:24.2.1)
assert isinstance(result.BELGIUM_MBUS2_METER_READING1, MBusObject)
assert result.BELGIUM_MBUS2_METER_READING1.unit == 'm3'
assert isinstance(result.BELGIUM_MBUS2_METER_READING1.value, Decimal)
assert result.BELGIUM_MBUS2_METER_READING1.value == Decimal('872.234')
# BELGIUM_5MIN_GAS_METER_READING (0-x:24.2.3)
assert isinstance(result.BELGIUM_5MIN_GAS_METER_READING, MBusObject)
assert result.BELGIUM_5MIN_GAS_METER_READING.unit == 'm3'
assert isinstance(result.BELGIUM_5MIN_GAS_METER_READING.value, Decimal)
assert result.BELGIUM_5MIN_GAS_METER_READING.value == Decimal('112.384')

def test_checksum_valid(self):
# No exception is raised.
Expand Down Expand Up @@ -334,31 +298,18 @@ def test_to_json(self):
'INSTANTANEOUS_CURRENT_L1': {'value': 0.27, 'unit': 'A'},
'INSTANTANEOUS_CURRENT_L2': {'value': 0.88, 'unit': 'A'},
'INSTANTANEOUS_CURRENT_L3': {'value': 0.52, 'unit': 'A'},
'MBUS_DEVICES': [
{'BELGIUM_5MIN_GAS_METER_READING': {
'datetime': '2023-11-02T11:10:02+00:00',
'unit': 'm3',
'value': 92.287},
'CHANNEL_ID': 1}],
'ACTUAL_SWITCH_POSITION': {'value': 1, 'unit': None},
'ACTUAL_TRESHOLD_ELECTRICITY': {'value': 999.9, 'unit': 'kW'},
'BELGIUM_MAX_POWER_PER_PHASE': {'value': 999.9, 'unit': 'kW'},
'BELGIUM_MAX_CURRENT_PER_PHASE': {'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'}}
'BELGIUM_5MIN_GAS_METER_READING': {'datetime': '2023-11-02T11:10:02+00:00', 'value': 92.287, 'unit': 'm3'}}
)

def test_to_str(self):
Expand Down Expand Up @@ -401,21 +352,8 @@ def test_to_str(self):
'BELGIUM_MAX_POWER_PER_PHASE: 999.9 [kW]\n'
'BELGIUM_MAX_CURRENT_PER_PHASE: 999 [A]\n'
'TEXT_MESSAGE: None [None]\n'
'BELGIUM_MBUS1_DEVICE_TYPE: 3 [None]\n'
'BELGIUM_5MIN_GAS_METER_READING: 92.287 [m3] at 2023-11-02T11:10:02+00:00\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'
'\tBELGIUM_5MIN_GAS_METER_READING: 92.287 [m3] at 2023-11-02T11:10:02+00:00\n'
)
)

0 comments on commit bf3150e

Please sign in to comment.