sh1ntomi wrote: 
> Hi @jeroen2,
> 
> I am trying to setup volume control using JSON in Python 3.9 (with
> requests.post)  and encountering errors as below. Could you please share
> a full sample python program for JSON post ?
> 
> urllib3.exceptions.ProtocolError: ('Connection aborted.',
> RemoteDisconnected('Remote end closed connection without response'))

I haven't tried using Python for volume, but I do have one setup where
the remote (through Lirc) sends JSON to the server through a bash script
to set the volume. So in principle I would think that setting volume
through JSON should work. :-) 

Did you try using Curl on the command line to check the JSON? 

Code:
--------------------
    curl -X POST -d '"$command"' "$LMSIP":9000/jsonrpc.js"
--------------------
 (where $command is the JSON data, and $LMSip is the address of the
server)

An example of the full python code would be this:

Code:
--------------------
    #!/usr/bin/env python
  
  import requests
  
  # ----------configure players and set base values
  ServerLMS = 'http://314.local:9000/jsonrpc.js'
  PlayersOn =  ["xx:xx:xx:xx","xx:xx:xx:xx","xx:xx:xx:xx"]
  
  
  for EachPlayer in PlayersOn:
        try:
                data = '{ "id": 1, "method": "slim.request", 
"params":["'+EachPlayer+'", ["power", 1]]}'
                requests.post(ServerLMS, data=data)
        except:
  
--------------------


Where replacing ["power", 1] with something like  ["mixer", "volume",
70] should work to set the volume.

As an alternative, when your script is running on the same Pi that runs
the player, you could just use the 'command line shortcuts.'
(https://docs.picoreplayer.org/information/pcp_cli/) ("pcp up", "pcp
down") through os.system?


------------------------------------------------------------------------
jeroen2's Profile: http://forums.slimdevices.com/member.php?userid=70418
View this thread: http://forums.slimdevices.com/showthread.php?t=107209

_______________________________________________
diy mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/diy

Reply via email to