Tuya LOCAL with energy monitoring and without tuya-convert

At least you have values…others apparently not. From the switch one you would have to create 2 sensors as per my example, one to extract the consumption from attribute into state value. The other is the integration sensor that keeps statistics and shows up in the energy dashboard.

And how do I create this sensor? While adding the device to localtuya or some other way?

[Edit]
I tried adding the device again, made a Switch and one Sensor on the (what I think is) the _current_consumption DP.

Then I used the sensor with the same Integration settings as you had in your yaml, but I get “unknown” as a state, see below:

[Edit 2] - Seems I got it working with the settings below. I just had to wait for the data to aggregate I think. I think the problem with the other sensor is with how frequently the socket measures, added a comment here about that.

It requires time to generate statistics data indeed. So I hope it is now all fine, I will de-link from this post

1 Like

Thanks for this… Is there a way to get local tuya / homeassistant to report the energy usage (kWh) ? I can see the Dip id on Tuya IOT portal but local tuya only have the 3 attributes.

1 Like

Anyone managed to integrate in local-tuya Aubes smart switches? They are really cheap on Aliexpress and they work very good. You can get them with or without power monitoring (be careful when ordering!).

But the problem is that I can not get them working in local-tuya (they work throug official tuya integration).
When added, you need to manually select protocol 3.1 or 3.3. It works only with 3.3, but also in this case you get the response, that none of DPS is available. I tried to manually added a few, when adding DPS 1, you get the switch in HA, but is “unavailable”.

Cross posted

Local Tuya Novostella Flood - No dp_id from API explorer

Anyone ever seen when API explorer does not return dp_id? Can’t figure out even primary switch to start off.

There is local-tuya fork that is supposed to work also with 3.4

I attached 18, 19 & 20 via the integration and grab them individually via template sensors.
Current needed to be divided by 1000 to get the value in Amps.

Anyone knows what the other values are and how to expose them to Home Assistant?
DPS [1] VALUE [True]
DPS [9] VALUE [0]
DPS [18] VALUE [32] - Сurrent
DPS [19] VALUE [32] - Power
DPS [20] VALUE [2367] - Voltage
DPS [21] VALUE [1]
DPS [22] VALUE [691]
DPS [23] VALUE [33766]
DPS [24] VALUE [20628]
DPS [25] VALUE [2030]
DPS [26] VALUE [0]
DPS [38] VALUE [memory] - Relay Status [off; on; memory]
DPS [40] VALUE [relay]
DPS [41] VALUE [False] - Lock
DPS [42] VALUE []
DPS [43] VALUE []
DPS [44] VALUE []

1 Like

Hi @Brocks I am getting the same “non-mobile devices” problem when I am trying to link my app account with my developer account. How did you fix it?

9 - countdown timer

My Tuya devices are on a separate VLAN, how can I get Local Tuya to scan for those?

I was having the same issue, I cound’t write 0.001 directly.
The way I did it was to type 0.1 first and then add the extra zeros as needed.

1 Like

i managed to find device id, but how to obtain the lokal Key?
please can you help

1 Like

Hi before i install the local Tuya does my smart life app still work or does this remove the smart life apps control of my devices?

app still work

Hello, I bought a Kekotek breaker on amazon but I can’t read the data (kw and a) on localtuya. With the tuya cloud version it reads them.

I read above and made a configuration like:

switch:


- platform: localtuya
  host: 192.168.1.76
  local_key: 1234567891234567
  device_id: 12345678912345671234
  name: tuya_g4
  friendly_name: tuya_g4
  protocol_version: 3.3
  switches:
    sw01:
      name: tuya_g4
      friendly_name: G4 plug
      id: 1
      current: 4
      current_consumption: 5
      voltage: 6

sensor:

- platform: template
  sensors:
    tuya_g4_voltage:
      friendly_name: "G4 voltage"
      unit_of_measurement: 'V'
      value_template: "{{ states.switch.tuya_g4.attributes.voltage }}"
      
    tuya_g4_current:
      friendly_name: "G4 current"
      unit_of_measurement: 'mA'
      value_template: "{{ states.switch.tuya_g4.attributes.current }}"
      
    tuya_g4_current_consumption:
      friendly_name: "G4 current consumption"
      unit_of_measurement: 'W'
      value_template: "{{ states.switch.tuya_g4.attributes.current_consumption }}"

but it did not work

This helped me solve it!
It was not obvious that even though the switch/base entity had options for power/current, they didn’t work and I had to add the sensor component manually.

I am struggling on this bit

On the topic of localtuya I just submitted a PR to @rospogrigio for the WE and EA datacenter regions. This as Tuya now have started to enforce a strict one-datacenter rule to the trial accounts in their api. This means that I as a WE user cannot anymore have the cloud account connected to EU datacenter also and so I cannot addd my cloud account. Simple fix and hope it helps some more people.

2 Likes