# SmlLib
[![Tests Status](https://github.com/spacemanspiff2007/SmlLib/workflows/Tests/badge.svg)](https://github.com/spacemanspiff2007/SmlLib/actions?query=workflow%3ATests)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/SmlLib)](https://pypi.org/project/smllib/)
[![PyPI](https://img.shields.io/pypi/v/SmlLib)](https://pypi.org/project/smllib/)
[![Downloads](https://pepy.tech/badge/SmlLib)](https://pepy.tech/project/SmlLib)
_A SML (Smart Message Language) library_
## About
This library can be used to parse SML byte streams.
It does not read from external devices.
## Usage
The [sml2mqtt](https://pypi.org/project/sml2mqtt/) program makes use of this library.
Example:
```python
from smllib import SmlStreamReader
stream = SmlStreamReader()
stream.add(b'BytesFromSerialPort')
sml_frame = stream.get_frame()
if sml_frame is None:
print('Bytes missing')
# Add more bytes, once it's a complete frame the SmlStreamReader will
# return the frame instead of None
stream.add(b'BytesFromSerialPort')
sml_frame = stream.get_frame()
# A quick Shortcut to extract all values without parsing the whole frame
# In rare cases this might raise an InvalidBufferPos exception, then you have to use sml_frame.parse_frame()
obis_values = sml_frame.get_obis()
# return all values but slower
parsed_msgs = sml_frame.parse_frame()
for msg in parsed_msgs:
# prints a nice overview over the received values
print(msg.format_msg())
# In the parsed message the obis values are typically found like this
obis_values = parsed_msgs[1].message_body.val_list
# The obis attribute of the SmlListEntry carries different obis representations as attributes
list_entry = obis_values[0]
print(list_entry.obis) # 0100010800ff
print(list_entry.obis.obis_code) # 1-0:1.8.0*255
print(list_entry.obis.obis_short) # 1.8.0
```
```text
SmlMessage
transaction_id: 17c77d6b
group_no : 0
abort_on_error: 0
message_body <SmlOpenResponse>
codepage : None
client_id : None
req_file_id: 07ed29cd
server_id : 11111111111111111111
ref_time : None
sml_version: None
crc16 : 25375
SmlMessage
transaction_id: 17c77d6c
group_no : 0
abort_on_error: 0
message_body <SmlGetListResponse>
client_id : None
sever_id : 11111111111111111111
list_name : 0100620affff
act_sensor_time : 226361515
val_list: list
<SmlListEntry>
obis : 8181c78203ff (129-129:199.130.3*255)
status : None
val_time : None
unit : None
scaler : None
value : ISK
value_signature: None
-> (Hersteller-Identifikation)
<SmlListEntry>
obis : 0100000009ff (1-0:0.0.9*255)
status : None
val_time : None
unit : None
scaler : None
value : 11111111111111111111
value_signature: None
-> (Geräteeinzelidentifikation)
<SmlListEntry>
obis : 0100010800ff (1-0:1.8.0*255)
status : 386
val_time : None
unit : 30
scaler : -1
value : 123456789
value_signature: None
-> 12345678.9Wh (Zählerstand Total)
<SmlListEntry>
obis : 0100010801ff (1-0:1.8.1*255)
status : None
val_time : None
unit : 30
scaler : -1
value : 123456789
value_signature: None
-> 12345678.9Wh (Zählerstand Tarif 1)
<SmlListEntry>
obis : 0100010802ff (1-0:1.8.2*255)
status : None
val_time : None
unit : 30
scaler : -1
value : 0
value_signature: None
-> 0.0Wh (Zählerstand Tarif 2)
<SmlListEntry>
obis : 0100100700ff (1-0:16.7.0*255)
status : None
val_time : None
unit : 27
scaler : 0
value : 555
value_signature: None
-> 555W (aktuelle Wirkleistung)
<SmlListEntry>
obis : 8181c78205ff (129-129:199.130.5*255)
status : None
val_time : None
unit : None
scaler : None
value : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
value_signature: None
-> (Öffentlicher Schlüssel)
list_signature : None
act_gateway_time: None
crc16 : 22117
SmlMessage
transaction_id: 17c77d6d
group_no : 0
abort_on_error: 0
message_body <SmlCloseResponse>
global_signature: None
crc16 : 56696
```
Raw data
{
"_id": null,
"home_page": "https://github.com/spacemanspiff2007/SmlLib",
"name": "smllib",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "sml, obis, smart message language, energy meter",
"author": "spaceman_spiff",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/da/29/862991f849c8a9e5a149f4d1ed8a85e9a1414e8d943f119eed7930f69afe/smllib-1.4.tar.gz",
"platform": null,
"description": "# SmlLib\n[![Tests Status](https://github.com/spacemanspiff2007/SmlLib/workflows/Tests/badge.svg)](https://github.com/spacemanspiff2007/SmlLib/actions?query=workflow%3ATests)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/SmlLib)](https://pypi.org/project/smllib/)\n[![PyPI](https://img.shields.io/pypi/v/SmlLib)](https://pypi.org/project/smllib/)\n[![Downloads](https://pepy.tech/badge/SmlLib)](https://pepy.tech/project/SmlLib)\n\n\n_A SML (Smart Message Language) library_\n\n## About\nThis library can be used to parse SML byte streams.\nIt does not read from external devices.\n\n## Usage\nThe [sml2mqtt](https://pypi.org/project/sml2mqtt/) program makes use of this library.\n\n\nExample:\n```python\nfrom smllib import SmlStreamReader\n\nstream = SmlStreamReader()\nstream.add(b'BytesFromSerialPort')\nsml_frame = stream.get_frame()\nif sml_frame is None:\n print('Bytes missing')\n\n# Add more bytes, once it's a complete frame the SmlStreamReader will\n# return the frame instead of None\nstream.add(b'BytesFromSerialPort')\nsml_frame = stream.get_frame()\n\n# A quick Shortcut to extract all values without parsing the whole frame\n# In rare cases this might raise an InvalidBufferPos exception, then you have to use sml_frame.parse_frame()\nobis_values = sml_frame.get_obis()\n\n# return all values but slower\nparsed_msgs = sml_frame.parse_frame()\nfor msg in parsed_msgs:\n # prints a nice overview over the received values\n print(msg.format_msg())\n\n# In the parsed message the obis values are typically found like this\nobis_values = parsed_msgs[1].message_body.val_list\n\n# The obis attribute of the SmlListEntry carries different obis representations as attributes\nlist_entry = obis_values[0]\nprint(list_entry.obis) # 0100010800ff\nprint(list_entry.obis.obis_code) # 1-0:1.8.0*255\nprint(list_entry.obis.obis_short) # 1.8.0\n```\n\n```text\nSmlMessage\n transaction_id: 17c77d6b\n group_no : 0\n abort_on_error: 0\n message_body <SmlOpenResponse>\n codepage : None\n client_id : None\n req_file_id: 07ed29cd\n server_id : 11111111111111111111\n ref_time : None\n sml_version: None\n crc16 : 25375\nSmlMessage\n transaction_id: 17c77d6c\n group_no : 0\n abort_on_error: 0\n message_body <SmlGetListResponse>\n client_id : None\n sever_id : 11111111111111111111\n list_name : 0100620affff\n act_sensor_time : 226361515\n val_list: list\n <SmlListEntry>\n obis : 8181c78203ff (129-129:199.130.3*255)\n status : None\n val_time : None\n unit : None\n scaler : None\n value : ISK\n value_signature: None\n -> (Hersteller-Identifikation)\n <SmlListEntry>\n obis : 0100000009ff (1-0:0.0.9*255)\n status : None\n val_time : None\n unit : None\n scaler : None\n value : 11111111111111111111\n value_signature: None\n -> (Ger\u00e4teeinzelidentifikation)\n <SmlListEntry>\n obis : 0100010800ff (1-0:1.8.0*255)\n status : 386\n val_time : None\n unit : 30\n scaler : -1\n value : 123456789\n value_signature: None\n -> 12345678.9Wh (Z\u00e4hlerstand Total)\n <SmlListEntry>\n obis : 0100010801ff (1-0:1.8.1*255)\n status : None\n val_time : None\n unit : 30\n scaler : -1\n value : 123456789\n value_signature: None\n -> 12345678.9Wh (Z\u00e4hlerstand Tarif 1)\n <SmlListEntry>\n obis : 0100010802ff (1-0:1.8.2*255)\n status : None\n val_time : None\n unit : 30\n scaler : -1\n value : 0\n value_signature: None\n -> 0.0Wh (Z\u00e4hlerstand Tarif 2)\n <SmlListEntry>\n obis : 0100100700ff (1-0:16.7.0*255)\n status : None\n val_time : None\n unit : 27\n scaler : 0\n value : 555\n value_signature: None\n -> 555W (aktuelle Wirkleistung)\n <SmlListEntry>\n obis : 8181c78205ff (129-129:199.130.5*255)\n status : None\n val_time : None\n unit : None\n scaler : None\n value : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n value_signature: None\n -> (\u00d6ffentlicher Schl\u00fcssel)\n list_signature : None\n act_gateway_time: None\n crc16 : 22117\nSmlMessage\n transaction_id: 17c77d6d\n group_no : 0\n abort_on_error: 0\n message_body <SmlCloseResponse>\n global_signature: None\n crc16 : 56696\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "A library for the SML (Smart Message Language) protocol",
"version": "1.4",
"project_urls": {
"GitHub": "https://github.com/spacemanspiff2007/SmlLib",
"Homepage": "https://github.com/spacemanspiff2007/SmlLib"
},
"split_keywords": [
"sml",
" obis",
" smart message language",
" energy meter"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ca0fe3627f2499416ea925c988f5261699d03526d48f2dfd6e3e7fcabc0c904f",
"md5": "2ccf6aace035a6d312f01b35d8041085",
"sha256": "e6dd3de56e398a7137c3604f860e392325195c6819171a59bd5bb9f25358070f"
},
"downloads": -1,
"filename": "smllib-1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2ccf6aace035a6d312f01b35d8041085",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 31045,
"upload_time": "2024-04-05T05:42:56",
"upload_time_iso_8601": "2024-04-05T05:42:56.774794Z",
"url": "https://files.pythonhosted.org/packages/ca/0f/e3627f2499416ea925c988f5261699d03526d48f2dfd6e3e7fcabc0c904f/smllib-1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "da29862991f849c8a9e5a149f4d1ed8a85e9a1414e8d943f119eed7930f69afe",
"md5": "586dfd9358bc088a46176d76fc254b1f",
"sha256": "9f0bb15675855ff70d9945ced99d74527af6aace908c11f0ce00a67bc38a13de"
},
"downloads": -1,
"filename": "smllib-1.4.tar.gz",
"has_sig": false,
"md5_digest": "586dfd9358bc088a46176d76fc254b1f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 31197,
"upload_time": "2024-04-05T05:42:57",
"upload_time_iso_8601": "2024-04-05T05:42:57.959171Z",
"url": "https://files.pythonhosted.org/packages/da/29/862991f849c8a9e5a149f4d1ed8a85e9a1414e8d943f119eed7930f69afe/smllib-1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-05 05:42:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "spacemanspiff2007",
"github_project": "SmlLib",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "smllib"
}