From 14190bd497609a09e8e7134ab941a5a11e122335 Mon Sep 17 00:00:00 2001 From: Andi Date: Wed, 6 May 2020 02:35:02 +0200 Subject: [PATCH] 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 --- homeassistant/components/pyload/sensor.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/pyload/sensor.py b/homeassistant/components/pyload/sensor.py index abcf1193ce4..6539479d2cd 100644 --- a/homeassistant/components/pyload/sensor.py +++ b/homeassistant/components/pyload/sensor.py @@ -60,7 +60,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None): try: pyloadapi = PyLoadAPI(api_url=url, username=username, password=password) - pyloadapi.update() except ( requests.exceptions.ConnectionError, requests.exceptions.HTTPError, @@ -144,17 +143,11 @@ class PyLoadAPI: self.login = requests.post(f"{api_url}login", data=self.payload, timeout=5) self.update() - def post(self, method, params=None): + def post(self): """Send a POST request and return the response as a dict.""" - payload = {"method": method} - - if params: - payload["params"] = params - try: response = requests.post( f"{self.api_url}statusServer", - json=payload, cookies=self.login.cookies, headers=self.headers, timeout=5, @@ -170,4 +163,4 @@ class PyLoadAPI: @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): """Update cached response.""" - self.status = self.post("speed") + self.status = self.post()