Tuya LOCAL with energy monitoring and without tuya-convert

I have found better and way easier solution!

Just be warned, instructions in repository are a bit confusing, you can not just copy code, since there is some inconsistency! But you may copy mine:

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 }}"

You may change all “friendly_name” but when you are changing “tuya_g4” under sw01, make sure that you will change also all instances for switch! I had some issues getting sensor data since in the instructions on repository for switch is name “tuya_01”, but in sensor was once “tuya-sw01” and in value template “sw01”.

16 Likes