ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
filter_lifetime.h
Go to the documentation of this file.
1#pragma once
2
6#ifdef USE_BINARY_SENSOR
8#endif
9
11
13 SUB_SENSOR(runtime_hours)
14 SUB_SENSOR(remaining_days)
15 // Input sensors for the running state and speed
16#ifdef USE_BINARY_SENSOR
17 SUB_BINARY_SENSOR(is_on)
18#endif
19 SUB_SENSOR(current_speed)
20
21 public:
22 void setup() override;
23 void update() override;
24 void dump_config() override;
25 void on_shutdown() override;
26 void reset_filter();
27
28 void set_max_lifetime(uint32_t minutes) { this->max_lifetime_minutes_ = minutes; }
29 void set_is_on_lambda(bool (*is_on)()) { this->is_on_lambda_ = is_on; }
30 void set_current_speed_lambda(float (*speed)()) { this->current_speed_lambda_ = speed; }
31
32 protected:
33 bool get_is_on_();
34 float get_current_speed_();
35 void publish_values_();
36
37 bool (*is_on_lambda_)(){nullptr};
38 float (*current_speed_lambda_)(){nullptr};
42 uint32_t runtime_seconds_{0}; // Speed-weighted running time, persisted
43 uint32_t carry_ms_{0}; // Weighted milliseconds not yet counted as a second
44};
45
46} // namespace esphome::filter_lifetime
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
This class simplifies creating components that periodically check a state.
Definition component.h:532
Base-class for all sensors.
Definition sensor.h:48
int speed
Definition fan.h:3
static void uint32_t