How do I set the value of a switch via a custom module?

The title says it all! :slight_smile:

Use the receive() function to send an osc message to the client:

receive('/switch_address', preArg1, preArg2, value)

I ended up doing it like this: send(localhost, main_port, "/SCRIPT", "set('" + racks.switch+"'," + rackspaceValue + ",{send:false})")

Is one preferred over the other?

You're using send where receive should be used: sending to osc's own port just makes the trip longer for the message. Using a widget's address directly as written above is the most simple solution and should be preferred.