Skip to content

Commit

Permalink
Fixes state sensor for A7 (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohNan authored Aug 27, 2024
1 parent e460be9 commit dc56ed2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
17 changes: 14 additions & 3 deletions custom_components/wellbeing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,22 @@ def __init__(self, hass: HomeAssistant, entry: ConfigEntry):
def update(self, access_token: str, refresh_token: str, api_key: str | None = None):
super().update(access_token, refresh_token, api_key)
_LOGGER.debug("Tokens updated")
_LOGGER.debug(f"Api key: {api_key} : {self.api_key}")
_LOGGER.debug(f"Access token: {access_token}")
_LOGGER.debug(f"Refresh token: {refresh_token}")
_LOGGER.debug(f"Api key: {self._mask_access_token(self.api_key)}")
_LOGGER.debug(f"Access token: {self._mask_access_token(access_token)}")
_LOGGER.debug(f"Refresh token: {self._mask_access_token(refresh_token)}")

self._hass.config_entries.async_update_entry(
self._entry,
data={CONF_API_KEY: self.api_key, CONF_REFRESH_TOKEN: refresh_token, CONF_ACCESS_TOKEN: access_token},
)

@staticmethod
def _mask_access_token(token: str):
if len(token) == 1:
return "*"
elif len(token) < 4:
return token[:2] + "*" * (len(token) - 2)
elif len(token) < 10:
return token[:2] + "*****" + token[-2:]
else:
return token[:5] + "*****" + token[-5:]
7 changes: 6 additions & 1 deletion custom_components/wellbeing/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ def _create_entities(data):
attr="FilterLife_2",
unit=PERCENTAGE,
),
ApplianceSensor(name="State", attr="State", entity_category=EntityCategory.DIAGNOSTIC),
ApplianceSensor(
name="State",
attr="State",
device_class=SensorDeviceClass.ENUM,
entity_category=EntityCategory.DIAGNOSTIC
),
ApplianceBinary(
name="PM Sensor State",
attr="PMSensState",
Expand Down

0 comments on commit dc56ed2

Please sign in to comment.