mirror of
https://github.com/esphome/esphome.git
synced 2024-11-24 16:08:10 +01:00
Publish the pulse_meter
total when setting the total (#5475)
This commit is contained in:
parent
9f033bce3b
commit
d82471942f
4 changed files with 11 additions and 3 deletions
|
@ -225,7 +225,7 @@ esphome/components/pn532_spi/* @OttoWinter @jesserockz
|
||||||
esphome/components/power_supply/* @esphome/core
|
esphome/components/power_supply/* @esphome/core
|
||||||
esphome/components/preferences/* @esphome/core
|
esphome/components/preferences/* @esphome/core
|
||||||
esphome/components/psram/* @esphome/core
|
esphome/components/psram/* @esphome/core
|
||||||
esphome/components/pulse_meter/* @cstaahl @stevebaxter
|
esphome/components/pulse_meter/* @TrentHouliston @cstaahl @stevebaxter
|
||||||
esphome/components/pvvx_mithermometer/* @pasiz
|
esphome/components/pvvx_mithermometer/* @pasiz
|
||||||
esphome/components/qmp6988/* @andrewpc
|
esphome/components/qmp6988/* @andrewpc
|
||||||
esphome/components/qr_code/* @wjtje
|
esphome/components/qr_code/* @wjtje
|
||||||
|
|
|
@ -7,6 +7,13 @@ namespace pulse_meter {
|
||||||
|
|
||||||
static const char *const TAG = "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() {
|
void PulseMeterSensor::setup() {
|
||||||
this->pin_->setup();
|
this->pin_->setup();
|
||||||
this->isr_pin_ = pin_->to_isr();
|
this->isr_pin_ = pin_->to_isr();
|
||||||
|
|
|
@ -22,7 +22,8 @@ class PulseMeterSensor : public sensor::Sensor, public Component {
|
||||||
void set_timeout_us(uint32_t timeout) { this->timeout_us_ = timeout; }
|
void set_timeout_us(uint32_t timeout) { this->timeout_us_ = timeout; }
|
||||||
void set_total_sensor(sensor::Sensor *sensor) { this->total_sensor_ = sensor; }
|
void set_total_sensor(sensor::Sensor *sensor) { this->total_sensor_ = sensor; }
|
||||||
void set_filter_mode(InternalFilterMode mode) { this->filter_mode_ = mode; }
|
void set_filter_mode(InternalFilterMode mode) { this->filter_mode_ = mode; }
|
||||||
void set_total_pulses(uint32_t pulses) { this->total_pulses_ = pulses; }
|
|
||||||
|
void set_total_pulses(uint32_t pulses);
|
||||||
|
|
||||||
void setup() override;
|
void setup() override;
|
||||||
void loop() override;
|
void loop() override;
|
||||||
|
|
|
@ -19,7 +19,7 @@ from esphome.const import (
|
||||||
)
|
)
|
||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
|
|
||||||
CODEOWNERS = ["@stevebaxter", "@cstaahl"]
|
CODEOWNERS = ["@stevebaxter", "@cstaahl", "@TrentHouliston"]
|
||||||
|
|
||||||
pulse_meter_ns = cg.esphome_ns.namespace("pulse_meter")
|
pulse_meter_ns = cg.esphome_ns.namespace("pulse_meter")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue