Forums

SONOS (SoCo PyPi) on Pythonanywhere

Hi,

I am experimenting with Pythonanywhere with my SONOS speakers. I have already worked with the PyPI SoCo Library successfully, on my Raspberry Pi in my local network. It's nice to have full control over the SONOS speakers (tracks, radio stations, groups, etc). But now I would like to trigger the Python scripts I made, remotely, using IFTTT, Alexa, Flic etc (preferably with just using Python). The convenient "speakers = list(soco.discover())" statement does not work whilst executed on Pythonanywhere. It produces the following :

Traceback (most recent call last): File "/home/xxx/mysite/20171210_SONOS_WEB.py", line 21, in <module> speakers = list(soco.discover()) File "/home/xxx/.local/lib/python3.6/site-packages/soco/discovery.py", line 131, in discover _sock.sendto(really_utf8(PLAYER_SEARCH), (MCAST_GRP, MCAST_PORT)) PermissionError: [Errno 1] Operation not permitted

Now I'm stuck. I think I understand that it doesn't work that easily. I suppose it would be quite insecure if it did. I have been Googling, but found hardly any info to help me on this. Anyone here who has done this before ?

Hi there, PythonAnywhere doesn't have direct access to your home network... I wonder if the best bet might be to somehow use your raspberry pi as a hopping point?

Yes, that's what I expected. Unfortunately, I have no clue on how "to use my Raspberry Pi as a hopping point". I am also not sure what that means. Making it a Wifi hotspot ? How will this help me in solving my problem ?

I think Harry means to setup your raspberry pi connected to your sonos speakers, and then running your speaker control code there.

That code could then interact with a PythonAnywhere webapp etc.