Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mbus devices #141

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 44 additions & 35 deletions dsmr_parser/obis_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
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'
Expand All @@ -66,8 +69,48 @@
ACTUAL_SWITCH_POSITION = r'^\d-\d:96\.3\.10.+?\r\n'
VALVE_POSITION_GAS = r'^\d-\d:24\.4\.0.+?\r\n'

# Multiple 'slaves' can be linked to the main device.
# The type is reported on 24.1.0
# Specifications are in EN 13757-3
# For example: Water mater = 7, Gas meter = 3
# Identifier is on 96.1.0 (in NL for ex) or
# on 96.1.1 (in BE for ex)
# The values are reported on 24.2.1
# With an exception in Belgium for the GAS meter
# Be aware that for the gas volume, another OBIS-code is published
# than the one listed in section 7 of DSMR P1.
# This is due to the fact that in Belgium the not-temperature
# corrected gas volume is used while in the Netherlands,
# the temperature corrected gas volume is used.
MBUS1_DEVICE_TYPE = r'^\d-1:24\.1\.0.+?\r\n'
MBUS1_EQUIPMENT_IDENTIFIER = r'^\d-1:96\.1\.0.+?\r\n'
MBUS1_EQUIPMENT_IDENTIFIER_ALT = r'^\d-1:96\.1\.1.+?\r\n'
MBUS1_VALVE_POSITION = r'^\d-1:24\.4\.0.+?\r\n'
MBUS1_METER_READING = r'^\d-1:24\.2\.1.+?\r\n'
MBUS1_METER_READING_ALT = r'^\d-1:24\.2\.3.+?\r\n'
Comment on lines +85 to +90
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be these can be generic matching all devices:

Suggested change
MBUS1_DEVICE_TYPE = r'^\d-1:24\.1\.0.+?\r\n'
MBUS1_EQUIPMENT_IDENTIFIER = r'^\d-1:96\.1\.0.+?\r\n'
MBUS1_EQUIPMENT_IDENTIFIER_ALT = r'^\d-1:96\.1\.1.+?\r\n'
MBUS1_VALVE_POSITION = r'^\d-1:24\.4\.0.+?\r\n'
MBUS1_METER_READING = r'^\d-1:24\.2\.1.+?\r\n'
MBUS1_METER_READING_ALT = r'^\d-1:24\.2\.3.+?\r\n'
MBUS_DEVICE_TYPE = r'^\d-\d:24\.1\.0.+?\r\n'
MBUS_EQUIPMENT_IDENTIFIER = r'^\d-\d:96\.1\.0.+?\r\n'
MBUS_EQUIPMENT_IDENTIFIER_ALT = r'^\d-\d:96\.1\.1.+?\r\n'
MBUS_VALVE_POSITION = r'^\d-\d:24\.4\.0.+?\r\n'
MBUS_METER_READING = r'^\d-\d:24\.2\.1.+?\r\n'
MBUS_METER_READING_ALT = r'^\d-\d:24\.2\.3.+?\r\n'

The exiting references are generic too. The regex will simple give more matches if there are more devices.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik there can only be a specific regex per value you want to parse. Otherwise it will only match the first one.


MBUS2_DEVICE_TYPE = r'^\d-2:24\.1\.0.+?\r\n'
MBUS2_EQUIPMENT_IDENTIFIER = r'^\d-2:96\.1\.0.+?\r\n'
MBUS2_EQUIPMENT_IDENTIFIER_ALT = r'^\d-2:96\.1\.1.+?\r\n'
MBUS2_VALVE_POSITION = r'^\d-2:24\.4\.0.+?\r\n'
MBUS2_METER_READING = r'^\d-2:24\.2\.1.+?\r\n'
MBUS2_METER_READING_ALT = r'^\d-2:24\.2\.3.+?\r\n'

MBUS3_DEVICE_TYPE = r'^\d-3:24\.1\.0.+?\r\n'
MBUS3_EQUIPMENT_IDENTIFIER = r'^\d-3:96\.1\.0.+?\r\n'
MBUS3_EQUIPMENT_IDENTIFIER_ALT = r'^\d-3:96\.1\.1.+?\r\n'
MBUS3_VALVE_POSITION = r'^\d-3:24\.4\.0.+?\r\n'
MBUS3_METER_READING = r'^\d-3:24\.2\.1.+?\r\n'
MBUS3_METER_READING_ALT = r'^\d-3:24\.2\.3.+?\r\n'

MBUS4_DEVICE_TYPE = r'^\d-4:24\.1\.0.+?\r\n'
MBUS4_EQUIPMENT_IDENTIFIER = r'^\d-4:96\.1\.0.+?\r\n'
MBUS4_EQUIPMENT_IDENTIFIER_ALT = r'^\d-4:96\.1\.1.+?\r\n'
MBUS4_VALVE_POSITION = r'^\d-4:24\.4\.0.+?\r\n'
MBUS4_METER_READING = r'^\d-4:24\.2\.1.+?\r\n'
MBUS4_METER_READING_ALT = r'^\d-4:24\.2\.3.+?\r\n'

# TODO 17.0.0
# TODO 96.3.10

ELECTRICITY_USED_TARIFF_ALL = (
ELECTRICITY_USED_TARIFF_1,
Expand All @@ -88,38 +131,6 @@
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
# 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'

Comment on lines -91 to -116
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing these might be breaking for anyone using these.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. But backwards compatibility is not really an issue. You always depend on a specific version.
You neither can have multiple of the same regexes in the same parser, as only the first will match afaik.

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'


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

Expand All @@ -142,5 +153,3 @@
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'
Loading