Tuya LOCAL with energy monitoring and without tuya-convert

Thanks I look forward to.

Mmmm, this is in contrast with what you originally wrote :

ID4= heating mode (manual, auto, holiday)

Now you are saying that the allowed values are Program/Manual/Holiday. If you look at the code, currently when you set a HVAC mode, the main switch is turned to on, AND the related command is sent to DP 4. If you don’t see the mode change it means that we are sending the wrong command (and as we are seeing, probably the it is case sensitive).
So, the challenge here is to develop the component such that it is usable for you AND general enough for other Tuya devices. Probably we’ll have to define the commands as options like we have done for covers. In the meantime, please confirm that the modes you see (with tyadebug) are Program/Manual/Holiday.
What happens if you set “Program”? I don’t know how HA is supposed to handle programming. Also the Preset thing is a bit tricky to setup, I have to do some thinking


OK I got it. Previous ID were from tuya app (heating mode (manual, auto, holiday) just to show ID meaning). Now what I can exactly see in the tuya_debug log for modes is (“Program”,“Manual”,“Holiday”). But I can understand its only for my case, general tuya device can be different from this. Yes it may be probalbly case sensitive beacuse it doesnt change mode. From Off state both buttons in HA card change it ON and to heating.mode.

Hi folks,

I have a noob question, how do you folks get the local_key? I have followed the instruction in:

without success. Is there a much easier way to get the local_key or am I out of luck?

Oh, I am also on Android and I used my Raspberry Pi4 to run the tuya-cli.

Thanks heaps in advance

Hello, this video helped me a lot!

Try it.

I got the following logs:
devices 192.168.1.109 and 248 are 2 identical zemismart covers.

@Alloc186 OK I have something in mind but will take some time to code it.

@juan11perez sorry I was not clear enough with what I meant with “tuyadebug”. I mean to download tuyadebug.tgz from the main page of localtuya integration, unzip it and launch the test.py script with the correct parameters for your device, for example:
./test.py device_id device_ip local_key
This should return the current status of the device (the list you get in the DPs drop-down menu). Launch it in the 4 situations you posted before so we can see what’s going on.
The only thing is that you are getting connection errors so maybe you’ll get a connection failure when operating with Tuya app because some devices don’t allow multiple connections. In this case, when you try with the remote control, please disconnect your app (i.e., kill it or put the phone in airplane mode). Let us know


thank you
to clarify I’m running HA in docker. so do I run this debug from HA docker or any linux machne in the network will do?

I also am running HA in docker, you can run the script from outside the docker, or from any other linux machine. If you have configured the devices in HA, remove them or stop HA since it could not allow multiple connections.

I have hacked something together that you can try:

It’s not tested as I don’t have any light, but I hope it works. I believe the range is ok, but you might to have tweak at least the lower limit in case the light doesn’t turn off at precisely 0.

1 Like

Thanks, as soon as I get home I try!

1 Like

Hi @postlund,

I tried the new code, but unfortunately it can’t handle the bulb well.
When I bring the brightness to maximum it is unavailable.
Often the slider fails to vary the brightness of the bulb and when it starts working again, it makes all the single past variations. But this only happens if you change the brightness repeatedly, normally I never would!

Here are some errors:



EDIT
Setting these values, it seems not to turn off when it reaches the maximum level:

DEFAULT_LOWER_BRIGHTNESS = 10
DEFAULT_UPPER_BRIGHTNESS = 1000

GREAT job, THANKS!!!

I noticed that this version is not the “pytuya_asyncio”.
Could inserting those parameters improve the speed of changes?

Tomorrow I will try to report the changes occurred in the “Re-map light brightness range” inside Convert pytuya to asyncio.

THANKS again MYTHICAL Pierre

Good Night

good day, so here it goes

stopped homeassistant and disconnected phone

Sounds great! That’s what I meant with “you have to tweak the limits”. You should not change the code though, you can do that from from Options in Integrations (if you added via config flow) or by specifying brightness_lower: and brightness_upper:.

We will likely merger the asyncio branch today, that should likely make the updates instant as well.

1 Like

There we have it. You should probably use ZZ to as close command and FZ as open command.

Thank you. So something like this

def open_cover(self, **kwargs):
“”“Open the cover.”""
_LOGGER.debug("Launching command %s to cover ", self._ZZ_cmd)
self._device.set_dps(self._ZZ_cmd.upper(), self._dps_id)

?

More like:

def open_cover(self, **kwargs):
    “”“Open the cover.”""
    _LOGGER.debug("Launching command %s to cover ", "ZZ")
    self._device.set_dps("FZ", self._dps_id)

And corresponding to close. @rospogrigio can then add this command set after you have verified that it works.


I remember someone asking: “how many different commands could there be???” :laughing:
I could expect some numeric command but I would have NEVER imagined something like FZ-ZZ
:astonished:
OK I prepared the PR : https://github.com/rospogrigio/localtuya-homeassistant/pull/81, please try it @juan11perez and review it @postlund .

No, that’s kinda ridiculous :wink: I believe DPS above 100 are custom DPs by the vendor, so I guess the vendor decided this was good. Maybe it maps to some other system or old standard


Yeah, this device is rather peculiar. Also, it’s the first one that does not even provide DP 1
 very weird.