Hello everyone,
This is my first post ever, I’ve been here for a long time, but just reading. After all this years I’ve learned a lot so I feel like I owe you this contribution, cuz I searched a lot and I found nothing so here you go, a configuration example of the new Sonoff POW Elite or POWR316D for ESPHome.
substitutions:
device_name: your_device_name
device_ip: your_device_ip
esphome:
name: ${device_name}
esp32:
board: nodemcu-32s
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: ${device_ip}
gateway: !secret wifi_gateway
subnet: 255.255.255.0
ap:
password: !secret wifi_password
captive_portal:
logger:
baud_rate: 0
api:
reboot_timeout: 15min
password: !secret api_key
encryption:
key: !secret api_key_cryp
ota:
password: !secret ota_password
uart:
rx_pin: GPIO16
baud_rate: 4800
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
- platform: wifi_signal
name: ${device_name} Wifi Signal Strength
update_interval: 60s
- platform: uptime
name: ${device_name} Uptime
binary_sensor:
- platform: gpio
pin: GPIO00
id: reset
internal: true
filters:
- invert:
- delayed_off: 10ms
on_click:
- max_length: 350ms # short press to toggle the relay
then:
switch.toggle: relay_1
- min_length: 360ms # long press to cycle display info
max_length: 3s
then:
- if:
condition:
binary_sensor.is_on: page
then:
binary_sensor.template.publish:
id: page
state: OFF
else:
binary_sensor.template.publish:
id: page
state: ON
- platform: template # this is a fake sensor to tell the screen which info to show on display
name: "Display page"
id: page
publish_initial_state: true
internal: true
display:
platform: tm1621
id: tm1621_display
update_interval: 1s
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: GPIO18
switch:
- platform: gpio
name: ${device_name}_switch
icon: "mdi:light-switch-off"
pin: GPIO13
id: relay_1
restore_mode: restore_default_off
on_turn_on:
light.turn_off: switch_led
on_turn_off:
light.turn_on: switch_led
status_led:
pin:
number: GPIO05
inverted: True
light:
- platform: monochromatic
name: ${device_name}_switch_led
id: switch_led
output: led
internal: true
restore_mode: restore_default_off
I’m not a programmer or anything, just a geek so you are invited to improve my code.
Regards!