work by Tuya app remote monitor by internet.
how to order tuya license see here:
https://www.kincony.com/forum/showthread.php?tid=2544
upload zmpt101b folder to your home assistant folder as this:
zmpt101b.zip (Size: 1.8 KB / Downloads: 251)
ymal file download:
m16v2.zip (Size: 2.18 KB / Downloads: 383)
Code:
substitutions:
name: m16v2
zmpt101b_sensitivity: "533.75"
esphome:
name: ${name}
friendly_name: ${name}
includes:
- zmpt101b/ZMPT101B.h
- zmpt101b/ZMPT101B.cpp
- zmpt101b/zmpt101b_custom_sensor.h
external_components:
# - source:
# type: local
# path: my_components/esphome-tuya-iot/components
- source:
type: git
url: https://github.com/hzkincony/esphome-tuya-iot
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "bw/rPHdwHVn/1VcrLR3klCXs3KieOgLLzS5lr4uXAMI="
ota:
password: "bd01aad7e00d3e47eaff147d8e37b6de"
tuya_iot:
id: tuya_iot_component
product_id: trt1ssh9tckaoxof
device_id: 26d09e3ccf9314f1eblodu
device_secret: hzwwkVtJG3GvJzff
# how to order tuya license please check with KinCony's forum
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO17_OUT
phy_addr: 0
i2c:
sda: 4
scl: 5
scan: true
id: bus_a
cd74hc4067:
- id: cd74hc4067_1
pin_s0: 32
pin_s1: 33
pin_s2: 13
pin_s3: 16
web_server:
port: 80
font:
- file: "gfonts://Roboto"
id: roboto
size: 20
binary_sensor:
- platform: gpio
id: display_btn
pin:
number: 0
mode: INPUT_PULLUP
inverted: True
on_press:
then:
- lambda: |-
static int display_voltage = 0;
display_voltage = (display_voltage + 1) % 3;
id(display_voltage_id).publish_state(display_voltage);
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
address: 0x3C
lambda: |-
it.printf(0, 0, id(roboto), "T: %.1f°C", id(temperature).state);
it.printf(0, 20, id(roboto), "H: %.1f%%", id(humidity).state);
if (id(display_voltage_id).state == 0)
it.printf(0, 40, id(roboto), "AC1:%.1fV", id(voltage_1).state);
else if (id(display_voltage_id).state == 1)
it.printf(0, 40, id(roboto), "AC2:%.1fV", id(voltage_2).state);
else
it.printf(0, 40, id(roboto), "AC3:%.1fV", id(voltage_3).state);
# Example configuration entry
sensor:
- platform: template
name: "Display Voltage ID"
id: display_voltage_id
accuracy_decimals: 0
update_interval: never
- platform: custom
lambda: |-
auto my_sensor34 = new ZMPT101BSensor(34, ${zmpt101b_sensitivity});
auto my_sensor36 = new ZMPT101BSensor(36, ${zmpt101b_sensitivity});
auto my_sensor39 = new ZMPT101BSensor(39, ${zmpt101b_sensitivity});
App.register_component(my_sensor34);
App.register_component(my_sensor36);
App.register_component(my_sensor39);
return {my_sensor34, my_sensor36, my_sensor39};
sensors:
- name: "m16v2-voltage-1"
id: voltage_1
unit_of_measurement: V
accuracy_decimals: 1
state_class: "measurement"
- name: "m16v2-voltage-2"
id: voltage_2
unit_of_measurement: V
accuracy_decimals: 1
state_class: "measurement"
- name: "m16v2-voltage-3"
id: voltage_3
unit_of_measurement: V
accuracy_decimals: 1
state_class: "measurement"
- platform: sht3xd
temperature:
name: "sht Temperature"
id: temperature
humidity:
name: "sht Humidity"
id: humidity
address: 0x44
update_interval: 10s
- platform: adc
pin: 35
id: adc35
update_interval: never
attenuation: 11db
- platform: cd74hc4067
id: ai1
number: 0
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai2
number: 1
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai3
number: 2
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai4
number: 3
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai5
number: 4
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai6
number: 5
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai7
number: 6
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai8
number: 7
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai9
number: 8
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai10
number: 9
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai11
number: 10
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai12
number: 11
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai13
number: 12
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai14
number: 13
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai15
number: 14
sensor: adc35
update_interval: 60s
- platform: cd74hc4067
id: ai16
number: 15
sensor: adc35
update_interval: 60s
- platform: ct_clamp
sensor: ai1
id: Measured_Current_1
name: "m16v2-current-1"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0.0034 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: template
id: power1
name: "power1"
lambda: return id(Measured_Current_1).state * id(voltage_1).state;
device_class: power
unit_of_measurement: 'W'
update_interval: 60s
- platform: total_daily_energy
name: "Total Daily Energy1"
power_id: power1
filters:
- multiply: 0.001
unit_of_measurement: kWh
accuracy_decimals: 3
icon: mdi:clock-alert
device_class: energy
- platform: ct_clamp
sensor: ai2
id: Measured_Current_2
name: "m16v2-current-2"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: ct_clamp
sensor: ai3
id: Measured_Current_3
name: "m16v2-current-3"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: ct_clamp
sensor: ai4
id: Measured_Current_4
name: "m16v2-current-4"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: ct_clamp
sensor: ai5
id: Measured_Current_5
name: "m16v2-current-5"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: ct_clamp
sensor: ai6
id: Measured_Current_6
name: "m16v2-current-6"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: ct_clamp
sensor: ai7
id: Measured_Current_7
name: "m16v2-current-7"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: ct_clamp
sensor: ai8
id: Measured_Current_8
name: "m16v2-current-8"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: ct_clamp
sensor: ai9
id: Measured_Current_9
name: "m16v2-current-9"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: ct_clamp
sensor: ai10
id: Measured_Current_10
name: "m16v2-current-10"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: ct_clamp
sensor: ai11
id: Measured_Current_11
name: "m16v2-current-11"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: ct_clamp
sensor: ai12
id: Measured_Current_12
name: "m16v2-current-12"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: ct_clamp
sensor: ai13
id: Measured_Current_13
name: "m16v2-current-13"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: ct_clamp
sensor: ai14
id: Measured_Current_14
name: "m16v2-current-14"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: ct_clamp
sensor: ai15
id: Measured_Current_15
name: "m16v2-current-15"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
- platform: ct_clamp
sensor: ai16
id: Measured_Current_16
name: "m16v2-current-16"
update_interval: 60s
filters:
- calibrate_linear:
# Measured value of 0 maps to 0A
- 0 -> 0
# Known load: 4.0A
# Value shown in logs: 0.1333A
- 0.31749 -> 8.95608
interval:
- interval: 15s
then:
- lambda: !lambda |-
id(tuya_iot_component).property_report("voltage_1", id(voltage_1).state);
id(tuya_iot_component).property_report("voltage_2", id(voltage_2).state);
id(tuya_iot_component).property_report("voltage_3", id(voltage_3).state);
id(tuya_iot_component).property_report("temperature", id(temperature).state);
id(tuya_iot_component).property_report("humidity", id(humidity).state);
id(tuya_iot_component).property_report("measured_current_1", id(Measured_Current_1).state);
id(tuya_iot_component).property_report("measured_current_2", id(Measured_Current_2).state);
id(tuya_iot_component).property_report("measured_current_3", id(Measured_Current_3).state);
id(tuya_iot_component).property_report("measured_current_4", id(Measured_Current_4).state);
id(tuya_iot_component).property_report("measured_current_5", id(Measured_Current_5).state);
id(tuya_iot_component).property_report("measured_current_6", id(Measured_Current_6).state);
id(tuya_iot_component).property_report("measured_current_7", id(Measured_Current_7).state);
id(tuya_iot_component).property_report("measured_current_8", id(Measured_Current_8).state);
id(tuya_iot_component).property_report("measured_current_9", id(Measured_Current_9).state);
id(tuya_iot_component).property_report("measured_current_10", id(Measured_Current_10).state);
id(tuya_iot_component).property_report("measured_current_11", id(Measured_Current_11).state);
id(tuya_iot_component).property_report("measured_current_12", id(Measured_Current_12).state);
id(tuya_iot_component).property_report("measured_current_13", id(Measured_Current_13).state);
id(tuya_iot_component).property_report("measured_current_14", id(Measured_Current_14).state);
id(tuya_iot_component).property_report("measured_current_15", id(Measured_Current_15).state);
id(tuya_iot_component).property_report("measured_current_16", id(Measured_Current_16).state);
time:
- platform: sntp
id: my_time
- platform: homeassistant
id: homeassistant_time