One-Time Password (OTP)
The otp
integrationIntegrations connect and integrate Home Assistant with your devices, services, and more.
[Learn more] generates One-Time Passwords according to RFC6238 that is compatible with most OTP generators available, including Google Authenticator. You can use this when building custom security solutions and want to use “rolling codes”, that change every 30 seconds.
Configuration
To enable the OTP integrationIntegrations connect and integrate Home Assistant with your devices, services, and more.
[Learn more], add the following lines to your configuration.yaml
The configuration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases, the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI.[Learn more] file.
After changing the configuration.yaml
The configuration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases, the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI.[Learn more] file, restart Home Assistant to apply the changes.
# Example configuration.yaml entry
sensor:
- platform: otp
token: SHARED_SECRET_TOKEN
Generating a token
A simple way to generate a token
for a new sensor is to run this snippet of Python code in your Home Assistant virtual environment:
$ pip3 install pyotp
$ python3 -c 'import pyotp; print("Token:", pyotp.random_base32())'
Token: IHEDPEBEVA2WVHB7
To run in a Docker container:
$ docker exec -it home-assistant python -c 'import pyotp; print("Token:", pyotp.random_base32())'
Token: IHEDPEBEVA2WVHB7
Copy and paste the token into your Home Assistant configuration and add it to your OTP generator. Verify that they generate the same code.