Skip to content

Commit

Permalink
🔁 improve for reverse_state (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
al-one committed Jan 6, 2022
1 parent 8c8ce09 commit 844f85a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions custom_components/xiaomi_miot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2086,8 +2086,13 @@ def set_parent_property(self, val, prop=None):
class ToggleSubEntity(BaseSubEntity, ToggleEntity):
def __init__(self, parent, attr='power', option=None):
self._prop_power = None
self._reverse_state = None
super().__init__(parent, attr, option)

async def async_added_to_hass(self):
await super().async_added_to_hass()
self._reverse_state = self.custom_config_bool('reverse_state', None)

def update(self, data=None):
super().update(data)
if self._available:
Expand All @@ -2100,6 +2105,8 @@ def state(self):

@property
def is_on(self):
if self._reverse_state:
return not self._state
return self._state

def turn_on(self, **kwargs):
Expand Down

0 comments on commit 844f85a

Please sign in to comment.