This links Tuya devices to MQTT using the following:
- Devices are accessed using tinytuya package.
- Device details are published using the Homie convention on MQTT
- Home Assistant configurations are also published so one should be able to integrate this with Home Assistant too.
- Clone this project.
cd tuya_mqtt
- Setup the python3 environment using by running
python3 -m venv .venv
- Activate the environment by running
source .venv/bin/activate
. - Install requirements with
pip install -r requirements.txt
. This would also installtinytuya
needed for the following steps. - Follow the instructions for
tinytuya
here.
- Note
tinytuya
is already installed above so no need to install it. - Start under the heading "Setup Wizard - Getting Local Keys"
- Setup the Tuya app.
- Setup a Tuya account.
- Also try and activate the full DP settings per these instructions.
- Run the wizard tool (try and run it at least 24h after your devices was connected to the Tuya account/cloud).
- Note the properites here is discovered via the cloud, so run the wizard tool at least 24h after your device was connected to the Tuya cloud.
- Copy
config_sample.py
toconfig.py
and edit appropriately. - You can then run the server by running
./server.py
. - The service can also be activated copying the service file
tuya_mqtt.service
to an appropriate location and editing the file to match your setup.
Some things to note:
- Please make sure to set the instruction set to the full set per these instructions.
- Note that you may need to rerun the wizard tool using
python -m tinytuya wizard
a day our two after first adding your device to ensure the full device details are populated.