Alright, I think I got it working, properly. All thanks to @peterxian and his screenshot from Tasmota. Honestly, I wouldn’t have been able to decode the Tasmota template format into anything usable. This one screenshot saved my a**, so a big thank you!
The final config file will be at the bottom, but there are some things I’m not quite sure about.
First of all, the energy monitoring chip is really ADE7953, meaning I took the ESPhome config from there.
The one thing bothering me a bit is the Use with Shelly 2.5 section of the article, where it states a GPIO16 must be used in order for the device not to overheat. I know, this is not a Shelly 2.5, but I tried anyway. I was given an error, stating that GPIO16 cannot be used, due to its conflicting function. Probably a different ESP chip so … no harm done?
The other thing I’m worried about is the adc platform for the temperature reading as the compiler says it’s deprecated. See threads here and here. Neither of those, however, make any contributions to how to solve the issue. As long as it compiles, I’ll leave it there, but if you have a solution, I’m all ears.
So anyway, here’s the final config file as well as the HA screenshot.
All sensors, relays and switches behave as expected. Hope this helps someone in the future, or can be included in the ESPhome documentation.
esphome:
name: 1p-jidelna-vypinac-2
friendly_name: 1P Jídelna Vypínač 2
esp32:
board: esp32-c3-devkitm-1
flash_size: 8MB
framework:
type: esp-idf
version: recommended
sdkconfig_options:
COMPILER_OPTIMIZATION_SIZE: y
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "xxxxxxxxxxxxxxxxxxx"
ota:
- platform: esphome
password: "xxxxxxxxxxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "1P-Jidelna-Vypinac-2"
password: "xxxxxxxxxxx"
captive_portal:
i2c:
sda: GPIO6
scl: GPIO7
sensor:
- platform: ade7953_i2c
irq_pin: GPIO1
voltage:
name: "Voltage"
id: voltage
icon: mdi:alpha-v-circle-outline
device_class: voltage
frequency:
name: "Frequency"
id: frequency
accuracy_decimals: 2
icon: mdi:cosine-wave
device_class: frequency
current_a:
name: "Current A"
id: currenta
icon: mdi:alpha-a-circle-outline
device_class: current
current_b:
name: "Current B"
id: currentb
icon: mdi:alpha-a-circle-outline
device_class: current
active_power_a:
name: "Power A"
id: powera
icon: mdi:power
device_class: power
filters:
- multiply: -1
active_power_b:
name: "Power b"
id: powerb
icon: mdi:power
device_class: power
filters:
- multiply: -1
update_interval: 5s
# NTC Temperature
- platform: ntc
sensor: temp_resistance_reading
name: "Temperature"
calibration:
b_constant: 3350
reference_resistance: 10kOhm
reference_temperature: 298.15K
- platform: resistance
id: temp_resistance_reading
sensor: temp_analog_reading
configuration: DOWNSTREAM
resistor: 32kOhm
- platform: adc
id: temp_analog_reading
pin: 4
status_led:
pin:
number: 2
inverted: true
output:
- platform: gpio
id: "relay_output1"
pin: 5
- platform: gpio
id: "relay_output2"
pin: 3
switch:
- platform: output
id: "relay1"
name: "Relay1"
output: "relay_output1"
- platform: output
id: "relay2"
name: "Relay2"
output: "relay_output2"
binary_sensor:
- platform: gpio
name: "Switch 1"
pin: 18
filters:
- delayed_on_off: 50ms
- platform: gpio
name: "Switch 2"
pin: 10
filters:
- delayed_on_off: 50ms
- platform: gpio
name: "Button"
pin:
number: 19
inverted: yes
mode:
input: true
pullup: true
EDIT: Updated the pins to match properly. Device output and switch #1 correspond with values 1/A and #2 with 2/B.