mirror of https://github.com/esphome/esphome.git
fix: growatt_solar make warm_up_time configurable
This commit is contained in:
parent
31e08f7a94
commit
f61ba71573
|
@ -28,9 +28,9 @@ void GrowattSolar::update() {
|
|||
this->waiting_to_update_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Ignore when device uptime is too low, preventing invalid readouts during inverter boot cycle
|
||||
if (millis() < 30000)
|
||||
if (this->warm_up_time_ * 1000 > millis())
|
||||
return;
|
||||
|
||||
this->waiting_to_update_ = false;
|
||||
|
|
|
@ -26,6 +26,8 @@ class GrowattSolar : public PollingComponent, public modbus::ModbusDevice {
|
|||
|
||||
void set_protocol_version(GrowattProtocolVersion protocol_version) { this->protocol_version_ = protocol_version; }
|
||||
|
||||
void set_warm_up_time(uint8_t warm_up_time) { this->warm_up_time_ = warm_up_time; }
|
||||
|
||||
void set_inverter_status_sensor(sensor::Sensor *sensor) { this->inverter_status_ = sensor; }
|
||||
|
||||
void set_grid_frequency_sensor(sensor::Sensor *sensor) { this->grid_frequency_sensor_ = sensor; }
|
||||
|
@ -81,6 +83,7 @@ class GrowattSolar : public PollingComponent, public modbus::ModbusDevice {
|
|||
sensor::Sensor *total_energy_production_{nullptr};
|
||||
sensor::Sensor *inverter_module_temp_{nullptr};
|
||||
GrowattProtocolVersion protocol_version_;
|
||||
uint8_t warm_up_time_;
|
||||
};
|
||||
|
||||
} // namespace growatt_solar
|
||||
|
|
|
@ -39,6 +39,7 @@ CONF_INVERTER_STATUS = "inverter_status"
|
|||
CONF_PV_ACTIVE_POWER = "pv_active_power"
|
||||
CONF_INVERTER_MODULE_TEMP = "inverter_module_temp"
|
||||
CONF_PROTOCOL_VERSION = "protocol_version"
|
||||
CONF_WARM_UP_TIME = "warm_up_time"
|
||||
|
||||
AUTO_LOAD = ["modbus"]
|
||||
CODEOWNERS = ["@leeuwte"]
|
||||
|
@ -108,6 +109,7 @@ CONFIG_SCHEMA = (
|
|||
cv.Optional(CONF_PROTOCOL_VERSION, default="RTU"): cv.enum(
|
||||
PROTOCOL_VERSIONS, upper=True
|
||||
),
|
||||
cv.Optional(CONF_WARM_UP_TIME, default=0): cv.uint8_t,
|
||||
cv.Optional(CONF_PHASE_A): PHASE_SCHEMA,
|
||||
cv.Optional(CONF_PHASE_B): PHASE_SCHEMA,
|
||||
cv.Optional(CONF_PHASE_C): PHASE_SCHEMA,
|
||||
|
@ -163,6 +165,9 @@ async def to_code(config):
|
|||
|
||||
cg.add(var.set_protocol_version(config[CONF_PROTOCOL_VERSION]))
|
||||
|
||||
if CONF_WARM_UP_TIME in config:
|
||||
cg.add(var.set_warm_up_time(int(config[CONF_WARM_UP_TIME])))
|
||||
|
||||
if CONF_INVERTER_STATUS in config:
|
||||
sens = await sensor.new_sensor(config[CONF_INVERTER_STATUS])
|
||||
cg.add(var.set_inverter_status_sensor(sens))
|
||||
|
|
Loading…
Reference in New Issue