Tompd 63sw Energy monitor values frozen

Hey, after installing the energy monitor I noticed that values don’t update, only Total Energy is updating, leakage current voltage current and power have the same value since day 1
flashed the mcu with the latest esphome
I noticed also that my pcb is a little bit different from the device used here TOMZN TOMPD-63-WiFi | ESPHome Devices

esphome:
  name: tompd-cbu
  friendly_name: tompd-cbu


bk72xx:
  board: generic-bk7231n-qfn32-tuya
  #board: wb3s

ota:
  - platform: esphome
    password: "0b8b2bf7c9fe6f9a9bd8a6913b693b72"

api:
  encryption:
    key: "K6VTuysbvkk8clKXDC91dNoUaRobo0IJmk5N3b6fDY4="
# Enable Home Assistant API

# Disable logging
logger:
  baud_rate: 0
  
uart:
  baud_rate: 9600
  id: uart_tuya
  rx_pin: RX1
  tx_pin: TX1

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.3.68
    gateway: 192.168.3.1
    subnet: 255.255.0.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "tom Fallback Hotspot"
    password: "idEqhSV1Hafg" 
    
tuya:
  uart_id: uart_tuya
  on_datapoint_update:
  - sensor_datapoint: 6
    datapoint_type: raw
    then:
      - lambda: |-
          ESP_LOGD("main", "on_datapoint_update %s", format_hex_pretty(x).c_str());
          id(voltage).publish_state((x[0] << 8 | x[1]) * 0.1);
          id(current).publish_state((x[3] << 8 | x[4]) * 0.001);
          id(power).publish_state((x[6] << 8 | x[7]) * 1);

switch:
  - platform: tuya
    switch_datapoint: 16
    name: "On"

sensor:
  - platform: template
    id: voltage
    name: "Volt"
    unit_of_measurement: "V"
    icon: "mdi:sine-wave"
    accuracy_decimals: 1
  - platform: template
    id: current
    name: "Curent"
    icon: "mdi:current-ac"
    unit_of_measurement: "A"
    accuracy_decimals: 2
  - platform: template
    id: power
    name: "Power"
    icon: "mdi:flash"
    unit_of_measurement: "W"
    accuracy_decimals: 0
  - platform: tuya
    name: "Total Energy"
    sensor_datapoint: 1
    unit_of_measurement: "kWh"
    accuracy_decimals: 2
    icon: "mdi:lightning-bolt"
    filters:
      - multiply: 0.01  
  - platform: tuya
    name: "Leakage Current"
    sensor_datapoint: 15
    unit_of_measurement: "mA"
    accuracy_decimals: 0
    icon: "mdi:flash-alert"

from the log I can get this maybe it can help

[10:36:49.237][C][tuya:056]:   Datapoint 16: switch (value: ON)
[10:36:49.241][C][tuya:060]:   Datapoint 19: string value (value: 1234)
[10:36:49.244][C][tuya:054]:   Datapoint 17: raw (value: 04.01.00.1E)
[10:36:49.246][C][tuya:054]:   Datapoint 18: raw (value: 01.01.00.28.03.01.00.F5.04.01.00.D2 (12))
[10:36:49.251][C][tuya:058]:   Datapoint 1: int value (value: 1030)
[10:36:49.255][C][tuya:058]:   Datapoint 15: int value (value: 0)
[10:36:49.258][C][tuya:054]:   Datapoint 6: raw (value: 09.06.00.06.E0.00.01.29 (8))
[10:36:49.262][C][tuya:058]:   Datapoint 104: int value (value: 800)
[10:36:49.266][C][tuya:058]:   Datapoint 105: int value (value: 500)
[10:36:49.270][C][tuya:058]:   Datapoint 116: int value (value: 2317)
[10:36:49.273][C][tuya:058]:   Datapoint 117: int value (value: 1960)
[10:36:49.277][C][tuya:058]:   Datapoint 118: int value (value: 362)
[10:36:49.280][C][tuya:056]:   Datapoint 11: switch (value: OFF)
[10:36:49.284][C][tuya:058]:   Datapoint 13: int value (value: 0)
[10:36:49.287][C][tuya:064]:   Datapoint 9: bitmask (value: 0)
[10:36:49.292][C][tuya:074]:   Product: '{"P":"u0cxoxtfelys3ufx","v":"1.0.0","m":1,"mt":10,"n":0,"low":0}'

Do you see actual updates, i.e. on_datapoint_update debug messages?

I get update only on Total energy and Leakage mA

[11:14:46.498][D][tuya:368]: Datapoint 1 update to 1083
[11:14:46.501][D][sensor:135]: 'Total Energy': Sending state 10.83000 kWh with 2 decimals of accuracy
[11:14:46.524][D][tuya:360]: Datapoint 11 update to OFF
[11:14:46.529][D][tuya:368]: Datapoint 13 update to 0
[11:14:47.475][D][tuya:368]: Datapoint 15 update to 0
[11:14:47.482][D][sensor:135]: 'Leakage Current': Sending state 0.00000 mA with 0 decimals of accuracy
[11:14:48.474][D][tuya:368]: Datapoint 104 update to 824
[11:14:48.495][D][tuya:368]: Datapoint 105 update to 500
[11:14:48.516][D][tuya:368]: Datapoint 116 update to 2321
[11:14:48.522][D][tuya:368]: Datapoint 117 update to 2390
[11:14:48.549][D][tuya:368]: Datapoint 118 update to 457

switched on an older model 63-wifi (wb3s chip) the same config (board, api and ota different of course) I get all data

[11:25:31.223][D][tuya:397]: Datapoint 9 update to 00000000
[11:25:31.242][D][tuya:368]: Datapoint 1 update to 61205
[11:25:31.245][D][sensor:135]: 'Total Energy': Sending state 612.04999 kWh with 2 decimals of accuracy
[11:25:31.264][D][tuya:352]: Datapoint 6 update to 09.04.00.00.00.00.00.00 (8)
[11:25:31.266][D][main:049]: on_datapoint_update 09.04.00.00.00.00.00.00 (8)
[11:25:31.269][D][sensor:135]: 'Volt': Sending state 230.80000 V with 1 decimals of accuracy
[11:25:31.270][D][sensor:135]: 'Curent': Sending state 0.00000 A with 2 decimals of accuracy
[11:25:31.272][D][sensor:135]: 'Power': Sending state 0.00000 W with 0 decimals of accuracy
[11:25:31.292][D][tuya:368]: Datapoint 15 update to 0
[11:25:31.293][D][sensor:135]: 'Leakage Current': Sending state 0.00000 mA with 0 decimals of accuracy
[11:25:31.296][D][tuya:368]: Datapoint 13 update to 0
[11:25:31.319][D][tuya:360]: Datapoint 12 update to OFF
[11:25:31.319][D][tuya:397]: Datapoint 9 update to 00000000

And what are the values on the display at the time of the datapoint updates?
Maybe that model uses other values…

you mean on the device display ? displaying normally refreshing 2-5 times /sec
I noticed that the frozen values are refreshing to Hass each time I make an ota update, probably each time the mcu reboots, to sum it updates all the values after wake up but only keep updating Total energy and Leakage

Yes, and I meant the actual values, to correlate with other datapoints, maybe?

Did you try with the tuya app before flashing, to check whether those values were provided to Tuya itself? Maybe that revision of the board only provides meaningful data once, at start?

nope, I flashed the device right from the box no tuya app,
yep update at start then only 2 values updates each time, but it’s updating on the display normally

Such a problem again — I was lazy and didn’t make a backup, nor did I check it on Tuya. Now I don’t have updates and I’m using incorrect Datapoints.
Does anyone have the possibility to access Tuya and obtain the correct data?

I would also like to add that updates occur only through this datapoint

[19:49:00.094][D][tuya:379]: Datapoint 1 update to 2091
[19:49:00.098][D][sensor:129]: ‘Total Energy’ >> 20.91 kWh
[19:49:00.119][D][tuya:371]: Datapoint 11 update to OFF
[19:49:00.126][D][tuya:379]: Datapoint 13 update to 0
[19:49:00.126][D][sensor:129]: ‘Remaining Available Energy’ >> 0.00 kW/h
[19:49:01.084][D][tuya:379]: Datapoint 15 update to 0
[19:49:01.092][D][sensor:129]: ‘Leakage Current’ >> 0 mA
[19:49:02.086][D][tuya:379]: Datapoint 104 update to 481
[19:49:02.108][D][tuya:379]: Datapoint 105 update to 500
[19:49:02.132][D][tuya:379]: Datapoint 116 update to 2359
[19:49:02.138][D][tuya:379]: Datapoint 117 update to 2570
[19:49:02.154][D][tuya:379]: Datapoint 118 update to 292
[19:53:59.536][D][tuya:379]: Datapoint 1 update to 2093
[19:53:59.543][D][sensor:129]: ‘Total Energy’ >> 20.93 kWh
[19:53:59.561][D][tuya:371]: Datapoint 11 update to OFF
[19:53:59.566][D][tuya:379]: Datapoint 13 update to 0
[19:53:59.571][D][sensor:129]: ‘Remaining Available Energy’ >> 0.00 kW/h
[19:54:00.537][D][tuya:379]: Datapoint 15 update to 0
[19:54:00.548][D][sensor:129]: ‘Leakage Current’ >> 0 mA
[19:54:01.531][D][tuya:379]: Datapoint 104 update to 484
[19:54:01.554][D][tuya:379]: Datapoint 105 update to 500
[19:54:01.573][D][tuya:379]: Datapoint 116 update to 2349
[19:54:01.579][D][tuya:379]: Datapoint 117 update to 2570
[19:54:01.588][D][tuya:379]: Datapoint 118 update to 292

Please use this

sensor:

  • platform: tuya
    name: “Total Energy”
    device_class: energy
    sensor_datapoint: 1
    accuracy_decimals: 2
    unit_of_measurement: kWh
    state_class: total_increasing
    icon: “mdi:sine-wave”
    filters:

    • multiply: 0.01
  • platform: tuya
    name: “Frequency”
    device_class: energy
    sensor_datapoint: 105
    accuracy_decimals: 1
    unit_of_measurement: Hz
    state_class: measurement
    icon: “mdi:sine-wave”
    filters:

    • multiply: 0.1
  • platform: tuya
    name: “Power Factor”
    device_class: energy
    sensor_datapoint: 104
    accuracy_decimals: 0
    unit_of_measurement: COS φ
    state_class: measurement
    icon: “mdi:sine-wave”
    filters:

    • multiply: 0.1
  • platform: tuya
    name: “Voltage”
    device_class: voltage
    sensor_datapoint: 116
    accuracy_decimals: 1
    unit_of_measurement: V
    state_class: measurement
    icon: “mdi:lightning-bolt”
    filters:

    • multiply: 0.1
  • platform: tuya
    name: “Current”
    device_class: current
    sensor_datapoint: 117
    accuracy_decimals: 3
    unit_of_measurement: A
    state_class: measurement
    icon: “mdi:current-ac”
    filters:

    • multiply: 0.001
  • platform: tuya
    name: “Power”
    device_class: power
    sensor_datapoint: 118
    accuracy_decimals: 3
    unit_of_measurement: W
    state_class: measurement
    icon: “mdi:flash”
    filters:

    • multiply: 0.001

switch:

  • platform: “tuya”
    name: Switch
    id: switch_power
    switch_datapoint: 16

Regarding the data from
[21:09:24.556][D][tuya:379]: Datapoint 13 update to 0
[21:09:25.528][D][tuya:379]: Datapoint 15 update to 0
At the moment I don’t know for sure — one of them definitely indicates a leakage (similar to a residual current device). As for the other one, it’s not clear yet.

Here is what I have :
Not very elegant – Frost still happens occasionally… but less often…



globals:
  - id: last_power_update
    type: int
    restore_value: no
    initial_value: '0'



uart:
  baud_rate: 9600
  id: uart_tuya
  rx_pin: RX1
  tx_pin: TX1

tuya:
  uart_id: uart_tuya
  on_datapoint_update:
  - sensor_datapoint: 6
    datapoint_type: raw
    then:
      - lambda: |-
          ESP_LOGD("main", "on_datapoint_update %s", format_hex_pretty(x).c_str());
          id(voltage).publish_state((x[0] << 8 | x[1]) * 0.1);
          id(current).publish_state((x[3] << 8 | x[4]) * 0.001);
          id(power).publish_state((x[6] << 8 | x[7]) * 1);



switch:
  - platform: tuya
    switch_datapoint: 16
    name: "On"
  - platform: tuya
    switch_datapoint: 11
    name: "Switch prepayment"
  - platform: tuya
    switch_datapoint: 106
    name: "Refresh"
    id: refresh

time:
  - platform: homeassistant
    id: esptime

interval:
  - interval: 10s
    then:
      - lambda: |-
          auto now = id(esptime).now().timestamp;
          if (id(last_power_update) > 0 && (now - id(last_power_update)) > 30) {
            ESP_LOGW("watchdog", "⚠️ The power meter hasn't sent anything for over 30 seconds!");
            id(sensor_timeout_action).execute();
          }


script:
  - id: sensor_timeout_action
    then:
      - switch.turn_on: refresh
      - delay: 1s
      - switch.turn_off: refresh


sensor:

  ## Voltage 
  - platform: template
    id: voltage
    name: "Volt"
    unit_of_measurement: "V"
    icon: "mdi:sine-wave"
    accuracy_decimals: 1
    device_class: voltage
    filters: 
      - throttle: 
          seconds: 15
  
  - platform: tuya
    id: voltage_116
    sensor_datapoint: 116
    unit_of_measurement: "V"
    internal: True
    accuracy_decimals: 1
    filters:
      - multiply: 0.1 
    device_class: voltage
    on_value: 
      then:
      - lambda: |-
          id(voltage).publish_state(x);


  ## Current 
  - platform: template
    id: current
    name: "Curent"
    icon: "mdi:current-ac"
    unit_of_measurement: "A"
    accuracy_decimals: 2
    device_class: current
    filters: 
      - throttle: 
          seconds: 15

  - platform: tuya
    id: current_117
    sensor_datapoint: 117
    unit_of_measurement: "A"
    internal: True
    accuracy_decimals: 2
    filters:
      - multiply: 0.001
    device_class: current
    on_value: 
      then:
      - lambda: |-
          id(current).publish_state(x);


  ## Power
  - platform: template
    id: power
    name: "Power"
    icon: "mdi:flash"
    unit_of_measurement: "W"
    accuracy_decimals: 0
    device_class: power
    filters: 
      - throttle: 
          seconds: 15
    on_value: 
      then:
      - lambda: |-
          id(last_power_update) = id(esptime).now().timestamp;

  - platform: tuya
    id: power_118
    sensor_datapoint: 118
    unit_of_measurement: "W"
    internal: True
    accuracy_decimals: 0
    device_class: power
    on_value: 
      then:
      - lambda: |-
          id(power).publish_state(x);




  
  - platform: tuya
    id: power_factor
    name: "Power factor"
    sensor_datapoint: 104
    #unit_of_measurement: ""
    #icon: "mdi:flash"
    accuracy_decimals: 3
    device_class: power_factor
    filters:
      - multiply: 0.001
      - throttle: 
          seconds: 15

  - platform: tuya
    id: frequency
    name: "Frequency"
    sensor_datapoint: 105
    unit_of_measurement: "Hz"
    #icon: "mdi:flash"
    accuracy_decimals: 1
    device_class: frequency
    filters:
      - multiply: 0.1
      - throttle: 
          seconds: 15


  - platform: tuya
    name: "Total Energy"
    sensor_datapoint: 1
    unit_of_measurement: "kWh"
    accuracy_decimals: 2
    icon: "mdi:lightning-bolt"
    device_class: energy
    state_class: total_increasing
    filters:
      - multiply: 0.01  
      - throttle: 
          seconds: 15

  - platform: tuya
    name: "Leakage Current"
    sensor_datapoint: 15
    unit_of_measurement: "mA"
    accuracy_decimals: 0
    icon: "mdi:flash-alert"
    device_class: current
    filters: 
      - throttle: 
          seconds: 15