Issue with ESPHome cse7766 library and Sonoff POW Origin

I have a couple of Sonoff POW Origin (POWR316) devices and I flashed one of them with ESPHome, but I am unable to get the current monitoring part working. It seems like the data received from CSE7759B chip is in invalid format.

I am confused if this is the device issue or if I am doing anything wrong with the configuration. The power monitoring was working fine on the eWeLink app before flashing.

This is the configuration I am using

esp32:
  board: nodemcu-32s

logger:
  level: VERY_VERBOSE
  baud_rate: 0

web_server:
  port: 80

uart:
  rx_pin: GPIO16
  baud_rate: 4800
  debug:

sensor:
  - platform: cse7766
    update_interval: 30s
    current:
      name: ${device_name} Current
      id: a_sensor
    voltage:
      name: ${device_name} Voltage
      id: v_sensor
    power:
      name: ${device_name} Power
      id: w_sensor
    energy:
      name: ${device_name} Energy
      id: wh_sensor

This is the log output from ESPHome

[22:25:01][D][uart_debug:114]: <<< 02:A8:2A:A2:51:40:C8:07:1A:02:A8:2A:A2:51:40:C8:07:1A
[22:25:01][D][uart_debug:114]: <<< 02:A8:2A:A2:51:40:C8:07:1A:02:A8:2A:A2:51:40:C8:07:1A:89:DF
[22:25:01][D][uart_debug:114]: <<< 02:A8:2A:A2:51:40:C8:07:1A:89:DF
[22:25:01][D][uart_debug:114]: <<< 02:A8:2A:A2:7A:51:40:C8:07:1A:89:4F:02:A8:2A:A2:7A:51:40:C8:07:73:1A:89
[22:25:02][D][uart_debug:114]: <<< 02:A8:2A:A2:7A:51:40:C8:07:73:1A:89:02:A8:2A:A2:7A:51:40:C8:07:73:1A:8A:FD
[22:25:02][V][cse7766:048]: Invalid Header 2 Start: 0x02!
[22:25:02][V][cse7766:048]: Invalid Header 2 Start: 0x02!
[22:25:02][D][uart_debug:114]: <<< 02:A8:2A:A2:7A:51:40:C8:07:73:1A:8A:FD:02:A8:2A:A2:7A:51:40:C8:07:73:1A:8A:FD
[22:25:02][V][cse7766:048]: Invalid Header 2 Start: 0x02!
[22:25:02][V][cse7766:048]: Invalid Header 2 Start: 0x02!
[22:25:02][D][uart_debug:114]: <<< 02:A8:2A:A2:7A:51:40:C8:07:73:1A:8A:FD:02:A8:2A:A2:7A:51:40:C8:07:73:1A:FE
[22:25:02][V][cse7766:048]: Invalid Header 2 Start: 0x02!
[22:25:02][D][uart_debug:114]: <<< 02:A8:A2:7A:51:40:C8:07:73:1A:02:A8:A2:7A:51:40:C8:07:73:1A
[22:25:02][D][uart_debug:114]: <<< 02:A8:A2:7A:51:40:C8:07:7A:9E:1A:02:A8:A2:7A:51:40:C8:07:7A:9E:1A
[22:25:03][V][cse7766:048]: Invalid Header 2 Start: 0x02!
[22:25:03][D][uart_debug:114]: <<< 02:A8:A2:7A:51:40:C8:07:7A:9E:1A:8C:FD:02:A8:A2:7A:51:40:C8:07:7A:9E:1A:8C:FD
[22:25:03][V][cse7766:048]: Invalid Header 2 Start: 0x02!
[22:25:03][V][cse7766:048]: Invalid Header 2 Start: 0x02!
[22:25:03][D][uart_debug:114]: <<< 02:A8:A2:7A:51:40:C8:07:7A:9E:1A:8C:FD:02:A8:A2:7A:51:40:C8:07:7A:9E:1A:8C:FD

I seem to be experiencing the same issue with both the SONOFF POW Origin and Elite. These used to be working fine and some recent update has broken them, I also see in the logs:

[12:34:03][V][cse7766:048]: Invalid Header 2 Start: 0x51!
[12:34:03][V][cse7766:048]: Invalid Header 2 Start: 0x02!
[12:34:03][V][cse7766:048]: Invalid Header 2 Start: 0x51!
[12:34:03][V][cse7766:048]: Invalid Header 2 Start: 0x02!
[12:34:03][V][cse7766:048]: Invalid Header 2 Start: 0x51!

Similar config to OP.

I also have a number of POWR2s (which also use the CSE7786) and they are still working fine.

There is a thread on the issue here, along with a couple of work arounds:

https://github.com/esphome/issues/issues/4529

1 Like

Thank you for pointing me to the issue thread @benjycov really appreciate the help!

This workaround worked for me