13static constexpr uint32_t SECONDS_PER_HOUR = 3600;
14static constexpr float MINUTES_PER_DAY = 24.0f * 60.0f;
26 this->last_update_ = now;
30 if (std::isnan(
speed))
40 ESP_LOGV(TAG,
"Elapsed %" PRIu32
" ms at %.0f%%, runtime %" PRIu32
" s", elapsed_ms,
speed, this->
runtime_seconds_);
48 const float remaining_minutes = std::max(0.0f, max_minutes - runtime_minutes);
49 this->
publish_state(100.0f * remaining_minutes / max_minutes);
63 ESP_LOGI(TAG,
"Filter lifetime reset");
67#ifdef USE_BINARY_SENSOR
86 LOG_SENSOR(
"",
"Filter Lifetime",
this);
88 " Max lifetime: %" PRIu32
" min (%.1f days)\n"
92#ifdef USE_BINARY_SENSOR
98 ESP_LOGCONFIG(TAG,
" Is-on: %s",
99 this->
is_on_lambda_ !=
nullptr ? LOG_STR_LITERAL(
"lambda") : LOG_STR_LITERAL(
"always"));
104 ESP_LOGCONFIG(TAG,
" Speed: %s",
109 LOG_UPDATE_INTERVAL(
this);
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
ESPPreferenceObject make_entity_preference(uint32_t version=0)
Create a preference object for storing this entity's state/settings.
bool state
The current state of this binary sensor. Also used as the backing storage for StatefulEntityBase.
sensor::Sensor * runtime_hours_sensor_
uint32_t max_lifetime_minutes_
binary_sensor::BinarySensor * is_on_sensor_
float(* current_speed_lambda_)()
sensor::Sensor * remaining_days_sensor_
uint32_t runtime_seconds_
void dump_config() override
ESPPreferenceObject pref_
void on_shutdown() override
sensor::Sensor * current_speed_sensor_
float get_current_speed_()
void publish_state(float state)
Publish a new state to the front-end.
float state
This member variable stores the last state that has passed through all filters.
ESPHOME_LOG_TAG(TAG, "filter_lifetime")
uint32_t IRAM_ATTR HOT millis()
Application App
Global storage of Application pointer - only one Application can exist.