From fceba0bb8834e8a1308eee8abcbc1210d2871be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=BCndler?= Date: Fri, 14 Aug 2020 03:48:26 +0200 Subject: [PATCH] Bump pysyncthru to 0.7.0 (#38832) * Bump pysyncthru version to 0.7.0 This change includes a heavier refactoring, using a more reliable source for the device status and parsing display strings only for additional details * Fix test flow to ensure a status is set --- homeassistant/components/syncthru/manifest.json | 2 +- homeassistant/components/syncthru/sensor.py | 7 ++++--- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/syncthru/test_config_flow.py | 1 + 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/syncthru/manifest.json b/homeassistant/components/syncthru/manifest.json index bf62738a02e..f70afa5a695 100644 --- a/homeassistant/components/syncthru/manifest.json +++ b/homeassistant/components/syncthru/manifest.json @@ -3,7 +3,7 @@ "name": "Samsung SyncThru Printer", "documentation": "https://www.home-assistant.io/integrations/syncthru", "config_flow": true, - "requirements": ["pysyncthru==0.5.0", "url-normalize==1.4.1"], + "requirements": ["pysyncthru==0.7.0", "url-normalize==1.4.1"], "ssdp": [ { "deviceType": "urn:schemas-upnp-org:device:Printer:1", diff --git a/homeassistant/components/syncthru/sensor.py b/homeassistant/components/syncthru/sensor.py index 6f7f248a924..c9aa6d8de9c 100644 --- a/homeassistant/components/syncthru/sensor.py +++ b/homeassistant/components/syncthru/sensor.py @@ -2,7 +2,7 @@ import logging -from pysyncthru import SyncThru +from pysyncthru import SYNCTHRU_STATE_HUMAN, SyncThru import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA @@ -101,7 +101,7 @@ class SyncThruSensor(Entity): def __init__(self, syncthru, name): """Initialize the sensor.""" - self.syncthru = syncthru + self.syncthru: SyncThru = syncthru self._attributes = {} self._state = None self._name = name @@ -164,7 +164,8 @@ class SyncThruMainSensor(SyncThruSensor): self.syncthru.url, ) self._active = False - self._state = self.syncthru.device_status() + self._state = SYNCTHRU_STATE_HUMAN[self.syncthru.device_status()] + self._attributes = {"display_text": self.syncthru.device_status_details()} class SyncThruTonerSensor(SyncThruSensor): diff --git a/requirements_all.txt b/requirements_all.txt index 66971ebbe57..1498e37fd09 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1668,7 +1668,7 @@ pysuez==0.1.17 pysupla==0.0.3 # homeassistant.components.syncthru -pysyncthru==0.5.0 +pysyncthru==0.7.0 # homeassistant.components.tankerkoenig pytankerkoenig==0.0.6 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 393a99e5e1a..18878a13833 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -782,7 +782,7 @@ pyspcwebgw==0.4.0 pysqueezebox==0.2.4 # homeassistant.components.syncthru -pysyncthru==0.5.0 +pysyncthru==0.7.0 # homeassistant.components.ecobee python-ecobee-api==0.2.7 diff --git a/tests/components/syncthru/test_config_flow.py b/tests/components/syncthru/test_config_flow.py index aac1923caab..8eb72ee264a 100644 --- a/tests/components/syncthru/test_config_flow.py +++ b/tests/components/syncthru/test_config_flow.py @@ -24,6 +24,7 @@ def mock_connection(aioclient_mock): text=""" { \tstatus: { +\thrDeviceStatus: 2, \tstatus1: " Sleeping... " \t}, \tidentity: {