From 4229ce392e3251ed31d778e5b436bcd8435f7cb0 Mon Sep 17 00:00:00 2001 From: Ben Vezzani Date: Fri, 5 May 2023 11:58:00 -0400 Subject: [PATCH] Allow 'off' value for sensors from mqtt (#14) * Allow 'off' value for sensors from mqtt * Fixing tests for new unit scales --- libdyson/dyson_device.py | 2 +- setup.cfg | 2 +- tests/test_pure_cool_formaldehyde.py | 4 ++-- tests/test_pure_cool_missing_env_data.py | 8 ++++---- tests/test_purifier_humidify_cool_formaldehyde.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libdyson/dyson_device.py b/libdyson/dyson_device.py index 6594954..0760383 100644 --- a/libdyson/dyson_device.py +++ b/libdyson/dyson_device.py @@ -294,7 +294,7 @@ def _get_field_value(state: Dict[str, Any], field: str): def _get_environmental_field_value(self, field, divisor=1) -> Optional[Union[int, float]]: value = self._get_field_value(self._environmental_data, field) - if value == "OFF": + if value == "OFF" or value == "off": return ENVIRONMENTAL_OFF if value == "INIT": return ENVIRONMENTAL_INIT diff --git a/setup.cfg b/setup.cfg index 37a59eb..0a54844 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = libdyson-neon -version = 1.0.1 +version = 1.0.2 author = The libdyson Working Group author_email = dotvezz@gmail.com license = MIT License diff --git a/tests/test_pure_cool_formaldehyde.py b/tests/test_pure_cool_formaldehyde.py index abdcd55..7947784 100644 --- a/tests/test_pure_cool_formaldehyde.py +++ b/tests/test_pure_cool_formaldehyde.py @@ -64,6 +64,6 @@ def test_properties(mqtt_client: MockedMQTT): device.request_environmental_data() assert device.particulate_matter_2_5 == 9 assert device.particulate_matter_10 == 5 - assert device.volatile_organic_compounds == 4 - assert device.nitrogen_dioxide == 11 + assert device.volatile_organic_compounds == 0.4 + assert device.nitrogen_dioxide == 1.1 assert device.formaldehyde == 1 diff --git a/tests/test_pure_cool_missing_env_data.py b/tests/test_pure_cool_missing_env_data.py index 3e24000..f510c30 100644 --- a/tests/test_pure_cool_missing_env_data.py +++ b/tests/test_pure_cool_missing_env_data.py @@ -64,8 +64,8 @@ def test_no_hcho(mqtt_client: MockedMQTT): device.request_environmental_data() assert device.particulate_matter_2_5 == 9 assert device.particulate_matter_10 == 5 - assert device.volatile_organic_compounds == 4 - assert device.nitrogen_dioxide == 11 + assert device.volatile_organic_compounds == .4 + assert device.nitrogen_dioxide == 1.1 assert device.formaldehyde is None @@ -98,6 +98,6 @@ def test_missing_data(mqtt_client: MockedMQTT): device.request_environmental_data() assert device.particulate_matter_2_5 == 9 assert device.particulate_matter_10 == 5 - assert device.volatile_organic_compounds == 4 - assert device.nitrogen_dioxide == 11 + assert device.volatile_organic_compounds == .4 + assert device.nitrogen_dioxide == 1.1 assert device.formaldehyde is None diff --git a/tests/test_purifier_humidify_cool_formaldehyde.py b/tests/test_purifier_humidify_cool_formaldehyde.py index 9dbe30f..bb46dec 100644 --- a/tests/test_purifier_humidify_cool_formaldehyde.py +++ b/tests/test_purifier_humidify_cool_formaldehyde.py @@ -64,6 +64,6 @@ def test_properties(mqtt_client: MockedMQTT): device.request_environmental_data() assert device.particulate_matter_2_5 == 9 assert device.particulate_matter_10 == 5 - assert device.volatile_organic_compounds == 4 - assert device.nitrogen_dioxide == 11 + assert device.volatile_organic_compounds == .4 + assert device.nitrogen_dioxide == 1.1 assert device.formaldehyde == 1