Skip to content

Commit 6d8503f

Browse files
authored
Merge pull request #105 from daroga0002/hide-token-even-in-debug
✨ hide token even in debug mode
2 parents 8492cb0 + 2a59649 commit 6d8503f

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

custom_components/tech/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,22 @@ async def async_setup(hass: HomeAssistant, config: dict): # pylint: disable=unu
3535
return True
3636

3737

38+
def sanitize_entry_data(entry_data, key):
39+
"""Return a copy of entry_data with the specified key field hidden."""
40+
sanitized_data = entry_data.copy()
41+
if key in sanitized_data:
42+
sanitized_data[key] = "***HIDDEN***"
43+
return str(sanitized_data)
44+
45+
3846
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
3947
"""Set up Tech Controllers from a config entry."""
4048
_LOGGER.debug("Setting up component's entry.")
4149
_LOGGER.debug("Entry id: %s", str(entry.entry_id))
4250
_LOGGER.debug(
4351
"Entry -> title: %s, data: %s, id: %s, domain: %s",
4452
entry.title,
45-
str(entry.data),
53+
sanitize_entry_data(entry.data, "token"),
4654
entry.entry_id,
4755
entry.domain,
4856
)

0 commit comments

Comments
 (0)