I created a small Python3 script to act as a brigde between an automation system and the volumio player,
Like that i can load a playlist of webradios and select 1 of the webradio stations in that playlist by sending a "stream0-stream1-stream2-stream3 comamnds toward a created port on the volumio.
I have tested it on a python windows 10 and it is working, however if i try to run it on the volumio python (updated to python3) i have the next error.
1/ print(f"Connection from {address} has been established.") -> give me an error
2/ print(“Listen…”) -> after that line the program did create the socket -
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((socket.gethostname(), 8888))
s.listen(1)
print(“Listen…”)
clientsocket, address = s.accept()
print(f"Connection from {address} has been established.")
clientsocket.send(bytes(“Hey there!!!”,“utf-8”))
while True:
msg = clientsocket.recv(7)
print(msg.decode(“utf-8”))
msg = msg.decode("utf-8")
if msg == "stream0":
res = requests.get(http+IPPlayer+cmdstring+'clearQueue')
res = requests.get(http+IPPlayer+cmdstring+'playplaylist&name=streamlist')
print(res)
if msg == "stream1":
res = requests.get(http+IPPlayer+cmdstring+'play&N=0')
print(res)
if msg == "stream2":
res = requests.get(http+IPPlayer+cmdstring+'play&N=1')
print(res)
if msg == "stream3":
res = requests.get(http+IPPlayer+cmdstring+'play&N=2')
print(res)
i installed the socketio on the raspberry with volumio
then i have the next error
volumio@volumio:~$ python3
Python 3.4.2 (default, Sep 26 2018, 07:16:01)
[GCC 4.9.2] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
import socketio
sio = socketio.Client()
Traceback (most recent call last):
File “”, line 1, in
AttributeError: ‘module’ object has no attribute ‘Client’
import socket
import requests
import sys
import time
print(“Starting program…wait 10sec…”)
time.sleep(10)
#stream0$0A -> load playlist + play track1
#stream1$0A -> jump to track1 + play
#stream2$0A -> jump to track2 + play
#stream3$0A -> jump to track3 + play
#stopall$0A -> stop playback any track
#exitsoc$0A -> stop program