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'))
Results 11 to 12 of 12
-
2022-02-14, 04:19 #11
- Join Date
- Aug 2020
- Posts
- 22
-
2022-02-17, 16:15 #12
- Join Date
- Jul 2020
- Posts
- 312
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"
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:
As an alternative, when your script is running on the same Pi that runs the player, you could just use the command line shortcuts. ("pcp up", "pcp down") through os.system?