ESPHome  2024.10.2
total_daily_energy.h
Go to the documentation of this file.
1 #pragma once
2 
5 #include "esphome/core/hal.h"
8 
9 namespace esphome {
10 namespace total_daily_energy {
11 
16 };
17 
18 class TotalDailyEnergy : public sensor::Sensor, public Component {
19  public:
20  void set_restore(bool restore) { restore_ = restore; }
21  void set_time(time::RealTimeClock *time) { time_ = time; }
22  void set_parent(Sensor *parent) { parent_ = parent; }
23  void set_method(TotalDailyEnergyMethod method) { method_ = method; }
24  void setup() override;
25  void dump_config() override;
26  float get_setup_priority() const override { return setup_priority::DATA; }
27  void loop() override;
28 
29  void publish_state_and_save(float state);
30 
31  protected:
32  void process_new_state_(float state);
33 
38  uint16_t last_day_of_year_{};
39  uint32_t last_update_{0};
40  bool restore_;
41  float total_energy_{0.0f};
42  float last_power_state_{0.0f};
43 };
44 
45 } // namespace total_daily_energy
46 } // namespace esphome
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
void set_method(TotalDailyEnergyMethod method)
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock...
float state
This member variable stores the last state that has passed through all filters.
Definition: sensor.h:131
void set_time(time::RealTimeClock *time)
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
Base-class for all sensors.
Definition: sensor.h:57