Storing Value from payload using mqtt paho, system.tag.Async not working correctly with relative path in UDT

Dear All
I would like to ask you for a help, iam struggling with the using system.tag.writeAsync in the change script in UDT

The first row is not working, when iam trying to write in to tag defined via relative path,but second one is working with absolute path

system.tag.readblocking is working with the relative path no problem.

I tried to read to variable using system.tag.readblocking and then using it for writeAsync but was unsuccesfull as well.

Thank you for your help

Best regards Jakub

Relative tag addressing in a tag event script depends on the execution context of the event to know where it is in the tag tree. You are attaching the on_message function to be executed asynchronously by another subsystem, losing the necessary context. You will need to construct the necessary absolute tag path prior to defining on_message, so it will be available in its closure. Or pass it to on_message as a default argument.

thank for your help, solve it using global variable

No, that’s not a solution. You are using a four-second sleep in your tag event. You can get away with it once or twice, but you will eventually hang your tag groups.

Pass the absolute path to on_message.

Understand,
i used different approach without sleep reading only one payload on broker

but i would like to have one more question, if i used approach 1st or 2nd i always get error message

Failed to submit a listener notification task. Event loop shut down?

i was thinking is because i used loop in the 1st approach but in the 2nd one iam not doing any loop but still this error :frowning:

I would expect you to have to supply a function that will be called to receive actual values as they come in (aka a listener). You are using a subscribe operation.