Prime a button from custom module

I want to be able to set the stats and colour of a button based on a condition in my custom module.

I have successfully coded the custom module to listen to my expression maps and respond if they change or are updated from cubase. What I can't work out how to do is "prime" a button in my panel, for example change it to red so that when it is then pressed it will get teh custom module to call an expression to update the maps in OSC.

It's the middle bit I can't do - I have created a button with an address that is read in OSC to call the update function and I can warn on the console that the files have been updated - all I want to do is change the status of the button to prompt the user to press to update the maps.

If you're interested, here is the watcher code that prompts on expression map change.

const mapFiles = glob.sync('E:/01 - Composing Data Drive/01 - Music Files/01 - Patches and Maps/01 - Cubase Mapings/01 - Expression Maps/Rebuilt Set 12-11-21/final patch numbers/*.expressionmap')

// Initialize watcher to monitor for changes to the expression maps

const watcher = chokidar.watch(mapFiles, {
    ignored: /(^|[\/\\])\../, // ignore dotfiles
    persistent: true
});

// Something to use when events are received.
const log = console.log.bind(console);
// Add event listeners.
watcher
    .on('change', primeUpdateBtn);

function primeUpdateBtn(){
   console.log("EXPRESSION MAP UPDATED - CHANGE STATUS OF BUTTON IN OSC TO PROMPT A REBUILD OF OSC BUTTONS")
}

This would do:

receive('/SCRIPT', `setVar("button_id", "primed", 1)`)

Then use VAR{primed} to define the appearance of the button, and make sure to reset the variable when needed.

This is the bit that I'm struggling with.
Do I need to do something like this is the css for the button? Sorry for such basic questions.

 #{
                OSC{primed, 1, false} == 0 ? "display:none;" : "background:#171C20"
            }

Using the OSC{} like this would work too but to update it from the custom module you'd call

receive('/button_address/primed', 1)

I must be missing something here - it’s not working.
This is my button set up I think how you have explained:

widget properties

And I've put this in the function:

function primeUpdateBtn(){
    console.log("OSC SEND BUTTON ON TO UPTATE")

    receive('/rebuildMapBtn/primed', "Test")
}

The function is called because I get the console log but the expected behaviour on the session is that the label on the OSC button will change from "default" to "Test", nothing however happens on the button.

You are mixing up two different syntaxes: VAR(} and OSC{}. The former creates a local variable in the widget that can be updated with setVar() (post #2), the latter creates an osc listener that can be updated with osc messages, as you attempt to do in your last post.

Got it cheers.

Will post my solution tomorrow but it got complicated as it turns out that the node that I was using was triggering multiple times at startup!

Fancy stuff! What was solution?