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
This commit is contained in:
etheralm 2020-01-11 10:41:52 +01:00 committed by springstan
parent b128814acf
commit 5ffbf55170
4 changed files with 65 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -4,5 +4,5 @@
"documentation": "https://www.home-assistant.io/integrations/dyson",
"requirements": ["libpurecool==0.6.0"],
"dependencies": [],
"codeowners": []
"codeowners": ["@etheralm"]
}

View File

@ -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",