Hi All,
I purchased one of these din rail energy meters with the Tuya MCU and ESP8266 inside, and couldn’t find any good or full examples of an ESPHome yaml config for them. I found some guides for tasmota, like this one (good guild for flashing), but I thought it would be worth sharing my config so others don’t need to figure it out.
After compiling the config, I flashed with tasmotizer with no issues. Hope it helps someone out.
MQTT bit is optional, i use it as i have a separate server running emoncms for my energy devices.
substitutions:
device_name: energy_meter
friendly_name: "Car Energy Meter"
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
wifi:
ssid: !secret wifissid
password: !secret wifipassword
ap:
ssid: ${friendly_name}
password: !secret esphome_admin_password
captive_portal:
logger:
baud_rate: 0
api:
ota:
mqtt:
broker: !secret mqtt_ip
username: !secret mqtt_username
password: !secret mqtt_password
topic_prefix: emon/${device_name}
uart:
rx_pin: GPIO3
tx_pin: GPIO1
baud_rate: 9600
tuya:
switch:
- platform: "tuya"
name: "${friendly_name} Switch"
id: power
switch_datapoint: 1
binary_sensor:
- platform: gpio
pin: 16
id: button
on_press:
then:
- switch.toggle: power
sensor:
- platform: "tuya"
name: "${friendly_name} Current"
sensor_datapoint: 18
accuracy_decimals: 2
unit_of_measurement: "A"
icon: "mdi:flash"
filters:
- multiply: 0.001
- platform: "tuya"
name: "${friendly_name} Power"
sensor_datapoint: 19
accuracy_decimals: 1
unit_of_measurement: "W"
icon: "mdi:flash"
filters:
- multiply: 0.1
- platform: "tuya"
name: "${friendly_name} Voltage"
sensor_datapoint: 20
unit_of_measurement: "V"
accuracy_decimals: 1
icon: "mdi:flash"
filters:
- multiply: 0.1
- platform: "tuya"
name: "${friendly_name} kWh +"
sensor_datapoint: 101
unit_of_measurement: "kWh"
accuracy_decimals: 3
icon: "mdi:flash"
filters:
- multiply: 0.01
- platform: "tuya"
name: "${friendly_name} kWh -"
sensor_datapoint: 9
unit_of_measurement: "kWh"
accuracy_decimals: 3
icon: "mdi:flash"
filters:
- multiply: 0.01