感谢楼主的插件,很好用,以前用的esphome接入,现在用插件更好了。
在这里斗胆分享一下自己的配置文件,帮助需要的人。
第一个是完全的esphome导入,没有用楼主的集成(我已经没有使用了),第二个是利用esphome第三方的透传,可以配合楼主的集成,完美!我个人往上面挂了个bmp280传感器,
没有的删除i2c配置即可。
esphome:
name: pzem-004t-v3-bmp280-esp-zhilian
platform: ESP8266
board: nodemcuv2
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "75ecb9cee9717d0da9b5e830bece8ef2"
web_server:
port: 80
wifi:
ssid: "Test"
password: "11223300"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Pzem-004T-V3 Fallback Hotspot"
password: "rkjSXhhvx4rL"
captive_portal:
i2c:
sda: 4
scl: 5
scan: true
id: bus_a
uart:
id: uart_bus
rx_pin: D6
tx_pin: D5
baud_rate: 9600
stop_bits: 1
time:
- platform: homeassistant
timezone: Asia/Shanghai
id: time1
switch:
- platform: gpio
name: "Chip ights"
pin: GPIO2
- platform: restart
name: "Living Room Restart"
- platform: gpio
pin: GPIO16
name: "Board lights"
- platform: uart
uart_id: uart_bus
name: "Reset data"
data: [0x01, 0x42, 0x80, 0x11]
text_sensor:
- platform: wifi_info
ip_address:
name: "ESP IP Address"
ssid:
name: "ESP Connected SSID"
mac_address:
name: "ESP Mac Wifi Address"
- platform: template
name: Uptime Human Readable
id: uptime_human
icon: mdi:clock-start
sensor:
- platform: pzemac
current:
name: "IN_current"
id: IN_current
voltage:
name: "IN_voltage"
id: IN_voltage
energy:
name: "IN_energy"
filters:
- lambda: return x /1000;
unit_of_measurement: "kWh"
power:
name: "IN_power"
id: IN_power
frequency:
name: "IN_Fr"
id: IN_Fr
power_factor:
name: "IN_PF"
id: IN_PF
update_interval: 10s
- platform: adc
pin: VCC
name: "VCC Voltage"
- platform: wifi_signal
name: "WiFi Signal Sensor"
- platform: uptime
name: Uptime Sensor
id: uptime_sensor
update_interval: 60s
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? String(days) + "d " : "") +
(hours ? String(hours) + "h " : "") +
(minutes ? String(minutes) + "m " : "") +
(String(seconds) + "s")
).c_str();
- platform: bmp280
i2c_id: bus_a
address: 0x76
temperature:
name: "BMP280 Temperature"
id: bmp280_temperature
oversampling: 16x
pressure:
name: "BMP280 Pressure"
id: bmp280_pressure
update_interval: 5s
- platform: template
name: "Altitude"
lambda: |-
const float STANDARD_SEA_LEVEL_PRESSURE = 1013.25; //in hPa, see note
return ((id(bmp280_temperature).state + 273.15) / 0.0065) *
(powf((STANDARD_SEA_LEVEL_PRESSURE / id(bmp280_pressure).state), 0.190234) - 1); // in meter
update_interval: 15s
icon: 'mdi:signal'
unit_of_measurement: 'm'
esphome:
name: pzem-004t-v3-bmp280-stream-server
platform: ESP8266
board: nodemcuv2
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "75ecb9cee9717d0da9b5e830bece8ef2"
wifi:
ssid: "Test"
password: "11223300"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Pzem-004T-V3"
password: "11223300"
captive_portal:
external_components:
- source: github://oxan/esphome-stream-server
stream_server:
uart_id: pzem
port: 1234
uart:
id: pzem
rx_pin: D7
tx_pin: D6
baud_rate: 9600
stop_bits: 1
i2c:
sda: 4
scl: 5
scan: true
id: bus_a
time:
- platform: homeassistant
timezone: Asia/Shanghai
id: time1
switch:
- platform: gpio
name: "Chip ights"
pin: GPIO2
- platform: restart
name: "Living Room Restart"
- platform: gpio
pin: GPIO16
name: "Board lights"
text_sensor:
- platform: wifi_info
ip_address:
name: "ESP IP Address"
- platform: template
name: Uptime Human Readable
id: uptime_human
icon: mdi:clock-start
light:
- platform: fastled_clockless
chipset: WS2811
pin: GPIO14
num_leds: 60
rgb_order: BRG
name: "FastLED WS2811 Light"
sensor:
- platform: wifi_signal
name: "WiFi Signal Sensor"
- platform: uptime
name: Uptime Sensor
id: uptime_sensor
update_interval: 60s
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? String(days) + "天" : "") +
(hours ? String(hours) + "时" : "") +
(minutes ? String(minutes) + "分" : "") +
(String(seconds) + "秒")
).c_str();
- platform: bmp280
i2c_id: bus_a
address: 0x76
temperature:
name: "BMP280 Temperature"
id: bmp280_temperature
oversampling: 16x
pressure:
name: "BMP280 Pressure"
id: bmp280_pressure
update_interval: 5s
- platform: template
name: "Altitude"
lambda: |-
const float STANDARD_SEA_LEVEL_PRESSURE = 1013.25; //in hPa, see note
return ((id(bmp280_temperature).state + 273.15) / 0.0065) *
(powf((STANDARD_SEA_LEVEL_PRESSURE / id(bmp280_pressure).state), 0.190234) - 1); // in meter
update_interval: 15s
icon: 'mdi:signal'
unit_of_measurement: 'm'
|