- 积分
- 318
- 金钱
- 251
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
中级会员
- 积分
- 318
- 金钱
- 251
- HASS币
- 0
|
发表于 2021-10-1 20:23:52
|
显示全部楼层
本帖最后由 3038922 于 2021-10-1 20:31 编辑
我改了下 想挂6个.结果读不到数据的.也不知道为啥.
用上位机测试004T正常的.我地址也设置了
我测试时候 是挂了一个.我看您地址是4开始的.我测试的那个是默认地址1.地址1是不是没法用的?
```
substitutions:
device_name: energy
esphome:
name: ${device_name}
platform: ESP8266
board: nodemcuv2
logger:
baud_rate: 0 # (UART logging interferes with pzem)
level: DEBUG
# Enable Home Assistant API
web_server:
port: 80
captive_portal:
uart:
- tx_pin: D1
rx_pin: D2
baud_rate: 9600
stop_bits: 1
modbus:
binary_sensor:
- platform: status
name: "${device_name} Status"
sensor:
- platform: pzemac
id: pzemac1
energy:
name: "energy_ac1"
filters:
- multiply: 0.002
unit_of_measurement: kWh
accuracy_decimals: 1
current:
name: "current_ac1"
id: "current_ac1"
accuracy_decimals: 1
voltage:
name: "voltage_ac1"
filters:
- multiply: 2
accuracy_decimals: 1
frequency:
name: "frequency_ac1"
accuracy_decimals: 1
power_factor:
name: "factor_ac1"
accuracy_decimals: 1
power:
name: "power_ac1"
id: "power_ac1"
filters:
- multiply: 2
accuracy_decimals: 0
update_interval: never
address: 1
- platform: pzemac
id: pzemac2
energy:
name: "energy_ac2"
filters:
- multiply: 0.002
unit_of_measurement: kWh
accuracy_decimals: 1
current:
name: "current_ac2"
id: "current_ac2"
accuracy_decimals: 1
voltage:
name: "voltage_ac2"
filters:
- multiply: 2
accuracy_decimals: 1
frequency:
name: "frequency_ac2"
accuracy_decimals: 1
power_factor:
name: "factor_ac2"
accuracy_decimals: 1
power:
name: "power_ac2"
id: "power_ac2"
filters:
- multiply: 2
accuracy_decimals: 0
update_interval: never
address: 2
- platform: pzemac
id: pzemac3
energy:
name: "energy_ac3"
filters:
- multiply: 0.002
unit_of_measurement: kWh
accuracy_decimals: 1
current:
id: "current_ac3"
name: "current_ac3"
accuracy_decimals: 1
voltage:
name: "voltage_ac3"
filters:
- multiply: 2
accuracy_decimals: 1
frequency:
name: "frequency_ac3"
accuracy_decimals: 1
power_factor:
name: "factor_ac3"
accuracy_decimals: 1
power:
name: "power_ac3"
id: "power_ac3"
filters:
- multiply: 2
accuracy_decimals: 0
update_interval: never
address: 3
- platform: total_daily_energy
name: "energy_ac1_daily"
power_id: power_ac1
id: energy_ac1_daily
unit_of_measurement: kWh
accuracy_decimals: 1
icon: mdi:counter
filters:
- multiply: 0.001
- platform: total_daily_energy
name: "energy_ac2_daily"
power_id: power_ac2
id: energy_ac2_daily
unit_of_measurement: kWh
accuracy_decimals: 1
icon: mdi:counter
filters:
- multiply: 0.001
- platform: total_daily_energy
name: "energy_ac3_daily"
power_id: power_ac3
id: energy_ac3_daily
unit_of_measurement: kWh
accuracy_decimals: 1
icon: mdi:counter
filters:
- multiply: 0.001
- platform: template
name: "today_ac13"
id: "today_ac13"
icon: mdi:counter
device_class: energy
state_class: measurement
unit_of_measurement: kWh
accuracy_decimals: 1
lambda: |-
return id(energy_ac1_daily).state + id(energy_ac2_daily).state + id(energy_ac3_daily).state ;
########################################################################################################################
- platform: pzemac
id: pzemac4
energy:
name: "energy_ac4"
filters:
- multiply: 0.002
unit_of_measurement: kWh
accuracy_decimals: 1
current:
name: "current_ac4"
id: "current_ac4"
accuracy_decimals: 1
voltage:
name: "voltage_ac4"
filters:
- multiply: 2
accuracy_decimals: 1
frequency:
name: "frequency_ac4"
accuracy_decimals: 1
power_factor:
name: "factor_ac4"
accuracy_decimals: 1
power:
name: "power_ac4"
id: "power_ac4"
filters:
- multiply: 2
accuracy_decimals: 0
update_interval: never
address: 4
- platform: pzemac
id: pzemac5
energy:
name: "energy_ac5"
filters:
- multiply: 0.002
unit_of_measurement: kWh
accuracy_decimals: 1
current:
name: "current_ac5"
id: "current_ac5"
accuracy_decimals: 1
voltage:
name: "voltage_ac5"
filters:
- multiply: 2
accuracy_decimals: 1
frequency:
name: "frequency_ac5"
accuracy_decimals: 1
power_factor:
name: "factor_ac5"
accuracy_decimals: 1
power:
name: "power_ac5"
id: "power_ac5"
filters:
- multiply: 2
accuracy_decimals: 0
update_interval: never
address: 5
- platform: pzemac
id: pzemac6
energy:
name: "energy_ac6"
filters:
- multiply: 0.002
unit_of_measurement: kWh
accuracy_decimals: 1
current:
id: "current_ac6"
name: "current_ac6"
accuracy_decimals: 1
voltage:
name: "voltage_ac6"
filters:
- multiply: 2
accuracy_decimals: 1
frequency:
name: "frequency_ac6"
accuracy_decimals: 1
power_factor:
name: "factor_ac6"
accuracy_decimals: 1
power:
name: "power_ac6"
id: "power_ac6"
filters:
- multiply: 2
accuracy_decimals: 0
update_interval: never
address: 6
- platform: total_daily_energy
name: "energy_ac4_daily"
power_id: power_ac4
id: energy_ac4_daily
unit_of_measurement: kWh
accuracy_decimals: 1
icon: mdi:counter
filters:
- multiply: 0.001
- platform: total_daily_energy
name: "energy_ac5_daily"
power_id: power_ac5
id: energy_ac5_daily
unit_of_measurement: kWh
accuracy_decimals: 1
icon: mdi:counter
filters:
- multiply: 0.001
- platform: total_daily_energy
name: "energy_ac6_daily"
power_id: power_ac6
id: energy_ac6_daily
unit_of_measurement: kWh
accuracy_decimals: 1
icon: mdi:counter
filters:
- multiply: 0.001
- platform: template
name: "today_ac46"
id: "today_ac46"
icon: mdi:counter
device_class: energy
state_class: measurement
unit_of_measurement: kWh
accuracy_decimals: 1
lambda: |-
return id(energy_ac4_daily).state + id(energy_ac5_daily).state + id(energy_ac6_daily).state ;
#################################
#SLOW SENSORS FOR HOME ASSISTANT#
#################################
- platform: template #########################
name: "current_ac1_slow"
lambda: |-
if (id(current_ac1).state) {
return (id(current_ac1).state);
} else {
return 0;
}
unit_of_measurement: A
icon: "mdi:alpha-a-circle"
update_interval: 60s
- platform: template #########################
name: "current_ac2_slow"
lambda: |-
if (id(current_ac2).state) {
return (id(current_ac2).state);
} else {
return 0;
}
unit_of_measurement: A
icon: "mdi:alpha-a-circle"
update_interval: 60s
- platform: template #########################
name: "current_ac3_slow"
lambda: |-
if (id(current_ac3).state) {
return (id(current_ac3).state);
} else {
return 0;
}
- platform: template #########################
name: "current_ac4_slow"
lambda: |-
if (id(current_ac4).state) {
return (id(current_ac4).state);
} else {
return 0;
}
unit_of_measurement: A
icon: "mdi:alpha-a-circle"
update_interval: 60s
- platform: template #########################
name: "current_ac5_slow"
lambda: |-
if (id(current_ac5).state) {
return (id(current_ac5).state);
} else {
return 0;
}
unit_of_measurement: A
icon: "mdi:alpha-a-circle"
update_interval: 60s
- platform: template #########################
name: "current_ac6_slow"
lambda: |-
if (id(current_ac6).state) {
return (id(current_ac6).state);
} else {
return 0;
}
unit_of_measurement: A
icon: "mdi:alpha-a-circle"
update_interval: 60s
time:
- platform: homeassistant
id: homeassistant_time
switch:
- platform: restart
name: "${device_name}_Restart"
- platform: uart
name: "${device_name}_Reset"
data: [0x01, 0x42, 0x80, 0x11]
interval:
- interval: 5s
then:
- lambda: "id(pzemac1).update();"
- delay: 150ms
- lambda: "id(pzemac2).update();"
- delay: 150ms
- lambda: "id(pzemac3).update();"
- delay: 150ms
- lambda: "id(pzemac4).update();"
- delay: 150ms
- lambda: "id(pzemac5).update();"
- delay: 150ms
- lambda: "id(pzemac6).update();"
```
|
|