Tuya LOCAL with energy monitoring and without tuya-convert

Hi @sKooTr

Did you ever get any further with this? I’ve got exactly the same unit and would also love to be able to integrate the other controls.

Does anyone know how we can add calibration code to sensors of power readings like calibrate_linear etc. in ESPHome and/or give an example?

Hi Brad,
No I did not get any further, sorry.

I have a problem. I want to configure a Switch (with the main socket and a usb). How can I configure in configuration.yaml? I want the V, mA and Watts.

localtuya:
  - host: 192.168.1.HOST
    device_id: MYDEVICEID
    local_key: MYLOCALKEY
    friendly_name: H1 Switch Device
    protocol_version: "3.3"
    entities:
      - platform: binary_sensor
        friendly_name: Plug H1A Status
        id: 1
        device_class: power
        state_on: "true" # Optional
        state_off: "false" # Optional

      - platform: sensor
        friendly_name: Plug Voltage
        id: 20
        scaling: 0.1 # Optional
        device_class: voltage # Optional
        unit_of_measurement: "V" # Optional

      - platform: switch
        friendly_name: Plug
        id: 1
        current: 18 # Optional
        current_consumption: 19 # Optional
        voltage: 20 # Optional

Hi Scott

OK thanks, I’ll keep playing around and will let you know if I have any luck.

Hi All,

I need some help with some RGBW light strips. I can’t get them to turn off. They turn on fine, can change the color without an issue and selecting the center for white gives me white. The problem is when I turn it off, HA things it’s off but the strip just turns to white.

I hadn’t found this thread previously so I created another here that shows the DPS’s I have selected. Just clicking the image links shows the settings.

Mind sharing the code? I have 2 lights that randomly become unavailable and if I toggle them in the tuya smart up they appear available again. Would love to be able to check what devices are unavailable and reboot them.

Hi,
fairly new to home Assistant just started playing this weekend.
Thought i’d start with the tuya globes I’ve got.
went through the process and got the keys from tuya, setup the Tuya Local integration on Home Assistant, and tried to configure a couple of the globes.
I’ve tried to configure through the UI, and set all the recommended setting on the UI - didn’t quite match up to what the documentation was expecting but most of them did - I couldn’t turn the globe off though HA, the swtich would switch for a second and then revert back to the off position.

I decided to attempt to configure the setting through yaml, with this attempt the light is now saying it’s unavailable.

I suspect there are some really easy things that i’ve got wrong in this attempt.
Also the sewing light that i configured through the UI, is still displaying as existing, but I can’t see the yaml that’s creating it in the configuration.yaml.

a couple of questions, where should I start adjusting this yaml to try and make the lights contactable.

localtuya:
  host: 192.168.10.101
  device_id: xxxx
  local_key: xxxx
  friendly_name: lounge_light
  protocol_version: "3.3"
  entities:
    - platform: light
      friendly_name: lounge_Light
      id: 1
      brightness: 1
      brightness_lower: 25
      brightness_upper: 255

i’ve tried with both 3.1 and 3.3 of the protocal versions,
should the device_id and local_key values be in quotes - currently they are not.

i’ve assigned the lights static Ips on the router, and I can ping them, is there something else I should do to ensure they are available on the network.

if I connect the network to the internet I can toggle the lights on and off with the tuya smart app.

thank you for any assistance.

all good,
I’ve figured it out, appears that I just had to activate the device, a little confusing because from the UI it looked activated and unavailable - but all sorted.

Would like to thank you and all your contributors for the work that has gone into building this integration - really appreciate it.

Liam

1 Like

How do I get the local key?

Linking a Tuya device with Smart Link

I know this is a noob question, but I have TuyaSmart already installed and both switches installed there. Can I get local_key and device_id from there?

It seems getting them via the Tuya IoT platform is no longer possible.

How to make the easy control?If i need to use cloud at the same time.

I got the energy monitoring working but once or twice a day the plug disconnects. And the only way to connect again is to unplug it. I got this error in my log:`

``
Logger: custom_components.localtuya.common
Source: custom_components/localtuya/pytuya/init.py:240
Integration: LocalTuya integration (documentation, issues)
First occurred: 22 april 2021 18:11:36 (94 occurrences)
Last logged: 11:29:38

[034…1d9] Connect to 192.168.0.217 failed
Traceback (most recent call last):
File “/config/custom_components/localtuya/common.py”, line 149, in _make_connection
status = await self._interface.status()
File “/config/custom_components/localtuya/pytuya/init.py”, line 472, in status
status = await self.exchange(STATUS)
File “/config/custom_components/localtuya/pytuya/init.py”, line 451, in exchange
msg = await self.dispatcher.wait_for(seqno)
File “/config/custom_components/localtuya/pytuya/init.py”, line 240, in wait_for
await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
File “/usr/local/lib/python3.8/asyncio/tasks.py”, line 501, in wait_for
raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError
``

P.S.: The recommended website states that their approach no longer works :frowning:

That seems to be correct for

  • Listing Tuya devices from the Tuya Smart or Smart Life apps

But there is still another approch left:

  • Linking a Tuya device with Smart Link

That’s the way I took a couple of month ago. It’s not as easy as the 1st approach but it did work well.

This worked for me about a week ago:

1 Like

I have an old version of Tuya smart life installed on an android emulator on my PC, I can just use root explorer to grab the local keys that way.

Hello Hugo,

Did you succeed with this? i having the same problem and kind of new to HA.

How do i create a sensor to report the volt, watts, e.t.c.

just set it up via the config flow and enter the DPS settings for your plug. You will then have a switch entity with the information. You can then you sensor template to split them off into seperate sensors.