Xenomes / Domoticz-TUYA-Plugin

Implements the special Tuya Home Assistant API.
22 stars 8 forks source link

Climate Heater #3

Closed Xenomes closed 1 year ago

Xenomes commented 3 years ago

Hi @Xenomes

https://www.domoticz.com/forum/viewtopic.php?p=119582#p119582

Thank you for working on this plugin.

I have recently acquired an Inkbird ITC-308-WIFI temperature controller. It reports temperature and allows the switching of heating and cooling based on a set point. I am using it for a Marine Fish Tank.

Below is a dump from your debug_discovery. The TUYA app allows me to set the units switchpoints and various settings but also reports the temp.

Getting devices Got devices { 'header': {'code': 'SUCCESS', 'payloadVersion': 1}, 'payload': { 'devices': [ { 'data': { 'current_temperature': 232, 'max_temper': 2120, 'min_temper': -400, 'online': True, 'state': 'false', 'temperature': 240}, 'dev_type': 'climate', 'ha_type': 'climate', 'icon': 'https://images.tuyaeu.com/smart/icon/15 ... 2c7z_0.png', 'id': '428061235002916fca85', 'name': 'Marine Tank Thermostat'}], 'scenes': []}}

From what I can tell based on the setup of the unit the returned values are as per below. Temps are <value/10> so 232 is 23.2C.

'current_temperature': 232 = Current Temp 'max_temper': 2120, = Max Temp for Alarm 'min_temper': -400, = Min Temp for Alarm 'online': True, = Is the unit online 'state': 'false', = No idea, does not appear to change even if the unit goes into heating or cooling mode. 'temperature': 240 = Set point for the temp

Is it possible that you could look at integrating this device to report at minimum the reported temp and allow setting the set point? There are many things it does via the TUYA app like flag alarms over the max and min alarm set points but I am not sure how I can sniff this data.

Cheers CV8R.

Xenomes commented 3 years ago

@CV8R

Can you test this modification of the script? I have no way to test it so it is really experiential. https://github.com/Xenomes/Domoticz-TUYA-Plugin/tree/Climate_Test

CV8R commented 3 years ago

Hi @Xenomes

The plugin fails to run.

2020-12-03 08:51:36.577 Error: (tuya) failed to load 'plugin.py', Python Path used was '/home/domoticz/domoticz/plugins/Domoticz-TUYA-Plugin-Climate_Test/:/usr/lib/python38.zip:/usr/lib/python3.8:/usr/lib/python3.8/lib-dynload:/usr/local/lib/python3.8/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.8/dist-packages'. 2020-12-03 08:51:36.577 Error: (TUYA) Module Import failed, exception: 'SyntaxError' 2020-12-03 08:51:36.577 Error: (TUYA) Import detail: File: /home/domoticz/domoticz/plugins/Domoticz-TUYA-Plugin-Climate_Test/plugin.py, Line: 112, offset: 9 2020-12-03 08:51:36.577 Error: (TUYA) Error Line ' dev = None

Xenomes commented 3 years ago

There was something wrong, uploaded a new version.

Cees2439867 commented 3 years ago

Hi @Xenomes, I am so happy with your plugin for Domoticz. Yesterday I installed it and it works! I use it for a heater in my bathroom of the brand "Flinq"with type number FQ8176 or FQ8177. It is a Dutch company but the heater is manufactured in China (where else?) and works with the TuyaSmart App. afbeelding This equipment has the following adjustable values: 1) Power On and Off Which now works with your plugin. 2) Temperature Setpoint and Actual Value 3) Switch for 1KW or 2KW or also called high power and low power 4) Lock On and Off

I would also be very interested to have temperature actual and setting on Domoticz. I would also be interested in the swith for 1/2 KW as well as Lock on and off. That is however less important for me.

Many, many thanks for your plugin. Cees

Xenomes commented 3 years ago

@Cees2439867 Can you post the result of debug_discovery.py script in the tools directory? maybe there is something in the reported json string.

Cees2439867 commented 3 years ago

Dear Xenomes,

This took me some puzzling. The part of the output you where asking for is:

Getting devices Got devices { 'header': {'code': 'SUCCESS', 'payloadVersion': 1}, 'payload': { 'devices': [ { 'data': { 'current_temperature': 22, 'max_temper': 40, 'min_temper': 5, 'online': True, 'state': 'false', 'temperature': 25}, 'dev_type': 'climate', 'ha_type': 'climate', 'icon': 'https://images.tuyaeu.com/smart/icon/1470624702_0.jpeg', 'id': '76001160483fda545f37', 'name': 'Badkamer_545F37'}], 'scenes': []}} !!! NOW REMOVE THIS FILE, SO YOUR CREDENTIALS (username, password) WON'T LEAK !!!

The equipment was switched off when I ran the tool.

I have noticed there is a whole bunch of equipment starting to come on the marked that all uses Tuya App. Especially I am looking for movement sensors and temperature/moisture gages. To be able to use those in Domoticz would be awesome.

Many thanks for your support!

Cees

Cees2439867 commented 3 years ago

Dear Xenomes, just added two mains switches. Great, enabled "Allow new devices for 5 minutes" and YES! They show up in under the devices tab, awesome! Thanks a lot, Cees

Xenomes commented 3 years ago

Good to hear the switches a working!

Xenomes commented 3 years ago

Hi @CV8R

I created a new version of the latest version plug-in and tried to add climate support, are you still able to test it?

Cees2439867 commented 3 years ago

Sure I will test it. I need to understand in detail how to install and how to remove. I will get back to you tomorrow with more questions about how to cooperate with you. ā£ Met vriendelijke groet,

Cees Bakker

TypeApp voor Android downloaden ā€‹

Op 13 mei 2021 22:16, om 22:16, Xenomes @.***> schreef:

Hi @CV8R

I created a new version of the latest version plug-in and tried to add climate support, are you still able to test it?

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/Xenomes/Domoticz-TUYA-Plugin/issues/3#issuecomment-840807253

Xenomes commented 3 years ago

Hi @Cees2439867,

I create a new branch Climate_Test, in your case there will be three devices discovered on/off, current temperature and set temperature. Is it possible that you test this version of the plug in? You need to delete your current climate device and update the plug-in and restart Domoticz. Check if the current temperature matches the device (can take a minute to update) also if you can set the temperature from Domoticz and visa versa. If there are error please post the log entries here (Log to all details).

Can you pull the other branch git with this command git pull origin Climate_Test and back with git pull origin master

Cees2439867 commented 3 years ago

Sorry for my slow understanding, after some more reading and study I found what to do. This is the result:

pi@domoticz:~/domoticz/plugins/Domoticz-TUYA-Plugin $ sudo git pull origin Climate_Test remote: Enumerating objects: 78, done. remote: Counting objects: 100% (78/78), done. remote: Compressing objects: 100% (69/69), done. remote: Total 78 (delta 31), reused 21 (delta 9), pack-reused 0 Unpacking objects: 100% (78/78), done. From https://github.com/Xenomes/Domoticz-TUYA-Plugin

I see no new devices after 5 minutes. The logfile shows no errors.

Part of the "Status" part of the logfile:

--------------------------------------------------------------------2021-05-14 10:27:13.987 Hoofdmeter: P1 Smart Meter (Verbruik) 2021-05-14 10:27:13.996 Hoofdmeter: General/Voltage (Netspanning) 2021-05-14 10:27:14.000 Hoofdmeter: Usage (Momenteel Verbruik L0) 2021-05-14 10:27:14.004 Hoofdmeter: Usage (Momenteel Verbruik L1) 2021-05-14 10:27:14.024 Tuya Apparaten: (Tuya Apparaten) Pushing 'onHeartbeatCallback' on to queue 2021-05-14 10:27:14.074 (Tuya Apparaten) Processing 'onHeartbeatCallback' message 2021-05-14 10:27:14.075 Tuya Apparaten: (Tuya Apparaten) Calling message handler 'onHeartbeat'. 2021-05-14 10:27:14.075 Tuya Apparaten: (Tuya Apparaten) onHeartbeat called time=1620980834.0754375 2021-05-14 10:27:14.983 Hoofdmeter: P1 Smart Meter (Verbruik) 2021-05-14 10:27:14.993 Hoofdmeter: General/Voltage (Netspanning) 2021-05-14 10:27:14.997 Hoofdmeter: Usage (Momenteel Verbruik L0) 2021-05-14 10:27:15.001 Hoofdmeter: Usage

Hope this helps. I have left the system running on your new software as it seems okay.

Cees2439867 commented 3 years ago

There is a selection in the configuration Celsius/Fahrenheit. I never set it. So I chose Celsius and updated the Hardware.

Then I see in the logfile:

2021-05-14 10:35:02.447 Status: dzVents: Info: KWhNetto / KWhDirect = 4.182 / 1.455 2021-05-14 10:35:02.447 Status: dzVents: Info: ------ Finished Netto_Direct_Verbruik 2021-05-14 10:35:02.448 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua 2021-05-14 10:35:30.115 Status: Tuya Apparaten: (Tuya Apparaten) Stop directive received. 2021-05-14 10:35:30.229 Status: Tuya Apparaten: (Tuya Apparaten) Exiting work loop. 2021-05-14 10:35:30.315 Status: Tuya Apparaten: (Tuya Apparaten) Stopping threads. 2021-05-14 10:35:30.315 Status: Tuya Apparaten: (Tuya Apparaten) Stopped. 2021-05-14 10:35:30.315 Status: Tuya Apparaten: (Tuya Apparaten) Started. 2021-05-14 10:35:30.315 Status: Tuya Apparaten: (Tuya Apparaten) Entering work loop. 2021-05-14 10:35:30.660 Status: Tuya Apparaten: (Tuya Apparaten) Initialized version 1.0.10 alpha, author 'Wagner Oliveira contributed Xenomes' 2021-05-14 10:36:00.369 Status: dzVents: Info: ------ Start internal script: Event Elke Minuut:, trigger: "every minute" 2021-05-14 10:36:00.380 Status: dzVents: Info: ------ Finished Event Elke Minuut

The heater switches on and of fine. I wait what I can do. Sorry for the strange letter-types I do not know how to deal with that.

Cees2439867 commented 3 years ago

Just found out Domoticz crashed. I tried to get back then I see the following:

pi@domoticz:~ $ cd /home/pi/domoticz/plugins/Domoticz-TUYA-Plugin pi@domoticz:~/domoticz/plugins/Domoticz-TUYA-Plugin $ sudo git pull origin master From https://github.com/Xenomes/Domoticz-TUYA-Plugin

Xenomes commented 3 years ago

Crash is not good... downgrade worked after the reboot? The celcius/fahrenheit i think it is not necessary. Tomorrow i will try to review the code. the rollback command was git checkout origin/HEAD

Xenomes commented 3 years ago

Hi @Cees2439867,

I found the issue forgot to increase the unit number with the extra devices... Is it possible that you can try again... Hope it don't case a crash again. šŸ˜…

Cees2439867 commented 3 years ago

Very nice you found rhe issue. I try tomorrow, otherwise it may take up to the next weekend. I will come back with the results.

ā£ Met vriendelijke groet,

Cees Bakker

TypeApp voor Android downloaden ā€‹

Op 16 mei 2021 21:15, om 21:15, Xenomes @.***> schreef:

Hi @Cees2439867,

I found the issue forgot to increase the unit number with the extra devices... Is it possible that you can try again... Hope it don't case a crash again. šŸ˜…

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/Xenomes/Domoticz-TUYA-Plugin/issues/3#issuecomment-841863529

Xenomes commented 3 years ago

No problem! I will see your result!

BTW. I delete your telephone number from the post.

Cees2439867 commented 3 years ago

Oeps, did nor think about that, thanks!

ā£

Op 16 mei 2021 21:24, om 21:24, Xenomes @.***> schreef:

No problem! I will see your result!

BTW. I delete your telephone number from the post.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/Xenomes/Domoticz-TUYA-Plugin/issues/3#issuecomment-841864820

Cees2439867 commented 3 years ago

Just been looking to try the new solution. Have you noticed that trying to go back to the previous version of the plugin I see the following on my terminal:

pi@domoticz:~ $ cd /home/pi/domoticz/plugins/Domoticz-TUYA-Plugin
pi@domoticz:~/domoticz/plugins/Domoticz-TUYA-Plugin $ sudo git pull origin master
From https://github.com/Xenomes/Domoticz-TUYA-Plugin
    branch master -> FETCH_HEAD
    ba7d6dc..965b6d0 master -> origin/master
    Already up to date.
    pi@domoticz:~/domoticz/plugins/Domoticz-TUYA-Plugin $

It looks like the original version is not reinstalled. Is this okay anyway?

Xenomes commented 3 years ago

Sorry that command was wrong. please try 'git checkout origin/HEAD'

Cees2439867 commented 3 years ago

Unfortunately that gives new messages:


pi@domoticz:~ $ cd /home/pi/domoticz/plugins/Domoticz-TUYA-Plugin
pi@domoticz:~/domoticz/plugins/Domoticz-TUYA-Plugin $ sudo git checkout origin/HEAD
Note: checking out 'origin/HEAD'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 965b6d0 Changed the detected scene's switch type to push button.
pi@domoticz:~/domoticz/plugins/Domoticz-TUYA-Plugin $

I do not understand this...... I have left the system in the state it is.

Xenomes commented 3 years ago

When you nano the plugin.py can you see that it is version 1.0.9?

Cees2439867 commented 3 years ago

I see the following lines:

<plugin key="tuya" name="TUYA" author="Wagner Oliveira contributed Xenomes" version="1.0.9" wikilink="" externallink="https://github.com/Xenomes/Domoticz-TUYA-Plugin.git">
<h2>TUYA Plugin v.1.0.9</h2><br/>
Xenomes commented 3 years ago

v.1.0.9 is the live version. What went wrong with the test version?

Cees2439867 commented 3 years ago

Don't know, have to comeback later........

Op 17 mei 2021 13:17, om 13:17, Xenomes @.***> schreef:

v.1.0.9 is the live version. What went wrong with the test version?

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/Xenomes/Domoticz-TUYA-Plugin/issues/3#issuecomment-842240160

Cees2439867 commented 3 years ago

I have installed the test version, see below

pi@domoticz:~ $ cd /home/pi/domoticz/plugins/Domoticz-TUYA-Plugin
pi@domoticz:~/domoticz/plugins/Domoticz-TUYA-Plugin $ sudo git pull origin Climate_Test
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
From https://github.com/Xenomes/Domoticz-TUYA-Plugin
 * branch            Climate_Test -> FETCH_HEAD
   ec560c2..03cb033  Climate_Test -> origin/Climate_Test
Updating 965b6d0..03cb033
Fast-forward
 README.md | 19 ++++++++++---------
 plugin.py | 21 +++++++++++++++++++--
 2 files changed, 29 insertions(+), 11 deletions(-)
pi@domoticz:~/domoticz/plugins/Domoticz-TUYA-Plugin $ sudo systemctl restart domoticz.service
pi@domoticz:~/domoticz/plugins/Domoticz-TUYA-Plugin $

The plugin.py shows:

<h2>TUYA Plugin v.1.0.10 alpha</h2><br/>

After installing the new file, in Domoticz, I enabled new equipment for 5 minutes. The log file shows:

2021-05-21 11:33:08.310 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 4 state=False id=bf0d089744373f65f6fdh8 online=True
2021-05-21 11:33:08.310 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 6 state=False id=bf87b0e2b750788d240gj5 online=True
2021-05-21 11:33:08.311 Tuya Apparaten: (Tuya Apparaten) DEV name=Badkamer_545F37 state=False id=76001160483fda545f37 online=True
2021-05-21 11:33:08.311 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 2 state=False id=bf7468802bbe3d2e29aheb online=True
2021-05-21 11:33:08.311 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 3 state=False id=bfc57ce83e976922111ljy online=True
2021-05-21 11:33:08.311 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 5 state=False id=bf4c4b88c0b24c9bbbujfq online=True
2021-05-21 11:33:08.311 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 1 state=False id=bf8f2435897c06be2eaci7 online=True

There is no new devices in Domotics. I will leave the test file installed, or should I remove it?

Xenomes commented 3 years ago

Ok that looks good. I think you need to delete the climate device and activate the 5 min detection. Then there must be three devices in devices where you can activate them.

Cees2439867 commented 3 years ago

Aaah, now I understand. So I deleted the heater device and indeed three devices show up, great! I see the following:

afbeelding

The picture is more than 10 minutes after the devices are added. I see the temperatures of the heater as zero. I have tried setting the 'setpoint' temperature to 20 degrees (from 24). It keeps on showing zero degrees and the heater temperature setpoint does not change. Hope this helps.

Xenomes commented 3 years ago

Ok, I need to check the device update from tuyaha. I will keep you posted, maybe tonight or tomorrow.

Xenomes commented 3 years ago

Can you provide me with the part of you log filtered by "Tuya Apparaten"?

Cees2439867 commented 3 years ago

Here is the list:

2021-05-23 10:01:17.953 Hoofdmeter: Usage (Momenteel Verbruik L1)
2021-05-23 10:01:18.202 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 4 state=False id=bf0d089744373f65f6fdh8 online=True
2021-05-23 10:01:18.202 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 6 state=False id=bf87b0e2b750788d240gj5 online=True
2021-05-23 10:01:18.202 Tuya Apparaten: (Tuya Apparaten) DEV name=Badkamer_545F37 state=True id=76001160483fda545f37 online=True
2021-05-23 10:01:18.202 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 2 state=False id=bf7468802bbe3d2e29aheb online=True
2021-05-23 10:01:18.202 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 3 state=False id=bfc57ce83e976922111ljy online=True
2021-05-23 10:01:18.202 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 5 state=False id=bf4c4b88c0b24c9bbbujfq online=True
2021-05-23 10:01:18.202 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 1 state=False id=bf8f2435897c06be2eaci7 online=True
Xenomes commented 3 years ago

Thanks, i need a little bit more information. Can you set the debug in the plugin on "Python Only" and save it by update/aanpassen let it run of a couple of minutes and try to set a temperature hen post the log again.

Cees2439867 commented 3 years ago

2021-05-23 10:14:57.942 Hoofdmeter: Usage (Momenteel Verbruik L0) Is this what you need?

2021-05-23 10:14:57.946 Hoofdmeter: Usage (Momenteel Verbruik L1)
2021-05-23 10:14:57.223 Error: Tuya Apparaten: (Tuya Apparaten) Command for DeviceID=76001160483fda545f37 but device is not available.
2021-05-23 10:14:58.636 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 4 state=False id=bf0d089744373f65f6fdh8 online=True
2021-05-23 10:14:58.640 Tuya Apparaten: (Tuya Apparaten) Update 0:'Off' (Tuya Plug 4: Lamp Televisie) TimedOut=False
2021-05-23 10:14:58.640 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 6 state=False id=bf87b0e2b750788d240gj5 online=True
2021-05-23 10:14:58.645 Tuya Apparaten: (Tuya Apparaten) Update 0:'Off' (Tuya Plug 6: Lamp naast Bank) TimedOut=False
2021-05-23 10:14:58.645 Tuya Apparaten: (Tuya Apparaten) DEV name=Badkamer_545F37 state=True id=76001160483fda545f37 online=True
2021-05-23 10:14:58.650 Tuya Apparaten: (Tuya Apparaten) Update 1:'On' (Kachel Badkamer) TimedOut=False
2021-05-23 10:14:58.650 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 2 state=False id=bf7468802bbe3d2e29aheb online=True
2021-05-23 10:14:58.654 Tuya Apparaten: (Tuya Apparaten) Update 0:'Off' (Tuya - Plug 2: Lamp bij Raam) TimedOut=False
2021-05-23 10:14:58.654 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 3 state=False id=bfc57ce83e976922111ljy online=True
2021-05-23 10:14:58.658 Tuya Apparaten: (Tuya Apparaten) Update 0:'Off' (Tuya Plug 3: Lamp naast Kachel) TimedOut=False
2021-05-23 10:14:58.658 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 5 state=False id=bf4c4b88c0b24c9bbbujfq online=True
2021-05-23 10:14:58.662 Tuya Apparaten: (Tuya Apparaten) Update 0:'Off' (Tuya Plug 5: Lamp op Kist) TimedOut=False
2021-05-23 10:14:58.662 Tuya Apparaten: (Tuya Apparaten) DEV name=Wifi Plug 1 state=False id=bf8f2435897c06be2eaci7 online=True
2021-05-23 10:14:58.666 Tuya Apparaten: (Tuya Apparaten) Update 0:'Off' (Tuya - Plug 1: Staande Lamp) TimedOut=False
2021-05-23 10:14:58.926 Hoofdmeter: P1 Smart Meter (Verbruik) 
hectorgarcia-cw commented 2 years ago

Hi. I'm interested on climate heater support too. I was trying to start with your Climate branch but I cannot find it. What can I do to help?

dgilbert2 commented 1 year ago

Hi, is the update to support "climate" available please, as I need to read a thermometer temperature in Domoticz from a "Smartlife" device.

Thanks

michaelblaas commented 1 year ago

Hi @Xenomes , Is this functionality ever implemented in the production (master) branche? The Climate_Test branch is no longer available however my Tuya heater is not fully recognized (only on/off) after several efforts. Currently on 1.0.13. Output of debug script:

Getting devices Got devices { u'header': { u'code': u'SUCCESS', u'payloadVersion': 1}, u'payload': { u'devices': [ { u'data': { u'current_temperature': 21, u'max_temper': 37, u'min_temper': 0, u'online': True, u'state': u'false', u'temperature': 22}, u'dev_type': u'climate', u'ha_type': u'climate', u'icon': u'https://images.tuyaeu.com/smart/program_category_icon/qn.png', u'id': u'74354272c45bbef4adf4', u'name': u'Bureau Vide'}], u'scenes': []}}

Thanks for answering.

Xenomes commented 1 year ago

Hi, Climate is now available in a other plugin TinyTUYA