Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help #151

Open
jltnol opened this issue Apr 18, 2022 · 2 comments
Open

Need help #151

jltnol opened this issue Apr 18, 2022 · 2 comments

Comments

@jltnol
Copy link

jltnol commented Apr 18, 2022

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.......

@DrLuke
Copy link
Contributor

DrLuke commented Jun 18, 2022

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!

@jltnol
Copy link
Author

jltnol commented Jun 18, 2022

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)`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants