diff --git a/esphome/components/pulse_counter_ulp/pulse_counter_ulp_sensor.cpp b/esphome/components/pulse_counter_ulp/pulse_counter_ulp_sensor.cpp index 1919a5d0ce..f259b6022f 100644 --- a/esphome/components/pulse_counter_ulp/pulse_counter_ulp_sensor.cpp +++ b/esphome/components/pulse_counter_ulp/pulse_counter_ulp_sensor.cpp @@ -136,8 +136,8 @@ void PulseCounterUlpSensor::dump_config() { void PulseCounterUlpSensor::update() { UlpProgram::state raw = this->storage_.pop_state(); clock::time_point now = clock::now(); - auto interval = now - this->last_time_; - if (this->last_time_ != clock::time_point{}) { + clock::duration interval = now - this->last_time_; + if (interval != clock::duration::zero()) { float value = std::chrono::minutes{1} * static_cast(raw.edge_count) / interval; // pulses per minute ESP_LOGD(TAG, "'%s': Retrieved counter: %0.2f pulses/min", this->get_name().c_str(), value); this->publish_state(value);