ESPHome  2022.8.0
selec_meter.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace selec_meter {
9 
10 #define SELEC_METER_SENSOR(name) \
11  protected: \
12  sensor::Sensor *name##_sensor_{nullptr}; \
13 \
14  public: \
15  void set_##name##_sensor(sensor::Sensor *(name)) { this->name##_sensor_ = name; }
16 
18  public:
19  SELEC_METER_SENSOR(total_active_energy)
20  SELEC_METER_SENSOR(import_active_energy)
21  SELEC_METER_SENSOR(export_active_energy)
22  SELEC_METER_SENSOR(total_reactive_energy)
23  SELEC_METER_SENSOR(import_reactive_energy)
24  SELEC_METER_SENSOR(export_reactive_energy)
25  SELEC_METER_SENSOR(apparent_energy)
26  SELEC_METER_SENSOR(active_power)
27  SELEC_METER_SENSOR(reactive_power)
28  SELEC_METER_SENSOR(apparent_power)
29  SELEC_METER_SENSOR(voltage)
30  SELEC_METER_SENSOR(current)
31  SELEC_METER_SENSOR(power_factor)
32  SELEC_METER_SENSOR(frequency)
33  SELEC_METER_SENSOR(maximum_demand_active_power)
34  SELEC_METER_SENSOR(maximum_demand_reactive_power)
35  SELEC_METER_SENSOR(maximum_demand_apparent_power)
36 
37  void update() override;
38 
39  void on_modbus_data(const std::vector<uint8_t> &data) override;
40 
41  void dump_config() override;
42 };
43 
44 } // namespace selec_meter
45 } // namespace esphome
void on_modbus_data(const std::vector< uint8_t > &data) override
Definition: selec_meter.cpp:13
This class simplifies creating components that periodically check a state.
Definition: component.h:266
virtual void update()=0
Definition: a4988.cpp:4
SELEC_METER_SENSOR(total_active_energy) SELEC_METER_SENSOR(import_active_energy) SELEC_METER_SENSOR(export_active_energy) SELEC_METER_SENSOR(total_reactive_energy) SELEC_METER_SENSOR(import_reactive_energy) SELEC_METER_SENSOR(export_reactive_energy) SELEC_METER_SENSOR(apparent_energy) SELEC_METER_SENSOR(active_power) SELEC_METER_SENSOR(reactive_power) SELEC_METER_SENSOR(apparent_power) SELEC_METER_SENSOR(voltage) SELEC_METER_SENSOR(current) SELEC_METER_SENSOR(power_factor) SELEC_METER_SENSOR(frequency) SELEC_METER_SENSOR(maximum_demand_active_power) SELEC_METER_SENSOR(maximum_demand_reactive_power) SELEC_METER_SENSOR(maximum_demand_apparent_power) void update() override