Add unique_id to One-Time Password (OTP) (#120050)
This commit is contained in:
parent
53d3475b1d
commit
4515eedea9
1 changed files with 4 additions and 2 deletions
|
@ -60,7 +60,8 @@ async def async_setup_entry(
|
|||
"""Set up the OTP sensor."""
|
||||
|
||||
async_add_entities(
|
||||
[TOTPSensor(entry.data[CONF_NAME], entry.data[CONF_TOKEN])], True
|
||||
[TOTPSensor(entry.data[CONF_NAME], entry.data[CONF_TOKEN], entry.entry_id)],
|
||||
True,
|
||||
)
|
||||
|
||||
|
||||
|
@ -73,9 +74,10 @@ class TOTPSensor(SensorEntity):
|
|||
_attr_native_value: StateType = None
|
||||
_next_expiration: float | None = None
|
||||
|
||||
def __init__(self, name: str, token: str) -> None:
|
||||
def __init__(self, name: str, token: str, entry_id: str) -> None:
|
||||
"""Initialize the sensor."""
|
||||
self._attr_name = name
|
||||
self._attr_unique_id = entry_id
|
||||
self._otp = pyotp.TOTP(token)
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
|
|
Loading…
Add table
Reference in a new issue