Total Daily Energy Sensor

See Application::make_total_daily_energy_sensor().

API Reference

class TotalDailyEnergy : public sensor::Sensor, public Component

Public Functions

TotalDailyEnergy(const std::string &name, time::RealTimeClockComponent *time, Sensor *parent)
void setup()

Where the component’s initialization should happen.

Analogous to Arduino’s setup(). This method is guaranteed to only be called once. Defaults to doing nothing.

float get_setup_priority() const

priority of setup().

higher -> executed earlier

Defaults to 0.

Return
The setup priority of this component

uint32_t update_interval()

Return with which interval the sensor is polled. Return 0 for non-polling mode.

std::string unit_of_measurement()

Override this to set the Home Assistant unit of measurement for this sensor.

Return “” to disable this feature.

Return
The icon of this sensor, for example “°C”.

std::string icon()

Override this to set the Home Assistant icon for this sensor.

Return “” to disable this feature.

Return
The icon of this sensor, for example “mdi:battery”.

int8_t accuracy_decimals()

Return the accuracy in decimals for this sensor.

void loop()

This method will be called repeatedly.

Analogous to Arduino’s loop(). setup() is guaranteed to be called before this. Defaults to doing nothing.

Protected Functions

void publish_state_and_save_(float state)
void process_new_state_(float state)

Protected Attributes

ESPPreferenceObject pref_
time::RealTimeClockComponent *time_
Sensor *parent_
uint16_t last_day_of_year_ = {}
uint32_t last_update_ = {0}
float total_energy_ = {0.0f}