Expose current direction properly on state machine (#26298)

* Expose current direction properly on state machine

* Fix template fan
pull/26345/head
Paulus Schoutsen 2019-09-01 21:42:57 -07:00
parent 1ca2f1906a
commit 47e76fcd5e
3 changed files with 6 additions and 6 deletions

View File

@ -34,13 +34,13 @@ class DemoFan(FanEntity):
self._supported_features = supported_features self._supported_features = supported_features
self._speed = STATE_OFF self._speed = STATE_OFF
self.oscillating = None self.oscillating = None
self.direction = None self._direction = None
self._name = name self._name = name
if supported_features & SUPPORT_OSCILLATE: if supported_features & SUPPORT_OSCILLATE:
self.oscillating = False self.oscillating = False
if supported_features & SUPPORT_DIRECTION: if supported_features & SUPPORT_DIRECTION:
self.direction = "forward" self._direction = "forward"
@property @property
def name(self) -> str: def name(self) -> str:
@ -80,7 +80,7 @@ class DemoFan(FanEntity):
def set_direction(self, direction: str) -> None: def set_direction(self, direction: str) -> None:
"""Set the direction of the fan.""" """Set the direction of the fan."""
self.direction = direction self._direction = direction
self.schedule_update_ha_state() self.schedule_update_ha_state()
def oscillate(self, oscillating: bool) -> None: def oscillate(self, oscillating: bool) -> None:
@ -91,7 +91,7 @@ class DemoFan(FanEntity):
@property @property
def current_direction(self) -> str: def current_direction(self) -> str:
"""Fan direction.""" """Fan direction."""
return self.direction return self._direction
@property @property
def supported_features(self) -> int: def supported_features(self) -> int:

View File

@ -54,7 +54,7 @@ PROP_TO_ATTR = {
"speed": ATTR_SPEED, "speed": ATTR_SPEED,
"speed_list": ATTR_SPEED_LIST, "speed_list": ATTR_SPEED_LIST,
"oscillating": ATTR_OSCILLATING, "oscillating": ATTR_OSCILLATING,
"direction": ATTR_DIRECTION, "current_direction": ATTR_DIRECTION,
} # type: dict } # type: dict
FAN_SET_SPEED_SCHEMA = ENTITY_SERVICE_SCHEMA.extend( FAN_SET_SPEED_SCHEMA = ENTITY_SERVICE_SCHEMA.extend(

View File

@ -243,7 +243,7 @@ class TemplateFan(FanEntity):
return self._oscillating return self._oscillating
@property @property
def direction(self): def current_direction(self):
"""Return the oscillation state.""" """Return the oscillation state."""
return self._direction return self._direction