tuya energy monitor plug board: cb2s
Esphome code
substitutions:
devicename: tuya20a # ${devicename}
voltage_divider: "806.1586102719033"
current_resistor: "0.001067391066279705"
current_multiply: "0.4406190321602622"
esphome:
name: tuya20a
friendly_name: tuya-20a
bk72xx:
board: cb2s
framework:
version: dev
options:
LT_AUTO_DOWNLOAD_REBOOT: 0
status_led:
pin: P8 # P8 WifiLED //Синий светодиод
binary_sensor:
- platform: gpio
id: buttontuya20a
name: Button $devicename
pin:
number: P10 # кнопка P10 Btn (канал 1)
mode: INPUT_PULLUP
inverted: true
on_press:
- switch.toggle: relay
- platform: status
name: "$devicename Status"
switch:
- platform: gpio
id: relay
name: "${devicename} Relay"
pin: P26 # P26 Рел (канал 1)
- platform: restart
name: "${devicename} Restart"
##########################################################
sensor:
- platform: hlw8012
model: BL0937
current_resistor: ${current_resistor}
voltage_divider: ${voltage_divider}
sel_pin:
number: P24 # P24 BL0937SEL
inverted: True
cf_pin:
number: P7
inverted: True # P7 BL0937CF
cf1_pin:
number: P6
inverted: True # P6 BL0937CF1
current:
name: "${devicename} Current"
accuracy_decimals: 1
filters:
- multiply: ${current_multiply}
voltage:
name: "${devicename} Voltage"
#accuracy_decimals: 0
power:
name: "${devicename} Power"
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kW
energy:
name: "${devicename} Energy"
filters:
# Multiplication factor from Wh to kWh is 0.001
- multiply: 0.001
unit_of_measurement: kWh
update_interval: 8s
#voltage_divider: 1538
###########################################################
- platform: wifi_signal
name: "$devicename WiFi Signal"
update_interval: 60s
- platform: uptime
name: ${devicename} Uptime Sensor
id: tuya20a_sensor
update_interval: 30s
###########################################################
text_sensor:
- platform: libretiny
version:
name: LibreTiny Version $devicename
- platform: version
name: "${devicename} ESPHome Version"
- platform: wifi_info
ip_address:
name: "IP ${devicename}"
ssid:
name: "${devicename} ssid"
- platform: debug
reset_reason:
name: "${devicename} Reset Reason"