mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Fix pyload API statusServer doesn't take parameters (#35242)
* pyload API statusServer doesn't take parameters Remove json payload from API call to statusServer for retrieving current download speed. See maintainers message in: pyload/pyload#3622 (comment) Skip duplicated call to update function. * Lint sensor.py remove empty line
This commit is contained in:
parent
740d9c575e
commit
14190bd497
@ -60,7 +60,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
pyloadapi = PyLoadAPI(api_url=url, username=username, password=password)
|
pyloadapi = PyLoadAPI(api_url=url, username=username, password=password)
|
||||||
pyloadapi.update()
|
|
||||||
except (
|
except (
|
||||||
requests.exceptions.ConnectionError,
|
requests.exceptions.ConnectionError,
|
||||||
requests.exceptions.HTTPError,
|
requests.exceptions.HTTPError,
|
||||||
@ -144,17 +143,11 @@ class PyLoadAPI:
|
|||||||
self.login = requests.post(f"{api_url}login", data=self.payload, timeout=5)
|
self.login = requests.post(f"{api_url}login", data=self.payload, timeout=5)
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def post(self, method, params=None):
|
def post(self):
|
||||||
"""Send a POST request and return the response as a dict."""
|
"""Send a POST request and return the response as a dict."""
|
||||||
payload = {"method": method}
|
|
||||||
|
|
||||||
if params:
|
|
||||||
payload["params"] = params
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
f"{self.api_url}statusServer",
|
f"{self.api_url}statusServer",
|
||||||
json=payload,
|
|
||||||
cookies=self.login.cookies,
|
cookies=self.login.cookies,
|
||||||
headers=self.headers,
|
headers=self.headers,
|
||||||
timeout=5,
|
timeout=5,
|
||||||
@ -170,4 +163,4 @@ class PyLoadAPI:
|
|||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update cached response."""
|
"""Update cached response."""
|
||||||
self.status = self.post("speed")
|
self.status = self.post()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user