Upgrade libpurecoolink libraries without unused enum34 dependencypull/8828/head
parent
cf298c2435
commit
7f0d0607f1
|
@ -13,7 +13,7 @@ from homeassistant.helpers import discovery
|
||||||
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD, CONF_TIMEOUT, \
|
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD, CONF_TIMEOUT, \
|
||||||
CONF_DEVICES
|
CONF_DEVICES
|
||||||
|
|
||||||
REQUIREMENTS = ['libpurecoollink==0.2.0']
|
REQUIREMENTS = ['libpurecoollink==0.4.1']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -83,8 +83,8 @@ class DysonPureCoolLinkDevice(FanEntity):
|
||||||
|
|
||||||
def on_message(self, message):
|
def on_message(self, message):
|
||||||
"""Called when new messages received from the fan."""
|
"""Called when new messages received from the fan."""
|
||||||
from libpurecoollink.dyson import DysonState
|
from libpurecoollink.dyson_pure_state import DysonPureCoolState
|
||||||
if isinstance(message, DysonState):
|
if isinstance(message, DysonPureCoolState):
|
||||||
_LOGGER.debug("Message received for fan device %s : %s", self.name,
|
_LOGGER.debug("Message received for fan device %s : %s", self.name,
|
||||||
message)
|
message)
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
|
@ -6,7 +6,7 @@ https://home-assistant.io/components/sensor.dyson/
|
||||||
import logging
|
import logging
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from homeassistant.const import TEMP_CELSIUS
|
from homeassistant.const import TEMP_CELSIUS, STATE_OFF
|
||||||
from homeassistant.components.dyson import DYSON_DEVICES
|
from homeassistant.components.dyson import DYSON_DEVICES
|
||||||
|
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
@ -128,6 +128,8 @@ class DysonHumiditySensor(DysonSensor):
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return Dust value."""
|
"""Return Dust value."""
|
||||||
if self._device.environmental_state:
|
if self._device.environmental_state:
|
||||||
|
if self._device.environmental_state.humidity == 0:
|
||||||
|
return STATE_OFF
|
||||||
return self._device.environmental_state.humidity
|
return self._device.environmental_state.humidity
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -151,6 +153,8 @@ class DysonTemperatureSensor(DysonSensor):
|
||||||
"""Return Dust value."""
|
"""Return Dust value."""
|
||||||
if self._device.environmental_state:
|
if self._device.environmental_state:
|
||||||
temperature_kelvin = self._device.environmental_state.temperature
|
temperature_kelvin = self._device.environmental_state.temperature
|
||||||
|
if temperature_kelvin == 0:
|
||||||
|
return STATE_OFF
|
||||||
if self._unit == TEMP_CELSIUS:
|
if self._unit == TEMP_CELSIUS:
|
||||||
return float("{0:.1f}".format(temperature_kelvin - 273.15))
|
return float("{0:.1f}".format(temperature_kelvin - 273.15))
|
||||||
return float("{0:.1f}".format(temperature_kelvin * 9 / 5 - 459.67))
|
return float("{0:.1f}".format(temperature_kelvin * 9 / 5 - 459.67))
|
||||||
|
@ -172,7 +176,7 @@ class DysonAirQualitySensor(DysonSensor):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return Air QUality value."""
|
"""Return Air Quality value."""
|
||||||
if self._device.environmental_state:
|
if self._device.environmental_state:
|
||||||
return self._device.environmental_state.volatil_organic_compounds
|
return self._device.environmental_state.volatil_organic_compounds
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -354,7 +354,7 @@ knxip==0.5
|
||||||
libnacl==1.5.2
|
libnacl==1.5.2
|
||||||
|
|
||||||
# homeassistant.components.dyson
|
# homeassistant.components.dyson
|
||||||
libpurecoollink==0.2.0
|
libpurecoollink==0.4.1
|
||||||
|
|
||||||
# homeassistant.components.device_tracker.mikrotik
|
# homeassistant.components.device_tracker.mikrotik
|
||||||
librouteros==1.0.2
|
librouteros==1.0.2
|
||||||
|
|
|
@ -62,7 +62,7 @@ holidays==0.8.1
|
||||||
influxdb==3.0.0
|
influxdb==3.0.0
|
||||||
|
|
||||||
# homeassistant.components.dyson
|
# homeassistant.components.dyson
|
||||||
libpurecoollink==0.2.0
|
libpurecoollink==0.4.1
|
||||||
|
|
||||||
# homeassistant.components.media_player.soundtouch
|
# homeassistant.components.media_player.soundtouch
|
||||||
libsoundtouch==0.7.2
|
libsoundtouch==0.7.2
|
||||||
|
|
|
@ -6,10 +6,10 @@ from homeassistant.components.dyson import DYSON_DEVICES
|
||||||
from homeassistant.components.fan import dyson
|
from homeassistant.components.fan import dyson
|
||||||
from tests.common import get_test_home_assistant
|
from tests.common import get_test_home_assistant
|
||||||
from libpurecoollink.const import FanSpeed, FanMode, NightMode, Oscillation
|
from libpurecoollink.const import FanSpeed, FanMode, NightMode, Oscillation
|
||||||
from libpurecoollink.dyson import DysonState
|
from libpurecoollink.dyson_pure_state import DysonPureCoolState
|
||||||
|
|
||||||
|
|
||||||
class MockDysonState(DysonState):
|
class MockDysonState(DysonPureCoolState):
|
||||||
"""Mock Dyson state."""
|
"""Mock Dyson state."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
|
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT, \
|
||||||
|
STATE_OFF
|
||||||
from homeassistant.components.sensor import dyson
|
from homeassistant.components.sensor import dyson
|
||||||
from tests.common import get_test_home_assistant
|
from tests.common import get_test_home_assistant
|
||||||
|
|
||||||
|
@ -31,6 +32,21 @@ def _get_with_state():
|
||||||
return device
|
return device
|
||||||
|
|
||||||
|
|
||||||
|
def _get_with_standby_monitoring():
|
||||||
|
"""Return a valid device with state but with standby monitoring disable."""
|
||||||
|
device = mock.Mock()
|
||||||
|
device.name = "Device_name"
|
||||||
|
device.state = mock.Mock()
|
||||||
|
device.state.filter_life = 100
|
||||||
|
device.environmental_state = mock.Mock()
|
||||||
|
device.environmental_state.dust = 5
|
||||||
|
device.environmental_state.humidity = 0
|
||||||
|
device.environmental_state.temperature = 0
|
||||||
|
device.environmental_state.volatil_organic_compounds = 2
|
||||||
|
|
||||||
|
return device
|
||||||
|
|
||||||
|
|
||||||
class DysonTest(unittest.TestCase):
|
class DysonTest(unittest.TestCase):
|
||||||
"""Dyson Sensor component test class."""
|
"""Dyson Sensor component test class."""
|
||||||
|
|
||||||
|
@ -128,6 +144,17 @@ class DysonTest(unittest.TestCase):
|
||||||
self.assertEqual(sensor.name, "Device_name humidity")
|
self.assertEqual(sensor.name, "Device_name humidity")
|
||||||
self.assertEqual(sensor.entity_id, "sensor.dyson_1")
|
self.assertEqual(sensor.entity_id, "sensor.dyson_1")
|
||||||
|
|
||||||
|
def test_dyson_humidity_standby_monitoring(self):
|
||||||
|
"""Test humidity sensor while device is in standby monitoring."""
|
||||||
|
sensor = dyson.DysonHumiditySensor(self.hass,
|
||||||
|
_get_with_standby_monitoring())
|
||||||
|
sensor.entity_id = "sensor.dyson_1"
|
||||||
|
self.assertFalse(sensor.should_poll)
|
||||||
|
self.assertEqual(sensor.state, STATE_OFF)
|
||||||
|
self.assertEqual(sensor.unit_of_measurement, '%')
|
||||||
|
self.assertEqual(sensor.name, "Device_name humidity")
|
||||||
|
self.assertEqual(sensor.entity_id, "sensor.dyson_1")
|
||||||
|
|
||||||
def test_dyson_temperature_sensor(self):
|
def test_dyson_temperature_sensor(self):
|
||||||
"""Test temperature sensor with no value."""
|
"""Test temperature sensor with no value."""
|
||||||
sensor = dyson.DysonTemperatureSensor(self.hass,
|
sensor = dyson.DysonTemperatureSensor(self.hass,
|
||||||
|
@ -162,6 +189,18 @@ class DysonTest(unittest.TestCase):
|
||||||
self.assertEqual(sensor.name, "Device_name temperature")
|
self.assertEqual(sensor.name, "Device_name temperature")
|
||||||
self.assertEqual(sensor.entity_id, "sensor.dyson_1")
|
self.assertEqual(sensor.entity_id, "sensor.dyson_1")
|
||||||
|
|
||||||
|
def test_dyson_temperature_standby_monitoring(self):
|
||||||
|
"""Test temperature sensor while device is in standby monitoring."""
|
||||||
|
sensor = dyson.DysonTemperatureSensor(self.hass,
|
||||||
|
_get_with_standby_monitoring(),
|
||||||
|
TEMP_CELSIUS)
|
||||||
|
sensor.entity_id = "sensor.dyson_1"
|
||||||
|
self.assertFalse(sensor.should_poll)
|
||||||
|
self.assertEqual(sensor.state, STATE_OFF)
|
||||||
|
self.assertEqual(sensor.unit_of_measurement, '°C')
|
||||||
|
self.assertEqual(sensor.name, "Device_name temperature")
|
||||||
|
self.assertEqual(sensor.entity_id, "sensor.dyson_1")
|
||||||
|
|
||||||
def test_dyson_air_quality_sensor(self):
|
def test_dyson_air_quality_sensor(self):
|
||||||
"""Test air quality sensor with no value."""
|
"""Test air quality sensor with no value."""
|
||||||
sensor = dyson.DysonAirQualitySensor(self.hass,
|
sensor = dyson.DysonAirQualitySensor(self.hass,
|
||||||
|
|
Loading…
Reference in New Issue