obis-parser 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- obis_parser/__init__.py +71 -0
- obis_parser/_version.py +24 -0
- obis_parser/core.py +579 -0
- obis_parser/py.typed +1 -0
- obis_parser-0.0.1.dist-info/METADATA +143 -0
- obis_parser-0.0.1.dist-info/RECORD +8 -0
- obis_parser-0.0.1.dist-info/WHEEL +4 -0
- obis_parser-0.0.1.dist-info/licenses/LICENSE +73 -0
obis_parser/__init__.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""Dependency-free OBIS parser and measurement catalog for smart meters and energy gateways.
|
|
2
|
+
|
|
3
|
+
Usage examples:
|
|
4
|
+
>>> from obis_parser import OBIS
|
|
5
|
+
>>>
|
|
6
|
+
>>> # 1. Parse and access properties
|
|
7
|
+
>>> obis = OBIS.parse("0100010800ff")
|
|
8
|
+
>>> obis.canonical
|
|
9
|
+
'1-0:1.8.0'
|
|
10
|
+
>>> obis.name
|
|
11
|
+
'Active energy import'
|
|
12
|
+
>>> obis.slug
|
|
13
|
+
'active_energy_import'
|
|
14
|
+
>>>
|
|
15
|
+
>>> # 2. Multi-meter channels and dynamic tariffs
|
|
16
|
+
>>> obis = OBIS.parse("1-1:1.8.2")
|
|
17
|
+
>>> obis.name
|
|
18
|
+
'Active energy import (Channel 1, Tariff 2)'
|
|
19
|
+
>>> obis.slug
|
|
20
|
+
'active_energy_import_channel_tariff'
|
|
21
|
+
>>> obis.placeholders
|
|
22
|
+
{'channel': '1', 'tariff': '2'}
|
|
23
|
+
>>>
|
|
24
|
+
>>> # 3. Full metadata decode
|
|
25
|
+
>>> m = obis.decode()
|
|
26
|
+
>>> m.unit
|
|
27
|
+
'kWh'
|
|
28
|
+
>>> m.device_class
|
|
29
|
+
'energy'
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
from ._version import __version__, __version_tuple__
|
|
33
|
+
from .core import (
|
|
34
|
+
ELECTRICITY_MEDIUM,
|
|
35
|
+
OBIS,
|
|
36
|
+
OBIS_CATALOG,
|
|
37
|
+
MeasurementKey,
|
|
38
|
+
OBISBillingPeriod,
|
|
39
|
+
OBISChannel,
|
|
40
|
+
OBISDeviceClass,
|
|
41
|
+
OBISMeasurement,
|
|
42
|
+
OBISMeasurementInfo,
|
|
43
|
+
OBISMeasurementType,
|
|
44
|
+
OBISMedium,
|
|
45
|
+
OBISNameDescriptor,
|
|
46
|
+
OBISPhysicalQuantity,
|
|
47
|
+
OBISStateClass,
|
|
48
|
+
OBISTariff,
|
|
49
|
+
ParsedOBIS,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
__all__ = [
|
|
53
|
+
"ELECTRICITY_MEDIUM",
|
|
54
|
+
"OBIS",
|
|
55
|
+
"OBIS_CATALOG",
|
|
56
|
+
"MeasurementKey",
|
|
57
|
+
"OBISBillingPeriod",
|
|
58
|
+
"OBISChannel",
|
|
59
|
+
"OBISDeviceClass",
|
|
60
|
+
"OBISMeasurement",
|
|
61
|
+
"OBISMeasurementInfo",
|
|
62
|
+
"OBISMeasurementType",
|
|
63
|
+
"OBISMedium",
|
|
64
|
+
"OBISNameDescriptor",
|
|
65
|
+
"OBISPhysicalQuantity",
|
|
66
|
+
"OBISStateClass",
|
|
67
|
+
"OBISTariff",
|
|
68
|
+
"ParsedOBIS",
|
|
69
|
+
"__version__",
|
|
70
|
+
"__version_tuple__",
|
|
71
|
+
]
|
obis_parser/_version.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '0.0.1'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 0, 1)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = None
|
obis_parser/core.py
ADDED
|
@@ -0,0 +1,579 @@
|
|
|
1
|
+
"""OBIS code parsing and measurement catalog for smart meters and energy gateways.
|
|
2
|
+
|
|
3
|
+
This module is dependency-free (standard library only) and provides:
|
|
4
|
+
- Object-oriented `OBIS` domain class with `OBIS.parse()`, canonicalization, and metadata.
|
|
5
|
+
- Full catalog of 31 German smart meter electricity registers (IEC 62056-6-1 / DIN 43863-3).
|
|
6
|
+
- Resolved measurement metadata via `obis.decode()` with 4-variant localization slugs.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import re
|
|
12
|
+
from dataclasses import dataclass, field
|
|
13
|
+
from string import hexdigits
|
|
14
|
+
from typing import Literal
|
|
15
|
+
|
|
16
|
+
_HEXDIGITS = set(hexdigits)
|
|
17
|
+
_OBIS_STRING_RE = re.compile(r"^(\d+)\s*-\s*(\d+)\s*:\s*(\d+)\s*\.\s*(\d+)\s*\.\s*(\d+)(?:\s*\*\s*(\d+))?$")
|
|
18
|
+
_OBIS_DOT_HEX_RE = re.compile(
|
|
19
|
+
r"^([0-9a-fA-F]{2})\.([0-9a-fA-F]{2})\.([0-9a-fA-F]{2})\."
|
|
20
|
+
r"([0-9a-fA-F]{2})\.([0-9a-fA-F]{2})\.([0-9a-fA-F]{2})$"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
#: Group A: Abstract medium (1 = Electricity, 7 = Gas, 4 = Heat, etc.)
|
|
24
|
+
type OBISMedium = int
|
|
25
|
+
|
|
26
|
+
#: Group B: Channel / sub-device index (0 = No channel / default)
|
|
27
|
+
type OBISChannel = int
|
|
28
|
+
|
|
29
|
+
#: Group C: Physical quantity (1 = Active power import, 2 = Active power export, etc.)
|
|
30
|
+
type OBISPhysicalQuantity = int
|
|
31
|
+
|
|
32
|
+
#: Group D: Measurement algorithm (8 = Energy register, 7 = Instantaneous power, etc.)
|
|
33
|
+
type OBISMeasurementType = int
|
|
34
|
+
|
|
35
|
+
#: Group E: Tariff rate register (0 = Total / unspecified, 1 = Tariff 1, etc.)
|
|
36
|
+
type OBISTariff = int
|
|
37
|
+
|
|
38
|
+
#: Group F: Billing period history (255 or 0 = Current period, 1..254 = Historic cycles)
|
|
39
|
+
type OBISBillingPeriod = int
|
|
40
|
+
|
|
41
|
+
type OBISDeviceClass = Literal[
|
|
42
|
+
"current",
|
|
43
|
+
"energy",
|
|
44
|
+
"power",
|
|
45
|
+
"voltage",
|
|
46
|
+
"reactive_energy",
|
|
47
|
+
"reactive_power",
|
|
48
|
+
"apparent_power",
|
|
49
|
+
"power_factor",
|
|
50
|
+
"frequency",
|
|
51
|
+
]
|
|
52
|
+
type OBISStateClass = Literal["measurement", "total_increasing"]
|
|
53
|
+
|
|
54
|
+
#: Medium code for electricity in the OBIS A field.
|
|
55
|
+
ELECTRICITY_MEDIUM = 1
|
|
56
|
+
|
|
57
|
+
#: F (billing period) values meaning "current period": absent, 0, or 255.
|
|
58
|
+
_CURRENT_PERIOD_F = (0, 255)
|
|
59
|
+
|
|
60
|
+
#: A measurement's identity: the (C, D) OBIS value groups — C is the physical
|
|
61
|
+
#: quantity, D the measurement/processing type (IEC 62056-6-1). The channel (B)
|
|
62
|
+
#: and tariff (E) fields are qualifiers and are NOT part of this key.
|
|
63
|
+
type MeasurementKey = tuple[OBISPhysicalQuantity, OBISMeasurementType]
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@dataclass(frozen=True)
|
|
67
|
+
class OBIS:
|
|
68
|
+
"""A structured representation of an OBIS code (A-B:C.D.E*F)."""
|
|
69
|
+
|
|
70
|
+
a: OBISMedium
|
|
71
|
+
b: OBISChannel
|
|
72
|
+
c: OBISPhysicalQuantity
|
|
73
|
+
d: OBISMeasurementType
|
|
74
|
+
e: OBISTariff
|
|
75
|
+
f: OBISBillingPeriod | None = None
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
def parse(cls, code: str) -> OBIS | None:
|
|
79
|
+
"""Parse an OBIS code from string, COSEM hex, dot-separated hex, or logical name."""
|
|
80
|
+
code = code.strip()
|
|
81
|
+
if not code:
|
|
82
|
+
return None
|
|
83
|
+
|
|
84
|
+
# Handle COSEM logical names with meter suffixes (e.g. '0100010800ff.1test000000001.sm')
|
|
85
|
+
if "." in code and len(code.split(".", 1)[0]) == 12:
|
|
86
|
+
prefix = code.split(".", 1)[0]
|
|
87
|
+
if all(char in _HEXDIGITS for char in prefix):
|
|
88
|
+
code = prefix
|
|
89
|
+
|
|
90
|
+
if match := _OBIS_STRING_RE.match(code):
|
|
91
|
+
return cls(
|
|
92
|
+
a=int(match.group(1)),
|
|
93
|
+
b=int(match.group(2)),
|
|
94
|
+
c=int(match.group(3)),
|
|
95
|
+
d=int(match.group(4)),
|
|
96
|
+
e=int(match.group(5)),
|
|
97
|
+
f=int(match.group(6)) if match.group(6) is not None else None,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
if match := _OBIS_DOT_HEX_RE.match(code):
|
|
101
|
+
return cls(
|
|
102
|
+
a=int(match.group(1), 16),
|
|
103
|
+
b=int(match.group(2), 16),
|
|
104
|
+
c=int(match.group(3), 16),
|
|
105
|
+
d=int(match.group(4), 16),
|
|
106
|
+
e=int(match.group(5), 16),
|
|
107
|
+
f=int(match.group(6), 16),
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
if len(code) == 12 and all(char in _HEXDIGITS for char in code):
|
|
111
|
+
return cls(
|
|
112
|
+
a=int(code[0:2], 16),
|
|
113
|
+
b=int(code[2:4], 16),
|
|
114
|
+
c=int(code[4:6], 16),
|
|
115
|
+
d=int(code[6:8], 16),
|
|
116
|
+
e=int(code[8:10], 16),
|
|
117
|
+
f=int(code[10:12], 16),
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
return None
|
|
121
|
+
|
|
122
|
+
@classmethod
|
|
123
|
+
def from_string(cls, code: str) -> OBIS | None:
|
|
124
|
+
"""Alias for `OBIS.parse()`."""
|
|
125
|
+
return cls.parse(code)
|
|
126
|
+
|
|
127
|
+
def __str__(self) -> str:
|
|
128
|
+
"""Return the canonical OBIS string."""
|
|
129
|
+
return self.to_obis_string()
|
|
130
|
+
|
|
131
|
+
def to_obis_string(self) -> str:
|
|
132
|
+
"""Return the canonical OBIS string used for entity keys."""
|
|
133
|
+
base = f"{self.a}-{self.b}:{self.c}.{self.d}.{self.e}"
|
|
134
|
+
if self.f is not None and self.f not in _CURRENT_PERIOD_F:
|
|
135
|
+
base += f"*{self.f}"
|
|
136
|
+
return base
|
|
137
|
+
|
|
138
|
+
@property
|
|
139
|
+
def canonical(self) -> str:
|
|
140
|
+
"""Canonical OBIS string representation."""
|
|
141
|
+
return self.to_obis_string()
|
|
142
|
+
|
|
143
|
+
@property
|
|
144
|
+
def medium(self) -> OBISMedium:
|
|
145
|
+
"""Abstract medium code (Group A)."""
|
|
146
|
+
return self.a
|
|
147
|
+
|
|
148
|
+
@property
|
|
149
|
+
def channel(self) -> OBISChannel:
|
|
150
|
+
"""Channel / sub-device index (Group B)."""
|
|
151
|
+
return self.b
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def physical_quantity(self) -> OBISPhysicalQuantity:
|
|
155
|
+
"""Physical quantity identifier (Group C)."""
|
|
156
|
+
return self.c
|
|
157
|
+
|
|
158
|
+
@property
|
|
159
|
+
def measurement_type(self) -> OBISMeasurementType:
|
|
160
|
+
"""Measurement algorithm / processing type (Group D)."""
|
|
161
|
+
return self.d
|
|
162
|
+
|
|
163
|
+
@property
|
|
164
|
+
def tariff(self) -> OBISTariff:
|
|
165
|
+
"""Tariff rate register (Group E)."""
|
|
166
|
+
return self.e
|
|
167
|
+
|
|
168
|
+
@property
|
|
169
|
+
def billing_period(self) -> OBISBillingPeriod | None:
|
|
170
|
+
"""Billing period history index (Group F)."""
|
|
171
|
+
return self.f
|
|
172
|
+
|
|
173
|
+
@property
|
|
174
|
+
def is_electricity(self) -> bool:
|
|
175
|
+
"""Return True if the code addresses the electricity medium (A=1)."""
|
|
176
|
+
return self.a == ELECTRICITY_MEDIUM
|
|
177
|
+
|
|
178
|
+
@property
|
|
179
|
+
def info(self) -> OBISMeasurementInfo | None:
|
|
180
|
+
"""Look up catalog metadata for this code's (C, D) measurement."""
|
|
181
|
+
return _get_obis_info(self)
|
|
182
|
+
|
|
183
|
+
@property
|
|
184
|
+
def name(self) -> str:
|
|
185
|
+
"""English display name with channel/tariff qualifiers."""
|
|
186
|
+
return self.describe().fallback_name
|
|
187
|
+
|
|
188
|
+
@property
|
|
189
|
+
def slug(self) -> str:
|
|
190
|
+
"""Localization slug with channel/tariff variant suffix."""
|
|
191
|
+
return self.describe().slug
|
|
192
|
+
|
|
193
|
+
@property
|
|
194
|
+
def translation_key(self) -> str:
|
|
195
|
+
"""Alias for slug (Home Assistant translation compatibility)."""
|
|
196
|
+
return self.slug
|
|
197
|
+
|
|
198
|
+
@property
|
|
199
|
+
def placeholders(self) -> dict[str, str]:
|
|
200
|
+
"""Channel and tariff placeholder mapping."""
|
|
201
|
+
return self.describe().placeholders
|
|
202
|
+
|
|
203
|
+
def describe(self) -> OBISNameDescriptor:
|
|
204
|
+
"""Resolve slug variant, placeholders, and English fallback name."""
|
|
205
|
+
return _describe_obis(self, self.info)
|
|
206
|
+
|
|
207
|
+
def decode(self) -> OBISMeasurement:
|
|
208
|
+
"""Decode into a fully-resolved OBISMeasurement object."""
|
|
209
|
+
return _build_measurement(self, self.info)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
#: Backwards-compatibility alias for OBIS.
|
|
213
|
+
ParsedOBIS = OBIS
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
@dataclass(frozen=True)
|
|
217
|
+
class OBISMeasurementInfo:
|
|
218
|
+
"""Catalog metadata for a base (C, D) measurement."""
|
|
219
|
+
|
|
220
|
+
name: str
|
|
221
|
+
slug: str
|
|
222
|
+
device_class: OBISDeviceClass | None
|
|
223
|
+
state_class: OBISStateClass | None
|
|
224
|
+
unit: str | None
|
|
225
|
+
icon: str
|
|
226
|
+
suggested_display_precision: int | None = None
|
|
227
|
+
|
|
228
|
+
@property
|
|
229
|
+
def translation_key(self) -> str:
|
|
230
|
+
"""Alias for slug (Home Assistant translation compatibility)."""
|
|
231
|
+
return self.slug
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
@dataclass(frozen=True)
|
|
235
|
+
class OBISNameDescriptor:
|
|
236
|
+
"""Resolved naming descriptors for an OBIS code."""
|
|
237
|
+
|
|
238
|
+
slug: str
|
|
239
|
+
placeholders: dict[str, str] = field(default_factory=dict)
|
|
240
|
+
fallback_name: str = ""
|
|
241
|
+
|
|
242
|
+
@property
|
|
243
|
+
def translation_key(self) -> str:
|
|
244
|
+
"""Alias for slug (Home Assistant translation compatibility)."""
|
|
245
|
+
return self.slug
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
@dataclass(frozen=True)
|
|
249
|
+
class OBISMeasurement:
|
|
250
|
+
"""A fully-resolved OBIS measurement with values, units, and localized metadata."""
|
|
251
|
+
|
|
252
|
+
code: OBIS
|
|
253
|
+
canonical: str
|
|
254
|
+
slug: str
|
|
255
|
+
name: str
|
|
256
|
+
unit: str | None
|
|
257
|
+
device_class: OBISDeviceClass | None
|
|
258
|
+
state_class: OBISStateClass | None
|
|
259
|
+
icon: str
|
|
260
|
+
suggested_display_precision: int | None
|
|
261
|
+
placeholders: dict[str, str] = field(default_factory=dict)
|
|
262
|
+
info: OBISMeasurementInfo | None = None
|
|
263
|
+
|
|
264
|
+
@property
|
|
265
|
+
def translation_key(self) -> str:
|
|
266
|
+
"""Alias for slug (Home Assistant translation compatibility)."""
|
|
267
|
+
return self.slug
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
OBIS_CATALOG: dict[MeasurementKey, OBISMeasurementInfo] = {
|
|
271
|
+
# Active energy (time-integral, D=8)
|
|
272
|
+
(1, 8): OBISMeasurementInfo(
|
|
273
|
+
"Active energy import",
|
|
274
|
+
"active_energy_import",
|
|
275
|
+
"energy",
|
|
276
|
+
"total_increasing",
|
|
277
|
+
"kWh",
|
|
278
|
+
"mdi:home-import-outline",
|
|
279
|
+
5,
|
|
280
|
+
),
|
|
281
|
+
(2, 8): OBISMeasurementInfo(
|
|
282
|
+
"Active energy export",
|
|
283
|
+
"active_energy_export",
|
|
284
|
+
"energy",
|
|
285
|
+
"total_increasing",
|
|
286
|
+
"kWh",
|
|
287
|
+
"mdi:home-export-outline",
|
|
288
|
+
5,
|
|
289
|
+
),
|
|
290
|
+
# Reactive energy
|
|
291
|
+
(3, 8): OBISMeasurementInfo(
|
|
292
|
+
"Reactive energy import",
|
|
293
|
+
"reactive_energy_import",
|
|
294
|
+
"reactive_energy",
|
|
295
|
+
"total_increasing",
|
|
296
|
+
"kvarh",
|
|
297
|
+
"mdi:home-import-outline",
|
|
298
|
+
5,
|
|
299
|
+
),
|
|
300
|
+
(4, 8): OBISMeasurementInfo(
|
|
301
|
+
"Reactive energy export",
|
|
302
|
+
"reactive_energy_export",
|
|
303
|
+
"reactive_energy",
|
|
304
|
+
"total_increasing",
|
|
305
|
+
"kvarh",
|
|
306
|
+
"mdi:home-export-outline",
|
|
307
|
+
5,
|
|
308
|
+
),
|
|
309
|
+
# Apparent energy (no standard HA device class / unit constant exists)
|
|
310
|
+
(9, 8): OBISMeasurementInfo(
|
|
311
|
+
"Apparent energy",
|
|
312
|
+
"apparent_energy",
|
|
313
|
+
None,
|
|
314
|
+
"total_increasing",
|
|
315
|
+
"kVAh",
|
|
316
|
+
"mdi:flash",
|
|
317
|
+
5,
|
|
318
|
+
),
|
|
319
|
+
# Active power (instantaneous, D=7)
|
|
320
|
+
(1, 7): OBISMeasurementInfo(
|
|
321
|
+
"Active power import",
|
|
322
|
+
"active_power_import",
|
|
323
|
+
"power",
|
|
324
|
+
"measurement",
|
|
325
|
+
"W",
|
|
326
|
+
"mdi:flash",
|
|
327
|
+
1,
|
|
328
|
+
),
|
|
329
|
+
(2, 7): OBISMeasurementInfo(
|
|
330
|
+
"Active power export",
|
|
331
|
+
"active_power_export",
|
|
332
|
+
"power",
|
|
333
|
+
"measurement",
|
|
334
|
+
"W",
|
|
335
|
+
"mdi:flash-outline",
|
|
336
|
+
1,
|
|
337
|
+
),
|
|
338
|
+
# Reactive power
|
|
339
|
+
(3, 7): OBISMeasurementInfo(
|
|
340
|
+
"Reactive power import",
|
|
341
|
+
"reactive_power_import",
|
|
342
|
+
"reactive_power",
|
|
343
|
+
"measurement",
|
|
344
|
+
"var",
|
|
345
|
+
"mdi:flash",
|
|
346
|
+
1,
|
|
347
|
+
),
|
|
348
|
+
(4, 7): OBISMeasurementInfo(
|
|
349
|
+
"Reactive power export",
|
|
350
|
+
"reactive_power_export",
|
|
351
|
+
"reactive_power",
|
|
352
|
+
"measurement",
|
|
353
|
+
"var",
|
|
354
|
+
"mdi:flash-outline",
|
|
355
|
+
1,
|
|
356
|
+
),
|
|
357
|
+
# Apparent power
|
|
358
|
+
(9, 7): OBISMeasurementInfo(
|
|
359
|
+
"Apparent power",
|
|
360
|
+
"apparent_power",
|
|
361
|
+
"apparent_power",
|
|
362
|
+
"measurement",
|
|
363
|
+
"VA",
|
|
364
|
+
"mdi:flash",
|
|
365
|
+
1,
|
|
366
|
+
),
|
|
367
|
+
# Active power total + absolute
|
|
368
|
+
(16, 7): OBISMeasurementInfo(
|
|
369
|
+
"Active power total",
|
|
370
|
+
"active_power_total",
|
|
371
|
+
"power",
|
|
372
|
+
"measurement",
|
|
373
|
+
"W",
|
|
374
|
+
"mdi:flash",
|
|
375
|
+
1,
|
|
376
|
+
),
|
|
377
|
+
(15, 7): OBISMeasurementInfo(
|
|
378
|
+
"Absolute active power",
|
|
379
|
+
"absolute_active_power",
|
|
380
|
+
"power",
|
|
381
|
+
"measurement",
|
|
382
|
+
"W",
|
|
383
|
+
"mdi:flash",
|
|
384
|
+
1,
|
|
385
|
+
),
|
|
386
|
+
# Active power per phase (signed vector sum)
|
|
387
|
+
(36, 7): OBISMeasurementInfo(
|
|
388
|
+
"Active power L1",
|
|
389
|
+
"active_power_l1",
|
|
390
|
+
"power",
|
|
391
|
+
"measurement",
|
|
392
|
+
"W",
|
|
393
|
+
"mdi:flash",
|
|
394
|
+
1,
|
|
395
|
+
),
|
|
396
|
+
(56, 7): OBISMeasurementInfo(
|
|
397
|
+
"Active power L2",
|
|
398
|
+
"active_power_l2",
|
|
399
|
+
"power",
|
|
400
|
+
"measurement",
|
|
401
|
+
"W",
|
|
402
|
+
"mdi:flash",
|
|
403
|
+
1,
|
|
404
|
+
),
|
|
405
|
+
(76, 7): OBISMeasurementInfo(
|
|
406
|
+
"Active power L3",
|
|
407
|
+
"active_power_l3",
|
|
408
|
+
"power",
|
|
409
|
+
"measurement",
|
|
410
|
+
"W",
|
|
411
|
+
"mdi:flash",
|
|
412
|
+
1,
|
|
413
|
+
),
|
|
414
|
+
# Active power per phase, import (+P)
|
|
415
|
+
(21, 7): OBISMeasurementInfo(
|
|
416
|
+
"Active power import L1",
|
|
417
|
+
"active_power_import_l1",
|
|
418
|
+
"power",
|
|
419
|
+
"measurement",
|
|
420
|
+
"W",
|
|
421
|
+
"mdi:flash",
|
|
422
|
+
1,
|
|
423
|
+
),
|
|
424
|
+
(41, 7): OBISMeasurementInfo(
|
|
425
|
+
"Active power import L2",
|
|
426
|
+
"active_power_import_l2",
|
|
427
|
+
"power",
|
|
428
|
+
"measurement",
|
|
429
|
+
"W",
|
|
430
|
+
"mdi:flash",
|
|
431
|
+
1,
|
|
432
|
+
),
|
|
433
|
+
(61, 7): OBISMeasurementInfo(
|
|
434
|
+
"Active power import L3",
|
|
435
|
+
"active_power_import_l3",
|
|
436
|
+
"power",
|
|
437
|
+
"measurement",
|
|
438
|
+
"W",
|
|
439
|
+
"mdi:flash",
|
|
440
|
+
1,
|
|
441
|
+
),
|
|
442
|
+
# Active power per phase, export (-P)
|
|
443
|
+
(22, 7): OBISMeasurementInfo(
|
|
444
|
+
"Active power export L1",
|
|
445
|
+
"active_power_export_l1",
|
|
446
|
+
"power",
|
|
447
|
+
"measurement",
|
|
448
|
+
"W",
|
|
449
|
+
"mdi:flash-outline",
|
|
450
|
+
1,
|
|
451
|
+
),
|
|
452
|
+
(42, 7): OBISMeasurementInfo(
|
|
453
|
+
"Active power export L2",
|
|
454
|
+
"active_power_export_l2",
|
|
455
|
+
"power",
|
|
456
|
+
"measurement",
|
|
457
|
+
"W",
|
|
458
|
+
"mdi:flash-outline",
|
|
459
|
+
1,
|
|
460
|
+
),
|
|
461
|
+
(62, 7): OBISMeasurementInfo(
|
|
462
|
+
"Active power export L3",
|
|
463
|
+
"active_power_export_l3",
|
|
464
|
+
"power",
|
|
465
|
+
"measurement",
|
|
466
|
+
"W",
|
|
467
|
+
"mdi:flash-outline",
|
|
468
|
+
1,
|
|
469
|
+
),
|
|
470
|
+
# Voltage per phase + total
|
|
471
|
+
(32, 7): OBISMeasurementInfo("Voltage L1", "voltage_l1", "voltage", "measurement", "V", "mdi:sine-wave", 1),
|
|
472
|
+
(52, 7): OBISMeasurementInfo("Voltage L2", "voltage_l2", "voltage", "measurement", "V", "mdi:sine-wave", 1),
|
|
473
|
+
(72, 7): OBISMeasurementInfo("Voltage L3", "voltage_l3", "voltage", "measurement", "V", "mdi:sine-wave", 1),
|
|
474
|
+
(12, 7): OBISMeasurementInfo("Voltage", "voltage", "voltage", "measurement", "V", "mdi:sine-wave", 1),
|
|
475
|
+
# Current per phase + total
|
|
476
|
+
(31, 7): OBISMeasurementInfo("Current L1", "current_l1", "current", "measurement", "A", "mdi:current-ac", 2),
|
|
477
|
+
(51, 7): OBISMeasurementInfo("Current L2", "current_l2", "current", "measurement", "A", "mdi:current-ac", 2),
|
|
478
|
+
(71, 7): OBISMeasurementInfo("Current L3", "current_l3", "current", "measurement", "A", "mdi:current-ac", 2),
|
|
479
|
+
(11, 7): OBISMeasurementInfo("Current", "current", "current", "measurement", "A", "mdi:current-ac", 2),
|
|
480
|
+
# Power factor + frequency
|
|
481
|
+
(13, 7): OBISMeasurementInfo(
|
|
482
|
+
"Power factor",
|
|
483
|
+
"power_factor",
|
|
484
|
+
"power_factor",
|
|
485
|
+
"measurement",
|
|
486
|
+
None,
|
|
487
|
+
"mdi:angle-acute",
|
|
488
|
+
2,
|
|
489
|
+
),
|
|
490
|
+
(14, 7): OBISMeasurementInfo("Frequency", "frequency", "frequency", "measurement", "Hz", "mdi:sine-wave", 2),
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
def _get_obis_info(obis: OBIS) -> OBISMeasurementInfo | None:
|
|
495
|
+
"""Look up measurement metadata from the catalog by (C, D)."""
|
|
496
|
+
if not obis.is_electricity:
|
|
497
|
+
return None
|
|
498
|
+
|
|
499
|
+
if obis.f is not None and obis.f not in _CURRENT_PERIOD_F:
|
|
500
|
+
return None
|
|
501
|
+
|
|
502
|
+
return OBIS_CATALOG.get((obis.c, obis.d))
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
def _has_tariff(e: int) -> bool:
|
|
506
|
+
"""A tariff register is any E in 1..254; 0 and 255 mean total/unspecified."""
|
|
507
|
+
return 1 <= e < 255
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
def _describe_obis(obis: OBIS, info: OBISMeasurementInfo | None) -> OBISNameDescriptor:
|
|
511
|
+
"""Resolve slug variant, placeholders, and fallback name for an OBIS code."""
|
|
512
|
+
if info is None:
|
|
513
|
+
canonical = obis.to_obis_string()
|
|
514
|
+
return OBISNameDescriptor(
|
|
515
|
+
slug="unknown_code",
|
|
516
|
+
placeholders={"code": canonical},
|
|
517
|
+
fallback_name=f"OBIS {canonical}",
|
|
518
|
+
)
|
|
519
|
+
|
|
520
|
+
has_channel = obis.b != 0
|
|
521
|
+
has_tariff = _has_tariff(obis.e)
|
|
522
|
+
|
|
523
|
+
placeholders: dict[str, str] = {}
|
|
524
|
+
fallback = info.name
|
|
525
|
+
if has_channel and has_tariff:
|
|
526
|
+
suffix = "_channel_tariff"
|
|
527
|
+
placeholders = {"channel": str(obis.b), "tariff": str(obis.e)}
|
|
528
|
+
fallback = f"{info.name} (Channel {obis.b}, Tariff {obis.e})"
|
|
529
|
+
elif has_channel:
|
|
530
|
+
suffix = "_channel"
|
|
531
|
+
placeholders = {"channel": str(obis.b)}
|
|
532
|
+
fallback = f"{info.name} (Channel {obis.b})"
|
|
533
|
+
elif has_tariff:
|
|
534
|
+
suffix = "_tariff"
|
|
535
|
+
placeholders = {"tariff": str(obis.e)}
|
|
536
|
+
fallback = f"{info.name} (Tariff {obis.e})"
|
|
537
|
+
else:
|
|
538
|
+
suffix = ""
|
|
539
|
+
|
|
540
|
+
return OBISNameDescriptor(
|
|
541
|
+
slug=f"{info.slug}{suffix}",
|
|
542
|
+
placeholders=placeholders,
|
|
543
|
+
fallback_name=fallback,
|
|
544
|
+
)
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
def _build_measurement(obis: OBIS, info: OBISMeasurementInfo | None) -> OBISMeasurement:
|
|
548
|
+
"""Assemble a complete OBISMeasurement object from parsed code and catalog info."""
|
|
549
|
+
descriptor = _describe_obis(obis, info)
|
|
550
|
+
canonical = obis.to_obis_string()
|
|
551
|
+
|
|
552
|
+
if info is None:
|
|
553
|
+
return OBISMeasurement(
|
|
554
|
+
code=obis,
|
|
555
|
+
canonical=canonical,
|
|
556
|
+
slug=descriptor.slug,
|
|
557
|
+
name=descriptor.fallback_name,
|
|
558
|
+
unit=None,
|
|
559
|
+
device_class=None,
|
|
560
|
+
state_class=None,
|
|
561
|
+
icon="mdi:gauge",
|
|
562
|
+
suggested_display_precision=None,
|
|
563
|
+
placeholders=descriptor.placeholders,
|
|
564
|
+
info=None,
|
|
565
|
+
)
|
|
566
|
+
|
|
567
|
+
return OBISMeasurement(
|
|
568
|
+
code=obis,
|
|
569
|
+
canonical=canonical,
|
|
570
|
+
slug=descriptor.slug,
|
|
571
|
+
name=descriptor.fallback_name,
|
|
572
|
+
unit=info.unit,
|
|
573
|
+
device_class=info.device_class,
|
|
574
|
+
state_class=info.state_class,
|
|
575
|
+
icon=info.icon,
|
|
576
|
+
suggested_display_precision=info.suggested_display_precision,
|
|
577
|
+
placeholders=descriptor.placeholders,
|
|
578
|
+
info=info,
|
|
579
|
+
)
|
obis_parser/py.typed
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Marker file for PEP 561.
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: obis-parser
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Dependency-free OBIS parser and measurement catalog for smart meters and energy gateways
|
|
5
|
+
Project-URL: Homepage, https://github.com/jannickfahlbusch/obis-parser
|
|
6
|
+
Project-URL: Repository, https://github.com/jannickfahlbusch/obis-parser
|
|
7
|
+
Project-URL: Issues, https://github.com/jannickfahlbusch/obis-parser/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/jannickfahlbusch/obis-parser/blob/main/CHANGELOG.md
|
|
9
|
+
Author-email: Jannick Fahlbusch <git@jf-projects.de>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: cosem,din-43863-3,energy,iec-62056-6-1,metering,obis,smart-meter,smgw,sml
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Home Automation
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Topic :: System :: Hardware
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.13
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# obis-parser
|
|
28
|
+
|
|
29
|
+
[](https://pypi.org/project/obis-parser/)
|
|
30
|
+
[](https://pypi.org/project/obis-parser/)
|
|
31
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
32
|
+
|
|
33
|
+
**Dependency-free OBIS parser and measurement catalog for smart meters and energy gateways**.
|
|
34
|
+
|
|
35
|
+
Extracts, parses, and normalizes OBIS (*Object Identification System*) codes (`A-B:C.D.E*F`) across smart meters (eHZ / mME), optical IR readouts (SML / IEC 62056-21), P1/DSMR meters, and Smart Meter Gateways (SMGW).
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
* **Zero External Dependencies:** Built entirely with standard library Python (`dataclasses`, `re`, `string`, `typing`).
|
|
42
|
+
* **Universal Ingestion:** Auto-detects and parses:
|
|
43
|
+
* Canonical strings: `1-0:1.8.0`, `1-0:1.8.0*255`, `1-1:1.7.0`
|
|
44
|
+
* Bare COSEM 12-hex: `0100010800ff`, `0100100700ff`, `010001080000` (F=0)
|
|
45
|
+
* COSEM logical names with meter suffixes: `0100010800ff.1lgz0067285558.sm`
|
|
46
|
+
* Dot-separated hex: `01.00.01.08.00.FF`
|
|
47
|
+
* **Single Domain Model (`OBIS`):** Everything is accessed directly on the `OBIS` instance (`.canonical`, `.name`, `.slug`, `.placeholders`, `.decode()`).
|
|
48
|
+
* **Channel & Tariff Qualifiers:** Treats Channel ($B \neq 0$) and Tariff ($1 \le E < 255$) as name qualifiers on $(C, D)$ base measurements.
|
|
49
|
+
* **4-Variant Localization Slugs:** Generates variant slugs (`base`, `_channel`, `_tariff`, `_channel_tariff`) with placeholder maps, ready for Home Assistant, Prometheus, or UI localization.
|
|
50
|
+
* **Curated Catalog:** 31 standard German electricity registers (DIN EN 62056-6-1 / DIN 43863-3) with units, device classes, state classes, and icons.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install obis-parser
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
or with [uv](https://github.com/astral-sh/uv):
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
uv add obis-parser
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Quick Start
|
|
69
|
+
|
|
70
|
+
### 1. Basic Parsing & Properties
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from obis_parser import OBIS
|
|
74
|
+
|
|
75
|
+
# Parses strings, bare-hex, dot-hex, or COSEM logical names
|
|
76
|
+
obis = OBIS.parse("0100010800ff")
|
|
77
|
+
if obis:
|
|
78
|
+
print(obis.canonical) # "1-0:1.8.0" (or str(obis))
|
|
79
|
+
print(obis.name) # "Active energy import"
|
|
80
|
+
print(obis.slug) # "active_energy_import"
|
|
81
|
+
print(obis.is_electricity) # True
|
|
82
|
+
print(obis.channel) # 0
|
|
83
|
+
print(obis.tariff) # 0
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 2. Multi-Meter Channels & Tariffs
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
# Multi-meter behind one gateway (Channel 1, Tariff 2)
|
|
90
|
+
obis = OBIS.parse("1-1:1.8.2")
|
|
91
|
+
if obis:
|
|
92
|
+
print(obis.canonical) # "1-1:1.8.2"
|
|
93
|
+
print(obis.name) # "Active energy import (Channel 1, Tariff 2)"
|
|
94
|
+
print(obis.slug) # "active_energy_import_channel_tariff"
|
|
95
|
+
print(obis.placeholders) # {"channel": "1", "tariff": "2"}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 3. Full Metadata Decode (`obis.decode()`)
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
obis = OBIS.parse("0100200700ff") # Voltage L1 (32.7.0)
|
|
102
|
+
if obis:
|
|
103
|
+
m = obis.decode()
|
|
104
|
+
print(m.name) # "Voltage L1"
|
|
105
|
+
print(m.unit) # "V"
|
|
106
|
+
print(m.device_class) # "voltage"
|
|
107
|
+
print(m.state_class) # "measurement"
|
|
108
|
+
print(m.icon) # "mdi:sine-wave"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Supported Registers (Catalog Overview)
|
|
114
|
+
|
|
115
|
+
| (C, D) | Measurement | Slug | Unit | Device Class | State Class |
|
|
116
|
+
|---|---|---|---|---|---|
|
|
117
|
+
| **(1, 8)** | Active energy import | `active_energy_import` | `kWh` | `energy` | `total_increasing` |
|
|
118
|
+
| **(2, 8)** | Active energy export | `active_energy_export` | `kWh` | `energy` | `total_increasing` |
|
|
119
|
+
| **(3, 8)** | Reactive energy import | `reactive_energy_import` | `kvarh` | `reactive_energy` | `total_increasing` |
|
|
120
|
+
| **(4, 8)** | Reactive energy export | `reactive_energy_export` | `kvarh` | `reactive_energy` | `total_increasing` |
|
|
121
|
+
| **(9, 8)** | Apparent energy | `apparent_energy` | `kVAh` | `None` | `total_increasing` |
|
|
122
|
+
| **(1, 7)** | Active power import | `active_power_import` | `W` | `power` | `measurement` |
|
|
123
|
+
| **(2, 7)** | Active power export | `active_power_export` | `W` | `power` | `measurement` |
|
|
124
|
+
| **(3, 7)** | Reactive power import | `reactive_power_import` | `var` | `reactive_power` | `measurement` |
|
|
125
|
+
| **(4, 7)** | Reactive power export | `reactive_power_export` | `var` | `reactive_power` | `measurement` |
|
|
126
|
+
| **(9, 7)** | Apparent power | `apparent_power` | `VA` | `apparent_power` | `measurement` |
|
|
127
|
+
| **(16, 7)** | Active power total (net sum) | `active_power_total` | `W` | `power` | `measurement` |
|
|
128
|
+
| **(15, 7)** | Absolute active power (\|P\|) | `absolute_active_power` | `W` | `power` | `measurement` |
|
|
129
|
+
| **(36/56/76, 7)** | Active power L1/L2/L3 (signed) | `active_power_l1..3` | `W` | `power` | `measurement` |
|
|
130
|
+
| **(21/41/61, 7)** | Active power import L1/L2/L3 (+P) | `active_power_import_l1..3` | `W` | `power` | `measurement` |
|
|
131
|
+
| **(22/42/62, 7)** | Active power export L1/L2/L3 (-P) | `active_power_export_l1..3` | `W` | `power` | `measurement` |
|
|
132
|
+
| **(32/52/72, 7)** | Voltage L1/L2/L3 | `voltage_l1..3` | `V` | `voltage` | `measurement` |
|
|
133
|
+
| **(12, 7)** | Voltage (total/RMS) | `voltage` | `V` | `voltage` | `measurement` |
|
|
134
|
+
| **(31/51/71, 7)** | Current L1/L2/L3 | `current_l1..3` | `A` | `current` | `measurement` |
|
|
135
|
+
| **(11, 7)** | Current (neutral/total) | `current` | `A` | `current` | `measurement` |
|
|
136
|
+
| **(13, 7)** | Power factor ($\cos \varphi$) | `power_factor` | `None` | `power_factor` | `measurement` |
|
|
137
|
+
| **(14, 7)** | Frequency | `frequency` | `Hz` | `frequency` | `measurement` |
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
Apache 2.0. Copyright 2026 Jannick Fahlbusch.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
obis_parser/__init__.py,sha256=gKsQX_DpS4pHIj3zzBGElr3ee52-7FzBmRBHBqxX_KU,1601
|
|
2
|
+
obis_parser/_version.py,sha256=8OsTLsIVB9D0HdPTmt5rVwyVUBe9xTVGkRslXicxzkM,520
|
|
3
|
+
obis_parser/core.py,sha256=bJqa2IsHK1MyPfQNO9S4BdpRY2L9_8vt5a8_FqSDgtk,17070
|
|
4
|
+
obis_parser/py.typed,sha256=bWew9mHgMy8LqMu7RuqQXFXLBxh2CRx0dUbSx-3wE48,27
|
|
5
|
+
obis_parser-0.0.1.dist-info/METADATA,sha256=R61TzpafQSVi2Pg5qEKUCkKIWZsmYjAA3XwU_TXU5ec,6706
|
|
6
|
+
obis_parser-0.0.1.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
7
|
+
obis_parser-0.0.1.dist-info/licenses/LICENSE,sha256=yjH7q_JxA9WnJMGfY1Pnwi0lLVLd19MRIfltsyl-gFc,10270
|
|
8
|
+
obis_parser-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
30
|
+
|
|
31
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
32
|
+
|
|
33
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
34
|
+
|
|
35
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
36
|
+
|
|
37
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
38
|
+
|
|
39
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
40
|
+
|
|
41
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
42
|
+
|
|
43
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
44
|
+
|
|
45
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
46
|
+
|
|
47
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
48
|
+
|
|
49
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
50
|
+
|
|
51
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
52
|
+
|
|
53
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
54
|
+
|
|
55
|
+
END OF TERMS AND CONDITIONS
|
|
56
|
+
|
|
57
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
58
|
+
|
|
59
|
+
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
|
60
|
+
|
|
61
|
+
Copyright 2026 Jannick Fahlbusch
|
|
62
|
+
|
|
63
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
64
|
+
you may not use this file except in compliance with the License.
|
|
65
|
+
You may obtain a copy of the License at
|
|
66
|
+
|
|
67
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
68
|
+
|
|
69
|
+
Unless required by applicable law or agreed to in writing, software
|
|
70
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
71
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
72
|
+
See the License for the specific language governing permissions and
|
|
73
|
+
limitations under the License.
|