Skip to content

Commit

Permalink
Update: Support for Home Assistant 0.110.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JurajNyiri committed May 21, 2020
1 parent 46e1c10 commit 232f4e5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
28 changes: 20 additions & 8 deletions custom_components/qbittorrent_alternative_speed/switch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
__version__ = "1.3"
__version__ = "1.3.1"

import logging
import voluptuous as vol

from qbittorrentapi import Client

from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA)
from homeassistant.const import (CONF_PROTOCOL,CONF_NAME,CONF_PORT, CONF_HOST,CONF_USERNAME,CONF_PASSWORD)
try:
from homeassistant.components.switch import (
SwitchEntity, PLATFORM_SCHEMA)
except ImportError:
from homeassistant.components.switch import (
SwitchDevice as SwitchEntity, PLATFORM_SCHEMA)


from homeassistant.const import (
CONF_PROTOCOL, CONF_NAME, CONF_PORT, CONF_HOST, CONF_USERNAME, CONF_PASSWORD)
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)
Expand All @@ -20,23 +28,27 @@
vol.Optional(CONF_NAME, default="qbittorrent_alternative_speed"): cv.string
})


def setup_platform(hass, config, add_devices, discovery_info=None):
host = config.get(CONF_PROTOCOL)+"://"+config.get(CONF_HOST)+":"+config.get(CONF_PORT)
host = config.get(CONF_PROTOCOL)+"://" + \
config.get(CONF_HOST)+":"+config.get(CONF_PORT)
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
name = config.get(CONF_NAME)

add_devices([qbittorrent_alternative_speed(host, username, password, name)], True)
add_devices([qbittorrent_alternative_speed(
host, username, password, name)], True)


class qbittorrent_alternative_speed(SwitchDevice):
class qbittorrent_alternative_speed(SwitchEntity):

def __init__(self, host, username, password, name):
self.host = host
self.username = username
self.password = password
self._name = name
self.qb = Client(host=self.host, username=self.username, password=self.password)
self.qb = Client(host=self.host, username=self.username,
password=self.password)
self.signin()

def signin(self):
Expand Down Expand Up @@ -66,4 +78,4 @@ def turn_on(self):
def turn_off(self):
self.update()
if(self._state == 1):
self.qb.transfer.toggle_speed_limits_mode()
self.qb.transfer.toggle_speed_limits_mode()
16 changes: 8 additions & 8 deletions custom_updater.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"switch.qbittorrent_alternative_speed": {
"updated_at": "2019-12-12",
"local_location": "/custom_components/qbittorrent_alternative_speed/switch.py",
"version": "1.3",
"changelog": "https://github.com/JurajNyiri/HomeAssistant-qBitTorrentAlternativeSpeed/commits/master",
"visit_repo": "https://github.com/JurajNyiri/HomeAssistant-qBitTorrentAlternativeSpeed/",
"remote_location": "https://raw.githubusercontent.com/JurajNyiri/HomeAssistant-qBitTorrentAlternativeSpeed/master/custom_components/qbittorrent_alternative_speed/switch.py"
}
"switch.qbittorrent_alternative_speed": {
"updated_at": "2020-05-21",
"local_location": "/custom_components/qbittorrent_alternative_speed/switch.py",
"version": "1.3.1",
"changelog": "https://github.com/JurajNyiri/HomeAssistant-qBitTorrentAlternativeSpeed/commits/master",
"visit_repo": "https://github.com/JurajNyiri/HomeAssistant-qBitTorrentAlternativeSpeed/",
"remote_location": "https://raw.githubusercontent.com/JurajNyiri/HomeAssistant-qBitTorrentAlternativeSpeed/master/custom_components/qbittorrent_alternative_speed/switch.py"
}
}

0 comments on commit 232f4e5

Please sign in to comment.