Using TDJSON to update container values?

Hey, I’m working with the TDJSON python library to be able to broadcast the custom parameters from a container over the web, update the values on a website, and then send the new values back to the component. This will involve multiple components and parameters being updated at the same time.

TDJSON’s opToJSONOp made it super easy to send all the data, but I’m wondering if there’s an efficient way to take the updated values and reassign them back to the container ideally using the same dictionary format.

I noticed addParametersFromJSONDict has the ability to overwrite and update the values of a container, but it seems like overkill to recreate a parameter every time instead of just modifying the value. Any tips would be greatly appreciated.

Those functions are definitely more engineered for working with creating custom parameter objects.

I think you’ll get what you’re looking for much more easily using the TDFunctions parameters getParInfo and applyParInfo.

Yes! Thank you Ivan, that’s exactly what I was looking for.

1 Like

Hey @Ivan is there a way to trigger a pulse using the same technique? Momentarys work fine, but nothing happens when I run the following code on a container that has a Pulse.

import TDFunctions
state = {"Pulse" : [1, "", "CONSTANT", None, False]}
TDFunctions.applyParInfo(op('container1'), state, setDefaults=False)

This will not trigger pulses. It’s only meant for data, not events. It wouldn’t be hard to analyze the par info dictionary yourself and handle pulsing as you like, though. The parInfo dictionary is not very complicated.

Thanks! I ended up doing that :slight_smile: