Package: tuya2domoticz
tuya2domoticzThis package is intended to be used as a standalone application (command line or daemon) for receiving
Pulsar asynchronous messages from TUYA sensor devices, and then passing those as alarm device messages to Domoticz using http requests.This is NOT a Domoticz plugin!For Domoticz, a tuya plugin is already implemented:https://github.com/Xenomes/Domoticz-TUYA-Pluginbutit just handles switches and devices that are usually online, not battery operated sensors. For me, that was not useable.
I have reflashed all my non-battery Tuya devices (wall sockets) with Tasmota, but for the actual sensors the reflashing is a painful and unguarranteed process. If reflashing is preferred, have a look at this:https://templates.blakadder.com/Y09.htmlCurrently, the only tested device is the Y09 WiFi water leakage sensor.Home Assistant can also handle tuya devices through a tuya maintained plugin (tuya-home-assistant) but, for what I can tell, it just uses a polling mechanism with a big warning about the delay in use. The Domoticz-TUYA-Plugin apparently uses the same plugin to interface with Tuya.ScreenshotsThe devices are "virtual devices" of type "alarm". I didn't find a suitable existing device to put everything in one place but this is effective (it's easy to script these to trigger some real alarm).
Some pictures related to the current setup below:Pre-requisitesPair the Tuya devices using the default SmartHome Application.Create an account and a cloud project onhttp://iot.tuya.com.Link the SmartHome app linked devices in the project (Devices -> Add Device -> Add Device with IOT Device Management App).Configure theHomeanddevicerelated service APIs.Write down the ID and KEY for that project. One device UID is also required, as the "normal" device listing fails.InstallationUsing pip:# Install tuya2domoticzpip3installtuya2domoticzSetupConfigure devices
The first run will help to configure the device. You will need to set up the ACCESS_ID, ACCESS_KEY, one of the registered devices UID (as reported from the tuya IOT project setup), Domoticz IP:PORT and then the device numbers for the Domoticz virtual devices. For each pyhisical device, there should be one a virtual alert device for the actual status, and one for the battery status. If the device battery status is not needed, it shall be set to "-2".
In the end, a "config.json" file will be created with the needed information. This file can be updated manually if needed.$python3-mtuya2domoticz-r2021-10-0420:05:07,591-tuya2domoticz-INFO-Started,usingconfigfile:config.json
Pleaseconfigurethefollowingparameters:
ACCESS_ID:zzzzzzzzzzzzzzzzzzzzzz
ACCESS_KEY:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FirstdeviceUID:05075255e098061ba2f6
Region(us,eu,cn):eu
domoticz(IP:PORT):192.168.1.41:80802021-10-0420:05:43,581-tuya2domoticz-INFO-Initializingtuyaconnector.
domoticzIDfor"Water leak sensor"(uid:05075255e098061ba2f6):38domoticzbatteryIDfor"Water leak sensor"(uid:05075255e098061ba2f6):40domoticzIDfor"Water leak sensor 2"(uid:050752558caab55ab820):39domoticzbatteryIDfor"Water leak sensor 2"(uid:050752558caab55ab820):412021-10-0420:05:50,001-tuya2domoticz-INFO-{'uid':'05075255e098061ba2f6','name':'Water leak sensor','domoticz_id':'38','domoticz_id_battery':'40'}2021-10-0420:05:50,001-tuya2domoticz-INFO-{'uid':'050752558caab55ab820','name':'Water leak sensor 2','domoticz_id':'39','domoticz_id_battery':'41'}2021-10-0420:05:50,001-tuya2domoticz-INFO-Devicesinitialized.2021-10-0420:05:50,001-tuya2domoticz-INFO-Startingpulsarlistener.Install the module as service:$python3-mtuya2domoticz-iNote, this will create a /home/$USER/tuya2domoticz folder (if not existing) and will copy the "config.json" file previously generated. Also, the tuya2domoticz.service file will be copied to /home/$USER/.config/systemd/user/. This systemctl service file can also be modified as needed (in case one needs a different working directory, for example).DeployStart the service:$systemctl--userstatustuya2domoticz
●tuya2domoticz.service-Tuya2domoticzDaemonLoaded:loaded(/home/costa/.config/systemd/user/tuya2domoticz.service;enabled;vendorpreset:enabled)Active:active(running)sinceMon2021-10-0420:14:04EEST;2sagoMainPID:90404(python3)CGroup:/user.slice/user-1000.slice/user@1000.service/app.slice/tuya2domoticz.service└─90404/usr/bin/python3-mtuya2domoticz-c/home/costa/tuya2domoticz/config.json

oct0420:14:04tufsystemd[999]:StartedTuya2domoticzDaemon.
oct0420:14:04tufpython3[90404]:2021-10-0420:14:04,826-tuya2domoticz-INFO-Started,usingconfigfile:/home/costa/tuya2domoticz/config.json
oct0420:14:04tufpython3[90404]:2021-10-0420:14:04,826-tuya2domoticz-INFO-Configloaded.
oct0420:14:04tufpython3[90404]:2021-10-0420:14:04,826-tuya2domoticz-INFO-Initializingtuyaconnector.
oct0420:14:05tufpython3[90404]:2021-10-0420:14:05,009-tuya2domoticz-INFO-{'uid':'05075255e098061ba2f6','name':'Water leak sensor','domoticz_id':'38','domoticz_id_battery':'40'}oct0420:14:05tufpython3[90404]:2021-10-0420:14:05,009-tuya2domoticz-INFO-{'uid':'050752558caab55ab820','name':'Water leak sensor 2','domoticz_id':'39','domoticz_id_battery':'41'}oct0420:14:05tufpython3[90404]:2021-10-0420:14:05,009-tuya2domoticz-INFO-Devicesinitialized.
oct0420:14:05tufpython3[90404]:2021-10-0420:14:05,010-tuya2domoticz-INFO-Startingpulsarlistener.