PZEM-004T - detect electrysyty failure
- Dominant language
- No language data
- Stars
- 313
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
### The problem
If there is no power to the high-voltage part of the PZEM-004T, it does not output anything, but the platform has processed that if there is nothing, the values do not change. Electrysyty failure cannot be tracked.
I suggest making the following changes to pzemac.cpp:
void PZEMAC::on_modbus_data(const std::vector &data) {
if (data.size() < 20) {
ESP_LOGW(TAG, "Invalid size for PZEM AC!");
// start add
this->voltage_sensor_->publish_state(0);
this->current_sensor_->publish_state(0);
this->power_sensor_->publish_state(0);
this->frequency_sensor_->publish_state(0);
this->power_factor_sensor_->publish_state(0);
//stop add
return;
}
...

Anern Grid Voltage - Hybrid Solar Inverter
Energy Monitoring External Voltage - PZEM004T
### Which version of ESPHome has the issue?
2023.12.7
### What type of installation are you using?
Home Assistant Add-on
### Which version of Home Assistant has the issue?
2024.1.3
### What platform are you using?
ESP8266
### Board
d1_mini
### Component causing the issue
PZEM-004T v3
### Example YAML snippet
_No response_
### Anything in the logs that might be useful for us?
_No response_
### Additional information
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.