From 5ffbf55170641657810d9f724d7d38c228999ea2 Mon Sep 17 00:00:00 2001 From: etheralm <8655564+etheralm@users.noreply.github.com> Date: Sat, 11 Jan 2020 10:41:52 +0100 Subject: [PATCH] Add support for Dyson TP06 fan (#30611) * initial commit * update manifest.json * update CODEOWNERS * remove unnecessary else * add rest of asserts for TP06 state test --- CODEOWNERS | 1 + homeassistant/components/dyson/fan.py | 2 + homeassistant/components/dyson/manifest.json | 2 +- tests/components/dyson/test_fan.py | 61 ++++++++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 344adf9b8fb..38a233d4a19 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -82,6 +82,7 @@ homeassistant/components/discogs/* @thibmaek homeassistant/components/doorbird/* @oblogic7 homeassistant/components/dsmr_reader/* @depl0y homeassistant/components/dweet/* @fabaff +homeassistant/components/dyson/* @etheralm homeassistant/components/ecobee/* @marthoc homeassistant/components/ecovacs/* @OverloadUT homeassistant/components/egardia/* @jeroenterheerdt diff --git a/homeassistant/components/dyson/fan.py b/homeassistant/components/dyson/fan.py index 1fdbed0d204..2d41e6b828a 100644 --- a/homeassistant/components/dyson/fan.py +++ b/homeassistant/components/dyson/fan.py @@ -530,6 +530,8 @@ class DysonPureCoolDevice(FanEntity): @property def carbon_filter(self): """Return the carbon filter state.""" + if self._device.state.carbon_filter_state == "INV": + return self._device.state.carbon_filter_state return int(self._device.state.carbon_filter_state) @property diff --git a/homeassistant/components/dyson/manifest.json b/homeassistant/components/dyson/manifest.json index 915c6aa3b79..4fc49b4ca60 100644 --- a/homeassistant/components/dyson/manifest.json +++ b/homeassistant/components/dyson/manifest.json @@ -4,5 +4,5 @@ "documentation": "https://www.home-assistant.io/integrations/dyson", "requirements": ["libpurecool==0.6.0"], "dependencies": [], - "codeowners": [] + "codeowners": ["@etheralm"] } diff --git a/tests/components/dyson/test_fan.py b/tests/components/dyson/test_fan.py index 5f6b124a3d5..367a86eabb4 100644 --- a/tests/components/dyson/test_fan.py +++ b/tests/components/dyson/test_fan.py @@ -820,6 +820,67 @@ async def test_purecool_update_state(devices, login, hass): assert attributes[dyson.ATTR_DYSON_SPEED_LIST] == _get_supported_speeds() +@asynctest.patch("libpurecool.dyson.DysonAccount.login", return_value=True) +@asynctest.patch( + "libpurecool.dyson.DysonAccount.devices", + return_value=[_get_dyson_purecool_device()], +) +async def test_purecool_update_state_filter_inv(devices, login, hass): + """Test state TP06 carbon filter state.""" + device = devices.return_value[0] + await async_setup_component(hass, dyson.DYSON_DOMAIN, _get_config()) + await hass.async_block_till_done() + event = { + "msg": "CURRENT-STATE", + "product-state": { + "fpwr": "OFF", + "fdir": "ON", + "auto": "ON", + "oscs": "ON", + "oson": "ON", + "nmod": "ON", + "rhtm": "ON", + "fnst": "FAN", + "ercd": "11E1", + "wacd": "NONE", + "nmdv": "0004", + "fnsp": "0002", + "bril": "0002", + "corf": "ON", + "cflr": "INV", + "hflr": "0075", + "sltm": "OFF", + "osal": "0055", + "osau": "0105", + "ancp": "CUST", + }, + } + device.state = DysonPureCoolV2State(json.dumps(event)) + + for call in device.add_message_listener.call_args_list: + callback = call[0][0] + if type(callback.__self__) == dyson.DysonPureCoolDevice: + callback(device.state) + + await hass.async_block_till_done() + fan_state = hass.states.get("fan.living_room") + attributes = fan_state.attributes + + assert fan_state.state == "off" + assert attributes[dyson.ATTR_NIGHT_MODE] is True + assert attributes[dyson.ATTR_AUTO_MODE] is True + assert attributes[dyson.ATTR_ANGLE_LOW] == 55 + assert attributes[dyson.ATTR_ANGLE_HIGH] == 105 + assert attributes[dyson.ATTR_FLOW_DIRECTION_FRONT] is True + assert attributes[dyson.ATTR_TIMER] == "OFF" + assert attributes[dyson.ATTR_HEPA_FILTER] == 75 + assert attributes[dyson.ATTR_CARBON_FILTER] == "INV" + assert attributes[dyson.ATTR_DYSON_SPEED] == int(FanSpeed.FAN_SPEED_2.value) + assert attributes[ATTR_SPEED] is SPEED_LOW + assert attributes[ATTR_OSCILLATING] is False + assert attributes[dyson.ATTR_DYSON_SPEED_LIST] == _get_supported_speeds() + + @asynctest.patch("libpurecool.dyson.DysonAccount.login", return_value=True) @asynctest.patch( "libpurecool.dyson.DysonAccount.devices",