5 namespace total_daily_energy {
7 static const char *
const TAG =
"total_daily_energy";
10 float initial_value = 0;
35 if (t.day_of_year != this->last_day_of_year_) {
51 if (std::isnan(state))
53 const uint32_t now =
millis();
55 const float new_state =
state;
56 float delta_hours = (now - this->
last_update_) / 1000.0f / 60.0f / 60.0f;
57 float delta_energy = 0.0f;
60 delta_energy = delta_hours * (old_state + new_state) / 2.0;
63 delta_energy = delta_hours * old_state;
66 delta_energy = delta_hours * new_state;
void publish_state_and_save(float state)
ESPTime now()
Get the time in the currently defined timezone.
TotalDailyEnergyMethod method_
void dump_config() override
void process_new_state_(float state)
uint32_t IRAM_ATTR HOT millis()
float state
This member variable stores the last state that has passed through all filters.
ESPPreferences * global_preferences
void publish_state(float state)
Publish a new state to the front-end.
time::RealTimeClock * time_
ESPPreferenceObject pref_
virtual ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)=0
Implementation of SPI Controller mode.
uint16_t last_day_of_year_
uint32_t get_object_id_hash()