Need help
So first off, I am not a code guy, and am using OSC with Indigo, my home automation system, to send out OSC commands to light controlling software. Indigo has been using Python 2.x, and the script below has worked perfectly for me.
But now Indigo is upgrading to Python 3.x, and, I keep getting error messages. Here is the short snippet of code I've been using with Python 2.x:
`import python-osc
def send(address, value=0): c = OSC.OSCClient() c.connect(('192.168.6.102', 7700)) oscmsg = OSC.OSCMessage() oscmsg.setAddress(address) oscmsg.append(value) c.send(oscmsg)
send('indigo33',1.0) send('indigo33',0.0)`
My first error message was "No module named OSC', but was able to change the Import command to "Import pythonosc" and that got me past the first error message.
Now I'm getting this error message: name 'OSC' is not defined. I've tried changing a few things from OSC to pythonosc, which of course doesn't solve my problem. And I'd be lying if I thought I could just bang away on this and stumble on the right code to make this work, so I'm hoping someone can maybe help with this.
I have at least looked at the info in "examples", but can't make heads or tails of what should be. I have no need to "receive" OSC messages, only send them out. ANY help will be greatly appreciated.......
It seems like you're using a different osc library that unfortunately has similar naming. You can install this one by running pip install python-osc
I've adapted the example from the documentation to do exactly what your code does:
from pythonosc.udp_client import SimpleUDPClient
# Plug in your IP and port here
client = SimpleUDPClient("127.0.0.1", 1337)
# Send messages like this:
client.send_message("/indigo33", [1.0])
client.send_message("/indigo33", [0.0])
Hope that helps!
Hey there. thanks for your reply. I actually got this fixed a few months ago with someone from indigo, my HA software. And their solution mirrors yours. I appreciate your help
`from pythonosc.udp_client import SimpleUDPClient
def send(address, value=0): client = SimpleUDPClient("192.168.6.102",7700) client.send_message(address, value)
send('indigo105',1.0) send('indigo105',0.0)`