ESPHome  2022.12.8
selec_meter.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 #include <vector>
8 
9 namespace esphome {
10 namespace selec_meter {
11 
12 #define SELEC_METER_SENSOR(name) \
13  protected: \
14  sensor::Sensor *name##_sensor_{nullptr}; \
15 \
16  public: \
17  void set_##name##_sensor(sensor::Sensor *(name)) { this->name##_sensor_ = name; }
18 
20  public:
21  SELEC_METER_SENSOR(total_active_energy)
22  SELEC_METER_SENSOR(import_active_energy)
23  SELEC_METER_SENSOR(export_active_energy)
24  SELEC_METER_SENSOR(total_reactive_energy)
25  SELEC_METER_SENSOR(import_reactive_energy)
26  SELEC_METER_SENSOR(export_reactive_energy)
27  SELEC_METER_SENSOR(apparent_energy)
28  SELEC_METER_SENSOR(active_power)
29  SELEC_METER_SENSOR(reactive_power)
30  SELEC_METER_SENSOR(apparent_power)
31  SELEC_METER_SENSOR(voltage)
32  SELEC_METER_SENSOR(current)
33  SELEC_METER_SENSOR(power_factor)
35  SELEC_METER_SENSOR(maximum_demand_active_power)
36  SELEC_METER_SENSOR(maximum_demand_reactive_power)
37  SELEC_METER_SENSOR(maximum_demand_apparent_power)
38 
39  void update() override;
40 
41  void on_modbus_data(const std::vector<uint8_t> &data) override;
42 
43  void dump_config() override;
44 };
45 
46 } // namespace selec_meter
47 } // 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:267
virtual void update()=0
uint16_le_t frequency
Definition: bl0942.h:21
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