From aa7513bc5ce8b83762c3998ec4b2718763dd4d7a Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 1 Sep 2019 21:42:57 -0700 Subject: [PATCH] Expose current direction properly on state machine (#26298) * Expose current direction properly on state machine * Fix template fan --- homeassistant/components/demo/fan.py | 8 ++++---- homeassistant/components/fan/__init__.py | 2 +- homeassistant/components/template/fan.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/demo/fan.py b/homeassistant/components/demo/fan.py index cdeed5dbfec..ab8a6f3fae9 100644 --- a/homeassistant/components/demo/fan.py +++ b/homeassistant/components/demo/fan.py @@ -34,13 +34,13 @@ class DemoFan(FanEntity): self._supported_features = supported_features self._speed = STATE_OFF self.oscillating = None - self.direction = None + self._direction = None self._name = name if supported_features & SUPPORT_OSCILLATE: self.oscillating = False if supported_features & SUPPORT_DIRECTION: - self.direction = "forward" + self._direction = "forward" @property def name(self) -> str: @@ -80,7 +80,7 @@ class DemoFan(FanEntity): def set_direction(self, direction: str) -> None: """Set the direction of the fan.""" - self.direction = direction + self._direction = direction self.schedule_update_ha_state() def oscillate(self, oscillating: bool) -> None: @@ -91,7 +91,7 @@ class DemoFan(FanEntity): @property def current_direction(self) -> str: """Fan direction.""" - return self.direction + return self._direction @property def supported_features(self) -> int: diff --git a/homeassistant/components/fan/__init__.py b/homeassistant/components/fan/__init__.py index f5edfe5bb59..50d698f7336 100644 --- a/homeassistant/components/fan/__init__.py +++ b/homeassistant/components/fan/__init__.py @@ -54,7 +54,7 @@ PROP_TO_ATTR = { "speed": ATTR_SPEED, "speed_list": ATTR_SPEED_LIST, "oscillating": ATTR_OSCILLATING, - "direction": ATTR_DIRECTION, + "current_direction": ATTR_DIRECTION, } # type: dict FAN_SET_SPEED_SCHEMA = ENTITY_SERVICE_SCHEMA.extend( diff --git a/homeassistant/components/template/fan.py b/homeassistant/components/template/fan.py index c3d5a4d878f..7fd8c4d9b3c 100644 --- a/homeassistant/components/template/fan.py +++ b/homeassistant/components/template/fan.py @@ -243,7 +243,7 @@ class TemplateFan(FanEntity): return self._oscillating @property - def direction(self): + def current_direction(self): """Return the oscillation state.""" return self._direction