Ga naar de inhoud
Home » Tiny Tuya plugin voor Domoticz

Tiny Tuya plugin voor Domoticz

Domoticz Blog Header

Hieronder al het werk dat ik verstoud heb mbt Tiny Tuya Plugin voor Domoticz

Installeren

Tiny Tuya wordt gebruikt bij domoticz om Tuya devices aan te sturen. De laatste gereleasede versie is de mater. Installatie gaat via

cd ~/domoticz/plugins
sudo pip3 install requests==2.23.0 charset-normalizer==3.0.1 tinytuya -U
git clone https://github.com/Xenomes/Domoticz-TinyTUYA-Plugin.git

Herstart vervolgens Domoticz

sudo systemctl restart domoticz

pulsar Branch specials

*** De pulsar branch leeft voor op de Master branch. Hier wordt op ontwikkeld!!! ***

Op de pulsar branch moet je ook tyua-connector-python (https://github.com/tuya/tuya-connector-python) geinstalleerd hebben via

sudo pip3 install tuya-connector-python

Ook moet je in het Tuya Developer Platform (iot.tuya.com) ge-enabled hebben:

Inloggen -> Linkerzijde op Cloud klikken -> Selecteer the tablad Message Service en enable vervolgens de message service (neem alle ingestelde waarden, niets veranderen)

Naar de pulsar branch en terug naar Master

Wil je over naar de pulsar branch, hierin zitten de laatste aanpassingen. Doe dan

git checkout pulsar
git pull
sudo systemctl restart domoticz

Wil je de plugin nu terug zetten naar master en een update doen:

git checkout Master
git pull
sudo systemctl restart domoticz

Wil je dan weer naar de pulsar branch:

git checkout pulsar
git pull
sudo systemctl restart domoticz

pulsar Branch specials

Op de pulsar branch moet je ook tyua-connector-python (https://github.com/tuya/tuya-connector-python) geinstalleerd hebben via

sudo pip3 install tuya-connector-python

Ook moet je in het Tuya Developer Platform (iot.tuya.com) ge-enabled hebben:

Inloggen -> Linkerzijde op Cloud klikken -> Selecteer the tablad Message Service en enable vervolgens de message service (neem alle ingestelde waarden, niets veranderen)

Eigen werk via git apart zetten

Als je met iets geknutseld hebt (b.v. tools/debug_discovery.py) maar je wilt toch een git pull doen dan moet je je werk even apart zetten (stashen of stacken). Wanneer is dit nodig, bijv:

pi@domoticz:~/domoticz/plugins/Domoticz-TinyTUYA-Plugin $ git pull
remote: Enumerating objects: 19, done.
remote: Counting objects: 100% (19/19), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 13 (delta 6), reused 13 (delta 6), pack-reused 0 (from 0)
Unpacking objects: 100% (13/13), 3.62 KiB | 38.00 KiB/s, done.
From https://github.com/Xenomes/Domoticz-TinyTUYA-Plugin
f393482..e11b9c4 Master -> origin/Master
Updating f393482..e11b9c4
error: Your local changes to the following files would be overwritten by merge:
tools/debug_discovery.py
Please commit your changes or stash them before you merge.
Aborting
pi@domoticz:~/domoticz/plugins/Domoticz-TinyTUYA-Plugin $

Of bijvoorbeeld als je de git status bekijkt:

pi@domoticz:~/domoticz/plugins/Domoticz-TinyTUYA-Plugin $ git status
On branch Master
Your branch is behind 'origin/Master' by 3 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: tools/debug_discovery.py

Untracked files:
(use "git add <file>..." to include in what will be committed)
__pycache__/
tools/dump.json
tools/gmail_debug_discovery.py
tools/outlook_debug_discovery.py
tools/outlook_testscript.py

no changes added to commit (use "git add" and/or "git commit -a")
pi@domoticz:~/domoticz/plugins/Domoticz-TinyTUYA-Plugin $

Oplossing is simpel:

pi@domoticz:~/domoticz/plugins/Domoticz-TinyTUYA-Plugin $ git stash
Saved working directory and index state WIP on Master: f393482 Update error reporting 2 #188
pi@domoticz:~/domoticz/plugins/Domoticz-TinyTUYA-Plugin $ git pull
Updating f393482..e11b9c4
Fast-forward
CHANGELOG.md | 4 +++-
README.md | 11 ++++++++---
plugin.py | 15 +++++++++++----
tools/debug_discovery.py | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------
4 files changed, 145 insertions(+), 50 deletions(-)
pi@domoticz:~/domoticz/plugins/Domoticz-TinyTUYA-Plugin $ git stash pop
Auto-merging tools/debug_discovery.py
CONFLICT (content): Merge conflict in tools/debug_discovery.py
On branch Master
Your branch is up to date with 'origin/Master'.

Unmerged paths:
(use "git restore --staged <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: tools/debug_discovery.py

Untracked files:
(use "git add <file>..." to include in what will be committed)
__pycache__/
tools/dump.json
tools/gmail_debug_discovery.py
tools/outlook_debug_discovery.py
tools/outlook_testscript.py

no changes added to commit (use "git add" and/or "git commit -a")
The stash entry is kept in case you need it again.
pi@domoticz:~/domoticz/plugins/Domoticz-TinyTUYA-Plugin $

Volgens mij is er een conflict, maar echt begrijpen doe ik het niet. Of ik de git kopieer doos ooit ga begrijpen … ik weet het niet … ClearCase was toch stukken simpeler !!! Zelfs met multi-site …

Tips voor mijzelf:

  • Wat gestashed is weggooien: git stash drop
  • Als je de melding “error: Pulling is not possible because you have unmerged files.” krijgt en je hebt geen idee wat er precies gaande is, doe dan git status om te zien waar unmerged paths zijn. Maak dit schoon met git restore –staged <file>

Nieuw device doorgeven aan ontwikkelaar

Zet in het Tuya Development platform het onbekende device in DP Instructions. Dit zorgt ervoor dat het device meer over zichzelf verteld. Denk hier bij aan de waardes van statussen. De DP Instructions setting vraagt wel veel credits (volgens mij). Dus zo dadelijk wel weer terug zetten!!

Voer nu (terwijl je in de tools map staat) het volgende commando uit:

python debug_discovery.py

Mogelijk woret er gevraagd naar settings van het Tuya Development Platorm. Log hierop in, en vervolgens:

  • Cloud -> Project Management
  • Klik op Open Project
  • In het tabblad Overview staan je API gegevens.
  • In het tabblad Devices staat je DeviceID

Er komst van alles over je scherm EN er wordt een bestand aangemaakt dump.json. Stuur dit bestand naar de ontwikkelaar.

Belangrijk: Ga terug naar het Tuya Development platform en zet het onbekende device in Standard Instructions!!

Links

Code: https://github.com/Xenomes/Domoticz-TinyTUYA-Plugin/

Support: https://www.domoticz.com/forum/viewtopic.php?f=65&t=39441

Tuya Developer Platform: https://platform.tuya.com/cloud/basic?id=p1739213101222t93a77&toptab=project

Tuya device in DP instruction mode zetten: https://developer.tuya.com/en/docs/iot/change-control-instruction-mode?id=Kcbz8lahbg5st Deze ksot geloof ik heel veel credits … gebruik zo min mogelijk!!

Tuya Overview My Project: https://platform.tuya.com/cloud/basic?id=p1739213101222t93a77&toptab=project

Tuya Usage Monitor My Project: https://eu.platform.tuya.com/cloud/calculate?region=EU&id=p1739213101222t93a77