Tuya LOCAL with energy monitoring and without tuya-convert

ok Gents,
So i confirm these commands work. i.e. open, close and stop

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

    def close_cover(self, **kwargs):
        """Close cover."""
        _LOGGER.debug("Launching command %s to cover ", "ZZ")
        self._device.set_dps("ZZ", self._dps_id)

    def stop_cover(self, **kwargs):
        """Stop the cover."""
        _LOGGER.debug("Launching command %s to cover ", COVER_STOP_CMD)
        self._device.set_dps(COVER_STOP_CMD.upper(), self._dps_id)

however, the cover entitly state is not reflecting the current state. To clarify

I press the close arrow, the cover closes. The slider moves to the close position, but the state remais open and the window icon stays open.

I press the open arrow, the cover opens, the slider moves to open positon and off course no change in the state as it never moved.

Hi,
I used the integration of light bulbs and switches via YAML and not via config flow so as not to have to manually enter the configuration to each test.

Through YAML configuration is not possible to vary those values? Do you need to change the Light file as I did?

Perfect for async integration. I await the tests.
Have a good day

State is polled every 30s, so it might take up to that time before state is reflected. Perhaps you can verify that? This will fix itself once we merge the change to use a persistent connection, as state changes are pushed (and updated) immediately. I’m gonna try to update some logging in that PR so we can merge today hopefully.

You can use brightness_lower and brightness_upper as I mentioned before, here is an example:

https://github.com/rospogrigio/localtuya-homeassistant/blob/300edaed4639a12bac43268c0848c9d6c2f6d4e0/custom_components/localtuya/init.py#L37

I have changed the upper limit to 1000 by default now.

Of course, last night, as I told you, I modified that file for the correct functioning of my bulbs.
My settings:
DEFAULT_LOWER_BRIGHTNESS = 10
DEFAULT_UPPER_BRIGHTNESS = 1000

You should just put:

brightness_lower: 10
brightness_upper: 1000

Under your light entity in the YAML config and not change the code. Should work equally fine.

1 Like

The asyncio PR has been merged and I have rebased the brightness range PR on top of that. So now is a good time to try if it all works.

Edit: You only need to check out and test the brightness PR as everything is there.

The asyncio is now merged so I updated the PR to use that, so now the state change should be immediate, can you please check @juan11perez ?
Edit: please note that you will need to close the Tuya app (or put the mobile in airplane mode) in order to operate your devices with this new PR.
Edit 2: it is not advised to post the localKeys of your devices online since someone might tamper with them
 I’d suggest you edit your post of the tuyadebug output hiding them. (Or, you can re-pair them with the app: this will generate new keys).

thank you.
I’ve downloaded the zip and installed it
should i replace the up/down/stop commands in cover.py with what i reported earlier?

No, you should just configure them with the line:
open_close_cmds: fz_zz
if you are using YAML config file, or select them from the drop-down menu if you are using config flow.

it’s not working
fz_zz doesnt show up in config flow
and i tried this and it’s rejected

- host: 192.168.1.64
  device_id: 42787240807d3a0103b8
  local_key: key
  friendly_name: curtains_bruno
  protocol_version: "3.3"
  entities:
  - platform: cover
    friendly_name: curtains_bruno
    id: 102
    open_close_cmds:  fz_zz 
    positioning_mode: position 
    currpos_dps: 101
    setpos_dps: 101 
    span_time: 25     

I believe you did something wrong because I’ve just tested and they do appear in the drop-down menu:

Please double-check and try again


I downloaded the master zip 2 times.
copied to custom_componenets/localtuya
cleared the cache
I cant see fz_zz

I also searched for fz_zz in the directory files, and it’s not there.
can you provide a git link to the directory?

It’s not on master so you cannot do that. You must check out from the branch belonging to the PR.

As an alternative, if you are not familiar with GitHub and checkouts and stuff, let’s just re-patch the code like you did before, and let us know if it works

Edit: if you want to use gitHub, here is the link of the PR again:

This possibility is excellent.
Tonight I try to insert the code directly into the YAML file

LocalTuya gets better every day!!!

@postlund @rospogrigio Thank you for your work and commitment that you dedicate to this project

so I changed to the uppercase branch like this

and downloaded the dir.
I used configflow and now the fz_zz command appears.
but the entity is unavaiable

I also tried by modifiying the code with the PR info and the entities are unavailable.

just for more info, I also have 4 tuya boiler switches and they’re working fine

OK,
tonight, when I get home, I try and update you on the result :slight_smile:

I think it’s because you have your Tuya application working: as I said, some devices don’t allow multiple connections. Try to kill the app or put your mobile in airplane mode

killed the app
switche the phone off
still unavailable.