Une autre solution pour intégrer des objets Tuya dans Domoticz.
A force de recherche je suis tombé sur une nouvelle méthode pour récupérer les fameuses Local Key sur cette page Tuyapi Repo et la page officiel sur le Tuya. Malheureusement malgré plusieurs essais, je n'ai pas réussi à intégrer de manière fonctionnelle mes prises dans Domoticz. J'ai fini par trouver une autre solution. Cela existe peut être déjà mais ici c'est ma solution.
- Créez un compte sur ce site iot.tuya.com.
- Enregistrez vos prises dans l'application via votre téléphone (Android or IOS).
- Une fois le compte validé, cliquez sur "Cloud Development" dans la barre en haut puis cliquez sur "Create". Après avoir créé l'application cliquez dessus pour obtenir vos clés.
- A partir d'ici ma solution diffère un peu. Dans le menu de gauche cliquez sur "Linked Devices". Sélectionnez l'onglet "Link devices by App Account". Sur votre téléphone allez dans "Profil" cliquez sur l’icône "Scan". Dans la page web cliquez sur "Add App Account" and scannez le QR code. Votre compte est maintenant lié "Tuya Cloud".
Dans le dossier du script vous trouverez code.json.model
. Renommez le en code.json
et complétez le avec les informations Client ID et Client Secret.
{ "devices":{ "prise_a":"", "prise_b":"" }, "client_id":"", "app_id":"" }
La liste des devices est totalement optionnelle pour le moment. Je l'ai ajouté afin de garder en mémoire les ids des prises. Ces derniers se trouvent dans l'application dans les informatins du Device à la ligne ID Virtuel.
Ce script envoi des requêtes au Cloud Tuya pour envoyer des commandes aux prises.
Options available main.py --switch <ID> <True|False> main.py --status <ID> main.py --toggle <ID>
Dans votre dossier de scripts Domoticz clonez le repo.
git clone https://github.com/BreizhCat/domoticz-tuya.git
Ajoutez le mode éxecutable au fichier main.py.
chmod a+x main.py
Dans Domoticz créez un dummy device et sur les actions On & Off appeller le script avec l'option switch True or False.
Another way to integrate your switch Tuya to Domoticz
I have discover this method on Tuyapi Repo and also information from official Tuya website. Unfortunatly this tutorial did not work well for me and even if I was able to add the devices on my Domoticz server I was not able use them. After digging a bit I have found few clues and I work on my own solution. Perhaps it exists already something like mine.
- This method requires you to create a developer account on iot.tuya.com.
- Register the devices within the Tuya App (Android or IOS).
- After you've created a new account, click "Cloud Development" in the top nav bar and click "Create". After you've created a new application, click into it. The access ID and access key are equivalent to the API key and API secret values need.)
- From there the solution is a bit different. On the left pan you can see a menu. Click on "Linked Devices". On the new page, click on tab "Link devices by App Account". Grab your phone and go to "Profil" select the "Scan" icon on the top rigth. On the web page click on "Add App Account" and scan the QR code. Your account is now linked to the "Tuya Cloud"
In the folder you will find a file code.json.model
. You have to rename it in code.json
and add your application id and your client id.
{ "devices":{ "prise_a":"", "prise_b":"" }, "client_id":"", "app_id":"" }
Devices is an option added just for memory at this moment. Because to call the script you will need to use these values to toggle the correct switch. These ids are available within the application in Information > Virtual ID. You have to do it on each device.
This python script send request in Tuya Cloud and allow you to switch the device and also to get status of the device.
The python script is just a wrapper and allow you to send the request.
Options available main.py --switch <ID> <True|False> main.py --status <ID> main.py --toggle <ID>
Go to script folder of your installation and clone the repo.
git clone https://github.com/BreizhCat/domoticz-tuya.git
Change authorization
chmod a+x main.py
Update the configuration file as expected (cf. Configure Application above).
In Domoticz, create dummy switch and add the action on and off on it.