Tuya LOCAL with energy monitoring and without tuya-convert

No problem, is this useful?:

-@-:/tmp/tuyadebug $ tuya-cli get --ip 192.168.170.211 --id dev-id --key dev-key --protocol-version 3.3
3 --> STOP
-@-:/tmp/tuyadebug $ tuya-cli get --ip 192.168.170.211 --id dev-id --key dev-key --protocol-version 3.3
1 --> UP
-@-:/tmp/tuyadebug $ tuya-cli get --ip 192.168.170.211 --id dev-id --key dev-key --protocol-version 3.3
2 --> DOWN

Perfect, please try this PR:
https://github.com/rospogrigio/localtuya/pull/103
Report any feedback in the PR conversation, please, thank you.
PS: you’ll have to configure the parameter “commands_set” to 1_2_3 in YAML, or select it from the drop-down menu in config flow, obviously.

1 Like

Done, Thanks a lot. Works perfectly!.

Wanted to thank you guys for Tuya local and give my experience.

Mostly, I followed the instructions from post 3 of this thread.

I have android rooted phone I don’t use anymore. Doesn’t have a SIM card, but works fine on wifi, so I pulled it out of the closet, and powered it up.

Searched, and found smartlife 3.3.0 apk, then downloaded it, then installed.

Started it up, entered my smartlife login, and app showed my tuya devices.
Made sure I could turn them on and off, then quit the program.
Brought up a root explorer, went to the directory from the post 3 instructions
/data/data/com.tuya.smartlife/shared_prefs
Need to select root first in my explorer to get there. Tried to copy the file to my google drive. That kept failing, so I gave up and edited the file on my phone with a root editor app.

Searched for “local” with the editor, and when I found it, scrolled to the right a little bit and found a local key. Its 16 digits long. Then if you go to the left some, you have to go past the position info, you will find the id for that local key.
Keep searching for “local” to find all your local keys.

I had three tuya smart plugs installed, and it gave me all three keys.

I have a supervisor version of HA running in docker. I have Samba, used it to copy tuya local from github into my custom_components directory.


Once it was copied over, I went to the integrations page in HA, and push the + icon to install tuya local. Tuya local shows you all the tuya devices you have running. Select one based on the id. Id should match one from file, I just use the last 4 digits of the id and that was fine.
Added the local key and did the other config stuff from the instructions.

After than, I added the tuya local switch names to HA, and could control the switches from HA locally instead of through the cloud.

At this point I messed up and removed the plugs from the smartlife app, so the plugs stopped working. Should read instructions lol.

Added them back to smartlife, but for some reason only two showed up. Could not get it to show the third one, and at some point smartlife upgraded itself, so I had to remove it and reinstall 3.3.0.

IMPORTANT trick for Smartlife app.
To find all the local keys, in Smartlife, I selected “profile” on the bottom, then “Setting” then “clear cache”.
After that, I made sure I could turn on all the switches, exited the program. Then used my root editor to find the local keys, all three of them.
I added a couple more tuya plugs, and had to clear cache again so I could get the local keys, but since I knew this trick it was easy.

Haven’t tried power monitoring yet, I have a monoprice plug with tasmota installed that I use power monitoring on, these plugs just need to turn on and off.

Randy

3 Likes

I currently have the Tuya cloud integration installed. Do I need to remove that before installing / configuring localTuya?

Yes, you need remove all add-ons named tuya. Tuya, tuya_custom, etc


Thank you 


Just FYI, I have two of the latest Kogan wifi switches (with USB ports and power monitoring) working fine with localTuya. Thanks very much to all concerned. Very pleased as I was quite disappointed that I could not use ESPhome with them.

The switching works well. The displayed power measurements are quite laggy but this does not effect my use case which is monitoring for washing machine and dishwasher cycle finishes.

Next up will be two Kogan RGBW lights and a Kogan Air Filter.

Also FYI, I installed v3.01 by copying into a new custom_components folder. The integration could not be found via the UI - I had to use the configuration.yaml file method.

I had to change my router static ip addressing yesterday, and after I finished some of my tuya local plugs had stopped working.
Figured out that their ip addresses changed when I made my other router changes.
So I assigned them static ip addresses in the router so this won’t happen again.
When you do this, you also have to change the ip address of the tuya local device to match. Select the device, then options to change this.

On my router, the tuya devices show up as esp_xxxxxx where xxxxxx is the last 6 digits of the mac address. This is also the end of the device id, to figure out which device is what on your router.

Assign static ip’s is the better solution and avoid problems. Also you can use other apps as https://play.google.com/store/apps/details?id=com.overlook.android.fing&hl=es&gl=US to get device mac. Thanks for share!.

This will be solved automatically from the next release of localtuya. It will discover when IP addresses change and update them automatically (works with YAML too, but since we can’t write the change back to file you will likely get a connection error upon next restart of Home Assistant).

1 Like

Hi @postlund,
how are you? Tonight I return home from vacation!
I have seen that there have been many changes and I am still stuck at 2.01.

Which version should I install to test the development of the color version?
If I’m not mistaken it was pull #90 (https://github.com/rospogrigio/localtuya/pull/90

See you soon!

Hey! That part is not released yet, I’ve been swamped with lots of stuff. But I’m gonna try to finish the HSV part soon at least. Stay on 2.0.1 for now, 2.0.3 has a few issues and we are waiting for a PR to be merged over at HACS to solve that.

Here I am back home!
So there is no need for testing for now.
I can go to sleep!
Good night, see you tomorrow

Hello all,
I have 1 tuya rgb bulb. I can add it to home assistant using the integration page. However I can only add it using DP 20. This allows me to turn the light on and off but not control color or brightness. The other DPS exist but when I select them I have no control and the light says unavailable. Any ideas much appreciated

Color support is not supported yet, it will come in the near future hopefully.

Good to know. And brightness? Do I just add DP 20?

It depends on your device I guess. Easiest is to just try and see what happens. You can just change the DP from Options for the device (assuming you added via config flow, otherwise you can change in YAML and reload the device).

I am back! So much has changed here
 I still cannot get this to work though. I would still appreciate any help that anyone is willing to give me.

Please see below for my error log:

Hi @postlund @rospogrigio,
Just for info, I saw that even in the old version 2.01 I have an error with the manifest.json

Logger: custom_components.hacs.repository.integration.rospogrigio.localtuya
Source: custom_components/hacs/repositories/integration.py:88
Integration: HACS (documentation, issues)
First occurred: 24 ottobre 2020, 16:03:11 (19 occurrences)
Last logged: 01:03:12

No file found ‘manifest.json’