Skip to content

Commit

Permalink
Bump python-synology to 0.4.0 : Add support for DSM v5 + fix sensors …
Browse files Browse the repository at this point in the history
…unknown for 15 min (#31049)

* updating new api version

* Added new configuration option for updated API
  • Loading branch information
aaska authored and Quentame committed Jan 27, 2020
1 parent 1dbfc66 commit 1f7ab90
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/synologydsm/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "synologydsm",
"name": "SynologyDSM",
"documentation": "https://www.home-assistant.io/integrations/synologydsm",
"requirements": ["python-synology==0.3.0"],
"requirements": ["python-synology==0.4.0"],
"dependencies": [],
"codeowners": []
}
17 changes: 14 additions & 3 deletions homeassistant/components/synologydsm/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (
ATTR_ATTRIBUTION,
CONF_API_VERSION,
CONF_DISKS,
CONF_HOST,
CONF_MONITORED_CONDITIONS,
Expand Down Expand Up @@ -82,6 +83,7 @@
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
vol.Optional(CONF_SSL, default=True): cv.boolean,
vol.Optional(CONF_API_VERSION): cv.positive_int,
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Optional(CONF_MONITORED_CONDITIONS): vol.All(
Expand Down Expand Up @@ -110,8 +112,9 @@ def run_setup(event):
use_ssl = config.get(CONF_SSL)
unit = hass.config.units.temperature_unit
monitored_conditions = config.get(CONF_MONITORED_CONDITIONS)
api_version = config.get(CONF_API_VERSION)

api = SynoApi(host, port, username, password, unit, use_ssl)
api = SynoApi(host, port, username, password, unit, use_ssl, api_version)

sensors = [
SynoNasUtilSensor(api, name, variable, _UTILISATION_MON_COND[variable])
Expand Down Expand Up @@ -150,13 +153,21 @@ def run_setup(event):
class SynoApi:
"""Class to interface with Synology DSM API."""

def __init__(self, host, port, username, password, temp_unit, use_ssl):
def __init__(self, host, port, username, password, temp_unit, use_ssl, api_version):
"""Initialize the API wrapper class."""

self.temp_unit = temp_unit

try:
self._api = SynologyDSM(host, port, username, password, use_https=use_ssl)
self._api = SynologyDSM(
host,
port,
username,
password,
use_https=use_ssl,
debugmode=False,
dsm_version=api_version,
)
except: # noqa: E722 pylint: disable=bare-except
_LOGGER.error("Error setting up Synology DSM")

Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ python-sochain-api==0.0.2
python-songpal==0.11.2

# homeassistant.components.synologydsm
python-synology==0.3.0
python-synology==0.4.0

# homeassistant.components.tado
python-tado==0.2.9
Expand Down

0 comments on commit 1f7ab90

Please sign in to comment.