Fix ISY994 fan platform overwriting state property (#9817)

* ISY994 platform overwrote state

* Update isy994.py

* Update isy994.py
This commit is contained in:
Paulus Schoutsen 2017-10-12 00:36:24 -07:00 committed by GitHub
parent 765560e87a
commit c33b179fb8

View File

@ -11,7 +11,7 @@ from homeassistant.components.fan import (FanEntity, DOMAIN, SPEED_OFF,
SPEED_LOW, SPEED_MEDIUM, SPEED_LOW, SPEED_MEDIUM,
SPEED_HIGH) SPEED_HIGH)
import homeassistant.components.isy994 as isy import homeassistant.components.isy994 as isy
from homeassistant.const import STATE_UNKNOWN, STATE_ON, STATE_OFF from homeassistant.const import STATE_ON, STATE_OFF
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -73,19 +73,16 @@ class ISYFanDevice(isy.ISYDevice, FanEntity):
@property @property
def speed(self) -> str: def speed(self) -> str:
"""Return the current speed.""" """Return the current speed."""
return self.state return VALUE_TO_STATE.get(self.value)
@property @property
def state(self) -> str: def is_on(self) -> str:
"""Get the state of the ISY994 fan device.""" """Get if the fan is on."""
return VALUE_TO_STATE.get(self.value, STATE_UNKNOWN) return self.value != 0
def set_speed(self, speed: str) -> None: def set_speed(self, speed: str) -> None:
"""Send the set speed command to the ISY994 fan device.""" """Send the set speed command to the ISY994 fan device."""
if not self._node.on(val=STATE_TO_VALUE.get(speed, 0)): self._node.on(val=STATE_TO_VALUE.get(speed, 255))
_LOGGER.debug("Unable to set fan speed")
else:
self.speed = self.state
def turn_on(self, speed: str=None, **kwargs) -> None: def turn_on(self, speed: str=None, **kwargs) -> None:
"""Send the turn on command to the ISY994 fan device.""" """Send the turn on command to the ISY994 fan device."""
@ -93,10 +90,7 @@ class ISYFanDevice(isy.ISYDevice, FanEntity):
def turn_off(self, **kwargs) -> None: def turn_off(self, **kwargs) -> None:
"""Send the turn off command to the ISY994 fan device.""" """Send the turn off command to the ISY994 fan device."""
if not self._node.off(): self._node.off()
_LOGGER.debug("Unable to set fan speed")
else:
self.speed = self.state
@property @property
def speed_list(self) -> list: def speed_list(self) -> list: