Maintenance 2nd (#4106)
* Add link to docs * Fix link * Update line breaks * Update ordering * Align vera platofrm to only use add_devices (instead od add_devices_callback) * Remove line break * Use consts * Update ordering * Update ordering * Use const, create default name, use string formatting * Update ordering * Use const * Update import style * Update ordering and line breaks * update line breaks * Set default port * Set defaults and update ordering * Update ordering * Minor style updates * Update ordering, defaults, line breaks, and readability * Use constants * Add line breaks * use string formatting * Update line breaks * Update logger
This commit is contained in:
1 parent
e6ece4bf6d
commit
9f2aae1357
28 files changed
+272
-271
No files matched your search
@@ -61,9 +61,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
url = "http://{}:{}/jsonrpc".format(host, port)
|
||||
|
||||
try:
|
||||
nzbgetapi = NZBGetAPI(api_url=url,
|
||||
username=username,
|
||||
password=password)
|
||||
nzbgetapi = NZBGetAPI(
|
||||
api_url=url, username=username, password=password)
|
||||
nzbgetapi.update()
|
||||
except (requests.exceptions.ConnectionError,
|
||||
requests.exceptions.HTTPError) as conn_err:
|
||||
@@ -72,9 +71,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
devices = []
|
||||
for ng_type in monitored_types:
|
||||
new_sensor = NZBGetSensor(api=nzbgetapi,
|
||||
sensor_type=SENSOR_TYPES.get(ng_type),
|
||||
client_name=name)
|
||||
new_sensor = NZBGetSensor(
|
||||
api=nzbgetapi, sensor_type=SENSOR_TYPES.get(ng_type),
|
||||
client_name=name)
|
||||
devices.append(new_sensor)
|
||||
|
||||
add_devices(devices)
|
||||
@@ -159,11 +158,9 @@ class NZBGetAPI(object):
|
||||
if params:
|
||||
payload['params'] = params
|
||||
try:
|
||||
response = requests.post(self.api_url,
|
||||
json=payload,
|
||||
auth=self.auth,
|
||||
headers=self.headers,
|
||||
timeout=5)
|
||||
response = requests.post(
|
||||
self.api_url, json=payload, auth=self.auth,
|
||||
headers=self.headers, timeout=5)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
except requests.exceptions.ConnectionError as conn_exc:
|
||||
|
||||
Reference in new issue
Block a user