So I finally got hold of 2 of these switches (for the pool pump and geyser)
Now between this post and the official ESPhome example Sonoff POW Elite 20a (POWR320D) | ESPHome-Devices I got the switch working fine. However I’m not getting any readings on the power sensors (power current voltage energy) all reading “unknown”
I have another sonoff pow2 which shows everything fine and the have supposedly the same cse7766 sensor.
Any idea from anyone?
Here is my config
substitutions:
friendly_name: Pool Pump
device_name: sonoff-pow-elite-pool-pump
esphome:
name: $device_name
esp32:
board: nodemcu-32s
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: $device_name
password: !secret wifi_failover
captive_portal:
api:
ota:
logger:
baud_rate: 0
uart:
rx_pin: RX
baud_rate: 4800
time:
- platform: homeassistant
id: homeassistant_time
sensor:
- platform: cse7766
update_interval: 2s
current:
name: $friendly_name Current
id: a_sensor
voltage:
name: $friendly_name Voltage
id: v_sensor
power:
name: $friendly_name Power
id: w_sensor
energy:
name: $friendly_name Energy
id: wh_sensor
- platform: total_daily_energy
name: $friendly_name Total Daily Energy
power_id: w_sensor
- platform: wifi_signal
name: $friendly_name Wifi RSSI
update_interval: 60s
binary_sensor:
- platform: status
name: $friendly_name Status
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
id: button_1
on_press:
then:
- switch.toggle: relay_1
- platform: template # this is a fake sensor to tell the screen which info to show on display
id: page
publish_initial_state: true
internal: true
display:
platform: tm1621
id: tm1621_display
cs_pin: GPIO25
data_pin: GPIO14
read_pin: GPIO26
write_pin: GPIO27
lambda: |-
if (id(page).state) {
it.display_voltage(true);
it.display_kwh(false);
it.printf(0, "%.1f", id(v_sensor).state);
it.printf(1, "%.1f", id(a_sensor).state);
} else {
it.display_voltage(false);
it.display_kwh(true);
it.printf(0, "%.1f", id(wh_sensor).state);
it.printf(1, "%.1f", id(w_sensor).state);
}
output:
- platform: ledc
id: led
pin:
number: GPIO18
inverted: True
switch:
- platform: template
name: $friendly_name
optimistic: true
id: relay_1
lambda: |-
if (isnan(id(w_sensor).state)) {
return {};
} else if (id(w_sensor).state > 4) {
// Running
return true;
} else {
// Not running
return false;
}
turn_off_action:
- switch.turn_on: relay_off
turn_on_action:
- switch.turn_on: relay_on
- platform: gpio
restore_mode: ALWAYS_ON
internal: true
id: relay_off
pin: GPIO04
on_turn_on:
- delay: 500ms
- switch.turn_off: relay_off #bi-stable relay so no need to keep on.
- light.turn_off: switch_led
interlock: [relay_on]
- platform: gpio
restore_mode: ALWAYS_OFF
internal: true
id: relay_on
pin: GPIO02
on_turn_on:
- delay: 500ms
- switch.turn_off: relay_on #bi-stable relay so no need to keep on.
- light.turn_on: switch_led
interlock: [relay_off]
- platform: restart
name: $friendly_name Restart
light:
- platform: monochromatic
id: switch_led
output: led
internal: True
- platform: status_led
id: wifi_status_led
internal: True
pin:
number: GPIO05
inverted: True
interval:
- interval: 30s
then:
if:
condition:
wifi.connected:
then:
- light.turn_on: wifi_status_led
else:
- light.turn_off: wifi_status_led
@fstof I’ve recently posted a problem with the POWR320D and the example you post, with the switch not working, but readings seems to work OK, not solved yet…
Try tasmota to see if all is working fine, i don’t think is a diferent sensor…
Below you have the link to tasmota. You only have to download the tasmota32.bin, upload to POWR320D, reboot, connect to the new SSID go to http://192.168.4.1 config your ssid, and finally choose powr320d template from the list. You can see all values on the web without configure anything of mqtt
This is how i solved this part. You don’t need the lambda part… Now also working without load. (sorry don’t know how to publich the data in the way You people do
Hi, you can go back to the original sonoff firmware via serial, but only if you have a backup from the original firmware. I have no problem with the status… Try with tasmota firmware, if you select he correct model all will run out of the box
I tried every trick in the book and then some.
My recently bought sonoff powr320D works fine with tasmota but not is esphome.
I tried even the basic CSE7766 Power Sensor examples. Esphome 2023.5.5 CSE7766 platform doen’t respond at all. It gives no readings. Not even in logs. I checked the chip on the PCB and it is the CSE7759B-SO.
Maybe CSE7766 platform it is not working properly with this chip?
Does anybody have any suggestions?
Hello, after debug uart on powr316 & reading CSE7766 datasheet, i add the line “parity: even” on uart config . Now i can view every electrical data. perhaps it can help you ?
I don’t know the rational behind the code but there is a serious problem with it.
If there is no current flowing you cannot turn off the relay. In my use case I am using this to switch on an immersion heater. If the immersion heather thermostat cuts power to the heater you cannot turn off the relay supplying power to the immersion heater.
I have updated the ESP code to comment out the Lamda code as other have done and now have proper control over the relay state.
Hello guys, it’s been a year since I posted my config file, and I had to revisit it cuz I updated the EspHome version of the device and I lost all readings and I thought I could use my original post as a backup config, but was even better, chris1313 on post 25 solved it.
Apparently now you can find the config file on esphome website but google seems to like this post so here goes my updated config file with chris1313 solution and beaj improvement: