I'm trying to use the function "system.cirruslink.engine.publish()" to publish sparkplug messages back to a gateway.
The basic reason for this is that I'm using metadata properties on the tags for various things, and when these are updated on the gateway tags, it doesn't trigger a DCMD message the way changing the actual tag value would.
import sparkplug_b as sparkplug from sparkplug_b import addMetric, MetricDataType payload = sparkplug.getDdataPayload() addMetric(payload, 'metric.meta', None, MetricDataType.Boolean, False) topic='spBv1.0/...' result = system.cirruslink.engine.publish('SERVER', topic, payload.SerializeToString(), 1, False)|
I've actually been running the script successfully for a while by importing the sparkplug libraries into Ignition and using the provided functions to encode the messages, but recent changes to the Ignition python binary removed the time.gmtime() function, which is in turn required by the google protobuf library, so that whole route is now no longer possible.
Traceback (most recent call last): File "<input>", line 7, in <module> File "/home/user/.ignition/cache/gwscada.example.com_8088/C1/pylib/sparkplug_b/__init__.py", line 13, in <module> import sparkplug_b_pb2 File "/home/user/.ignition/cache/gwscada.example.com_8088/C1/pylib/sparkplug_b/sparkplug_b_pb2.py", line 8, in <module> from google.protobuf import reflection as _reflection File "/home/user/.ignition/cache/gwscada.example.com_8088/C1/pylib/google/protobuf/reflection.py", line 51, in <module> from google.protobuf import message_factory File "/home/user/.ignition/cache/gwscada.example.com_8088/C1/pylib/google/protobuf/message_factory.py", line 49, in <module> from google.protobuf.internal import python_message as message_impl File "/home/user/.ignition/cache/gwscada.example.com_8088/C1/pylib/google/protobuf/internal/python_message.py", line 70, in <module> from google.protobuf.internal import well_known_types File "/home/user/.ignition/cache/gwscada.example.com_8088/C1/pylib/google/protobuf/internal/well_known_types.py", line 99, in <module> _EPOCH_DATETIME = datetime.utcfromtimestamp(0) File "/home/user/.ignition/cache/gwscada.example.com_8088/C1/pylib/datetime.py", line 1623, in utcfromtimestamp y, m, d, hh, mm, ss, weekday, jday, dst = _time.gmtime(t) AttributeError: 'builtin_function_or_method' object has no attribute 'gmtime'
So what I'm trying to do is just get access to these encoding methods to convert my payload to sparkplug, which should already be present since that's what the driver does every time it sends a message.
I can use the function to send unencoded messages, but since the remote site is speaking in Sparkplug/Protobuf, these are not understood by the client.