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

Mbus devices #141

wants to merge 2 commits into from

Conversation

dupondje
Copy link
Collaborator

Open for comments :)

At least the BE and the NL DSMR devices use MBUS.
Therefor we make the MBUS obis reference generic, and convert the V5
telegram to use MBUS values.

Also remove BELGIUM_MAX_POWER_PER_PHASE as this was a duplicate.

Finally set self.maxDiff = None to have a full test output on some
tests.
Comment on lines -91 to -116
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'

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.

Comment on lines +85 to +90
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'
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.

Comment on lines -433 to -437
{
'obis_reference': obis.DEVICE_TYPE,
'value_parser': CosemParser(ValueParser(int)),
'value_name': 'DEVICE_TYPE'
},
Copy link

Choose a reason for hiding this comment

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

May be keep de generic one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will cause same issue as above and is to generic as it will match an mbus device type.

@dupondje dupondje mentioned this pull request Oct 26, 2023
@dupondje
Copy link
Collaborator Author

Superseded by #142

@dupondje dupondje closed this Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants