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_HIGH)
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
_LOGGER = logging.getLogger(__name__)
@ -73,19 +73,16 @@ class ISYFanDevice(isy.ISYDevice, FanEntity):
@property
def speed(self) -> str:
"""Return the current speed."""
return self.state
return VALUE_TO_STATE.get(self.value)
@property
def state(self) -> str:
"""Get the state of the ISY994 fan device."""
return VALUE_TO_STATE.get(self.value, STATE_UNKNOWN)
def is_on(self) -> str:
"""Get if the fan is on."""
return self.value != 0
def set_speed(self, speed: str) -> None:
"""Send the set speed command to the ISY994 fan device."""
if not self._node.on(val=STATE_TO_VALUE.get(speed, 0)):
_LOGGER.debug("Unable to set fan speed")
else:
self.speed = self.state
self._node.on(val=STATE_TO_VALUE.get(speed, 255))
def turn_on(self, speed: str=None, **kwargs) -> None:
"""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:
"""Send the turn off command to the ISY994 fan device."""
if not self._node.off():
_LOGGER.debug("Unable to set fan speed")
else:
self.speed = self.state
self._node.off()
@property
def speed_list(self) -> list: