-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from aequitas/master
Added DSMR 2.2 support
- Loading branch information
Showing
12 changed files
with
231 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
.idea | ||
*.pyc | ||
.tox | ||
.cache | ||
*.egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: python | ||
python: | ||
- 2.7 | ||
- 3.4 | ||
- 3.5 | ||
install: pip install tox-travis | ||
script: tox | ||
matrix: | ||
allow_failures: | ||
- python: 2.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import argparse | ||
from dsmr_parser.serial import SERIAL_SETTINGS_V2_2, SERIAL_SETTINGS_V4, SerialReader | ||
from dsmr_parser import telegram_specifications | ||
|
||
|
||
def console(): | ||
"""Output DSMR data to console.""" | ||
|
||
parser = argparse.ArgumentParser(description=console.__doc__) | ||
parser.add_argument('--device', default='/dev/ttyUSB0', | ||
help='port to read DSMR data from') | ||
parser.add_argument('--version', default='2.2', choices=['2.2', '4'], | ||
help='DSMR version (2.2, 4)') | ||
|
||
args = parser.parse_args() | ||
|
||
settings = { | ||
'2.2': (SERIAL_SETTINGS_V2_2, telegram_specifications.V2_2), | ||
'4': (SERIAL_SETTINGS_V4, telegram_specifications.V4), | ||
} | ||
|
||
serial_reader = SerialReader( | ||
device=args.device, | ||
serial_settings=settings[args.version][0], | ||
telegram_specification=settings[args.version][1], | ||
) | ||
|
||
for telegram in serial_reader.read(): | ||
for obiref, obj in telegram.items(): | ||
if obj: | ||
print(obj.value, obj.unit) | ||
print() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Test telegram parsing.""" | ||
|
||
from dsmr_parser.parsers import TelegramParserV2_2 | ||
from dsmr_parser import telegram_specifications | ||
from dsmr_parser.obis_references import CURRENT_ELECTRICITY_USAGE, GAS_METER_READING | ||
|
||
TELEGRAM_V2_2 = [ | ||
"/ISk5\2MT382-1004", | ||
"", | ||
"0-0:96.1.1(00000000000000)", | ||
"1-0:1.8.1(00001.001*kWh)", | ||
"1-0:1.8.2(00001.001*kWh)", | ||
"1-0:2.8.1(00001.001*kWh)", | ||
"1-0:2.8.2(00001.001*kWh)", | ||
"0-0:96.14.0(0001)", | ||
"1-0:1.7.0(0001.01*kW)", | ||
"1-0:2.7.0(0000.00*kW)", | ||
"0-0:17.0.0(0999.00*kW)", | ||
"0-0:96.3.10(1)", | ||
"0-0:96.13.1()", | ||
"0-0:96.13.0()", | ||
"0-1:24.1.0(3)", | ||
"0-1:96.1.0(000000000000)", | ||
"0-1:24.3.0(161107190000)(00)(60)(1)(0-1:24.2.1)(m3)", | ||
"(00001.001)", | ||
"0-1:24.4.0(1)", | ||
"!", | ||
] | ||
|
||
|
||
def test_parse_v2_2(): | ||
"""Test if telegram parsing results in correct results.""" | ||
|
||
parser = TelegramParserV2_2(telegram_specifications.V2_2) | ||
result = parser.parse(TELEGRAM_V2_2) | ||
|
||
assert float(result[CURRENT_ELECTRICITY_USAGE].value) == 1.01 | ||
assert result[CURRENT_ELECTRICITY_USAGE].unit == 'kW' | ||
assert float(result[GAS_METER_READING].value) == 1.001 | ||
assert result[GAS_METER_READING].unit == 'm3' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[tox] | ||
envlist = py34,py35 | ||
|
||
[testenv] | ||
deps= | ||
pytest | ||
pylama | ||
commands= | ||
py.test test {posargs} | ||
pylama dsmr_parser test | ||
|
||
[pylama:pylint] | ||
max_line_length = 100 | ||
|
||
[pylama:pycodestyle] | ||
max_line_length = 100 |