I faced a challenge and came up with a kludgey solution, but wonder if there is a more elegant answer.
I am working to integrate a bunch of non-insteon automation and a/v gear (for example, a Nuvo Grand Concerto whole-house system). I am working on an AppleScript that controls the Nuvo via Serial Bridge. But I want to be able to control the Nuvo from within an Indigo Control Page (e.g., click a "mute" icon and have the Nuvo mute).
I had already created a bunch of state variable inside my AppleScript, with a parallel set inside Indigo (with logic to have my script update the Indigo variables, as appropriate).
I had the idea to extend this concept into a "message bus" with three Indigo variables: "scriptReadyForCommand," "indigoWantsToSendCommand" and "Payload." The idea is to have the script poll Indigo as pat of its core polling loop (which mainly scans the serial ports looking for stuff from devices). Inside Indigo control pages, I assign an AppleScript to certain actions (like clicking the "mute" button) and then queue up the appropriate command via my "bus" variables. My standalone script "sees" this on the next polling cycle and pulls down the payload variable and parses/processes as appropriate.
I can't directly send bytes over the serial ports from within Indigo because only one script at a time can use a serial port. I also wanted to maintain at least a bit of an abstraction layer to streamline things.
The above seems to work fine, but I am wondering if I (due to inexperience) am approaching this all wrong and should be doing this in a better / more conventional way.