Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes state sensor for A7 #141

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading