Skip to content

Commit

Permalink
Fix unavailable status
Browse files Browse the repository at this point in the history
- Fix unavailable status mainteined in some circustance
- Added "assumed_state" attribute
  • Loading branch information
ollo69 committed Jul 1, 2020
1 parent 17824bb commit fa8722f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions custom_components/smartthinq_sensors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ def __init__(self, device, name):
def available(self) -> bool:
return self._not_logged_count <= MAX_UPDATE_FAIL_ALLOWED

@property
def assumed_state(self) -> bool:
"""Return True if unable to access real state of the entity."""
return self.available and self._disconnected

@property
def name(self) -> str:
return self._name
Expand Down Expand Up @@ -434,6 +439,7 @@ def device_update(self):
# _LOGGER.debug('Status attributes: %s', l)

self._update_fail_count = 0
self._not_logged_count = 0
self._retry_count = 0
self._state = state

Expand Down
5 changes: 5 additions & 0 deletions custom_components/smartthinq_sensors/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ def available(self) -> bool:
"""Return True if entity is available."""
return self._api.available

@property
def assumed_state(self) -> bool:
"""Return True if unable to access real state of the entity."""
return self._api.assumed_state

@property
def state_attributes(self):
"""Return the optional state attributes."""
Expand Down

0 comments on commit fa8722f

Please sign in to comment.