Python script and Pyscript module for Home Assistant to resync local keys from the private Tuya API (works for Ledvance and Sylvania devices).
- Print out local keys for your Ledvance (or Sylvania) devices, which can be used with the LocalTuya integration for Home Assistant
- Automatic resync of local keys via Pyscript Integration
- Python 3.12 or newer (3.12 confirmed as working)
- Dependencies listed in
pyproject.toml(install with pip, see below)
-
Create a Python 3 environment
-
Install dependencies:
uv sync
-
Run the script:
uv run main.py
You will be prompted for your Ledvance/Tuya username and password.
- To run non-interactively, set the environment variables
LEDVANCE_USERNAMEandLEDVANCE_PASSWORDto your account credentials.
- To run non-interactively, set the environment variables
- See the Pyscript Integration documentation for setup.
- This also works for Sylvania devices by changing/uncommenting the keys in
pyscript_modules/tuya/const.py.
MIT License. See LICENSE for details.
Credits to FlagX for the initial script.