TahUtils
Python utilities for Tahu & Sparkplug B.
Install / Use
/learn @intellicintegration/TahUtilsREADME
TahUtils
A small wrapper package for using Tahu for Sparkplug B in Python. Comes with an unmodified (barring import structure) Tahu included, hence the use of the Eclipse license.
Examples
See the examples directory in the project repository.
Current Support
- Generating Sparkplug B topics
- Generating birth, death, and data payloads for nodes and devices
- Managing aliases
- Using enums for metric names
- Using dataclasses to manage metric names and metric states
- Parsing sparkplug b messages
Changes to the tahu library
Updating compiled Protobuf files
Assuming no major refactoring to the tahu library, updating the included tahu consists of the following steps:
-
Download the latest release from the repository: https://github.com/eclipse/tahu/tags
-
Extract the source code.
-
Regenerate the
sparkplug_b_pb2.pyfile per the instructions intahu-<version>/python/core/README.md. Usetahu-<version>/python/coreas your working directory when executing the command, and you'll need the protobuf compiler. -
Copy the contents of the
tahu-<version>/python/coredirectory to thetahutils/tahudirectory. -
Overwrite the
tahutils/tahu/__init__.pyfile with the appropriate imports, typically:from . import sparkplug_b_pb2 from . import array_packer from . import sparkplug_b -
Modify the imports in
tahutils/tahu/sparkplug_b.pyto include thetahupackage name:import tahutils.tahu.sparkplug_b_pb2 as sparkplug_b_pb2 import time from tahutils.tahu.sparkplug_b_pb2 import Payload from tahutils.tahu.array_packer import *
Fixing metric timestamps
As of this version, there is a bug in the tahu library relating to metric timestamps. See this pull request for more details.
This is patched by updating sparkplug_b.py.
def addMetric(container, name, alias, type, value, timestamp=None):
if timestamp is None:
timestamp = int(round(time.time() * 1000))
...
def addNullMetric(container, name, alias, type, timestamp=None):
if timestamp is None:
timestamp = int(round(time.time() * 1000))
metric = container.metrics.add()
if name is not None:
metric.name = name
if alias is not None:
metric.alias = alias
metric.timestamp = timestamp
metric.is_null = True
...
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
