Is there a better way to refresh widgets without hard-coding the UUID?

Maybe i'm just being weird, but having to hard-code UUIDs for all of my widgets feels wrong. This is mainly happening right now for me when I need to refresh a widget after it's tapped/long pressed. To do that I have to hard code the UUID in one or two places, often outside of the actual widget (e.g. named trigger). This feels wrong because if I create a new widget for some reason, or want a similar widget with slightly different content I have to duplicate even more since the UUID must be hard coded and run the risk of forgetting to update it (already happened once recently).

I was going to create a Feature Request but since I'm fairly new to BTT (and only really using the touch bar widgets and named triggers) I wasn't sure if this made any sense, much less outside of the touch bar, or if I'm just missing something. Does this make sense to anyone else? Has anyone come up with better solutions?

If you wish to avoid forgetting to update UUIDs in your scripts, you can save the UUIDs to BTT persistent variables via "set_persistent_string_variable", it just like global variables that every script can use. Instead of hardcoding the UUID, use the following code to retrieve the UUID:

tell application "BetterTouchTool" to set UUID to get_persistent_string_variable "VariableName"

If you only need the UUID for very few times, I still suggest using the hard-coding, tell an application to do something is time-consuming.

That's an interesting idea, and should work for most of my cases. I'll have to see if that feels any better when I update a script.

However that would still (mostly) prevent me from writing triggers usable by multiple widgets. Which I just realized I didn't really explain that I wanted to do/give a use case. Here's an example:

I have multiple sets of BT headphones that I use at different times of the day (work/home) and have modified and duplicated an AirPods widget I found on the forums (written by GoldenChaos and yyuuiko) to fit my needs. Since I have 2 headsets I have 2 widgets (I could probably combine them into 1 widget since I only have 1 connected at a time, but this was easier), and have duplicated triggers so I can perform the correct action (connect/disconnect and refresh) for each widget.
I would like to be able to write one set of triggers that do the right thing based on the uuid of the calling widget, making it easier to reuse the components instead of having to duplicate a trigger just to change a UUID. I could use one variable ("calling_widget_uuid") and just always reference that, but then I'm relying on execution times with async scripts not causing it to be overwritten by another widget running and calling the same trigger.

So what you'd need is the ability to pass an argument to a script assigned to a named trigger?
This is currently not possible, but I'm looking into ways to expand the java script functionality in BTT, which could allow this.

Either that or something similar to the standard variables where BTT could be queried for it. I've done most of my scripting so far in AppleScript/zsh (familiar with both and most of the widgets I found use them), but I would be happy to give Javascript a go if it adds functionality to support this.