Publish the pulse_meter total when setting the total (#5475)

This commit is contained in:
Trent Houliston
2023-10-20 08:28:05 +11:00
committed by Jesse Hills
parent 11dba3147d
commit 76ab923780
4 changed files with 11 additions and 3 deletions
@@ -7,6 +7,13 @@ namespace pulse_meter {
static const char *const TAG = "pulse_meter";
void PulseMeterSensor::set_total_pulses(uint32_t pulses) {
this->total_pulses_ = pulses;
if (this->total_sensor_ != nullptr) {
this->total_sensor_->publish_state(this->total_pulses_);
}
}
void PulseMeterSensor::setup() {
this->pin_->setup();
this->isr_pin_ = pin_->to_isr();