I have issues with a Tuya devices running ESPHome.
SPM02-D2TW this is the WIFI model.
This device runs on a bk72xx CB2S.
I have no issues installing ESPHome on the device and it’s reporting correctly.
Until it randomly does’t.
After running for a while, sometimes up to two weeks without issues it starts to log invalid message checksum and nothing is geting updated/reported to Home Assistant.
[08:57:12][W][tuya:119]: Tuya Received invalid message checksum 07!=B5
[08:57:12][W][tuya:119]: Tuya Received invalid message checksum 00!=26
[08:57:12][W][tuya:119]: Tuya Received invalid message checksum 07!=88
[08:57:12][W][tuya:119]: Tuya Received invalid message checksum FD!=EA
I have added the reset button into ESPHome yaml so that I can restart it remotely
button:
- platform: restart
name: "Restart"
And restarting with this button will “fix” the issue until it starts reporting checksum errors again.
Also after reboot I will get the total energy that the device has logged while the ESPHome reported checksum errors.
That to me says that the Tuya MCU still does its thing.
And my energy dashboard gets messed up.
I do get the correct total energy used but it looks like I had a lot energy usage the hour I restarted the device. which sucks.
At the moment, I just added a automation to restart the device once a day, to avoid this, but would like to have a correct fix for this.
I feel like this is some type of memory leakage on ESPHome.
I tried some logger settings, where I set level to WARN
And also disable logger with baud_rate: 0 as the Tuya MCU uses the uart, maybe it could be issues there. but no positive result from those changes.
bk72xx:
board: cb2s
logger:
baud_rate: 0
level: WARN
captive_portal:
uart:
tx_pin: P11
rx_pin: P10
baud_rate: 9600
button:
- platform: restart
name: "Restart"
tuya:
sensor:
- platform: wifi_signal
name: "Signal Strength"
update_interval: 60s
internal: true
- platform: tuya
name: "Total Energy"
sensor_datapoint: 1
unit_of_measurement: "kWh"
device_class: "energy"
state_class: "total"
accuracy_decimals: 2
filters:
- multiply: 0.01
- platform: tuya
name: "Frequency"
sensor_datapoint: 101
unit_of_measurement: "Hz"
device_class: "frequency"
state_class: "measurement"
accuracy_decimals: 2
filters:
- multiply: 0.01
- platform: tuya
name: "L1 Voltage"
sensor_datapoint: 102
unit_of_measurement: "V"
device_class: "voltage"
state_class: "measurement"
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: tuya
name: "L2 Voltage"
sensor_datapoint: 105
unit_of_measurement: "V"
device_class: "voltage"
state_class: "measurement"
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: tuya
name: "L3 Voltage"
sensor_datapoint: 108
unit_of_measurement: "V"
device_class: "voltage"
state_class: "measurement"
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: tuya
name: "N Current"
sensor_datapoint: 2
unit_of_measurement: "A"
device_class: "current"
state_class: "measurement"
accuracy_decimals: 2
- platform: tuya
# this is powerfactor ?
name: "Power Factor"
sensor_datapoint: 15
device_class: "power_factor"
state_class: "measurement"
accuracy_decimals: 2
filters:
- multiply: 0.01
- platform: tuya
name: "L1 Current"
sensor_datapoint: 103
unit_of_measurement: "A"
device_class: "current"
state_class: "measurement"
accuracy_decimals: 3
filters:
- multiply: 0.001
- platform: tuya
name: "L2 Current"
sensor_datapoint: 106
unit_of_measurement: "A"
device_class: "current"
state_class: "measurement"
accuracy_decimals: 3
filters:
- multiply: 0.001
- platform: tuya
name: "L3 Current"
sensor_datapoint: 109
unit_of_measurement: "A"
device_class: "current"
state_class: "measurement"
accuracy_decimals: 3
filters:
- multiply: 0.001
- platform: tuya
name: "L1 Power"
sensor_datapoint: 104
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
- platform: tuya
name: "L2 Power"
sensor_datapoint: 107
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
- platform: tuya
name: "L3 Power"
sensor_datapoint: 110
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
- platform: tuya
name: "Total Power"
sensor_datapoint: 111
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
accuracy_decimals: 1