diff --git a/CHANGELOG.md b/CHANGELOG.md index 3136fa830..e0ec39a66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. ### Breaking Changed - Berry energy_ctypes changed with new energy driver +- Berry energy_ctypes fixed accordingly ### Changed - Energy refactoring preparing for ESP32 phase/channel extension diff --git a/lib/libesp32/berry_tasmota/src/be_energy_ctypes_definitions.c b/lib/libesp32/berry_tasmota/src/be_energy_ctypes_definitions.c index 21ece3f3a..1844134a3 100644 --- a/lib/libesp32/berry_tasmota/src/be_energy_ctypes_definitions.c +++ b/lib/libesp32/berry_tasmota/src/be_energy_ctypes_definitions.c @@ -1,112 +1,11 @@ -/******************************************************************** - * Tasmota LVGL ctypes mapping - *******************************************************************/ +// /******************************************************************** +// * Tasmota LVGL ctypes mapping +// *******************************************************************/ #include "be_ctypes.h" #ifdef USE_ENERGY_SENSOR -/******************************************************************** - * Generated code, don't edit - *******************************************************************/ - -static const char * be_ctypes_instance_mappings[]; /* forward definition */ - -const be_ctypes_structure_t be_energy_struct = { - 250, /* size in bytes */ - 85, /* number of elements */ - be_ctypes_instance_mappings, - (const be_ctypes_structure_item_t[85]) { - { "active_power", 24, 0, 0, ctypes_float, 0 }, - { "active_power_2", 28, 0, 0, ctypes_float, 0 }, - { "active_power_3", 32, 0, 0, ctypes_float, 0 }, - { "apparent_power", 36, 0, 0, ctypes_float, 0 }, - { "apparent_power_2", 40, 0, 0, ctypes_float, 0 }, - { "apparent_power_3", 44, 0, 0, ctypes_float, 0 }, - { "command_code", 205, 0, 0, ctypes_u8, 0 }, - { "current", 12, 0, 0, ctypes_float, 0 }, - { "current_2", 16, 0, 0, ctypes_float, 0 }, - { "current_3", 20, 0, 0, ctypes_float, 0 }, - { "current_available", 215, 0, 0, ctypes_u8, 0 }, - { "daily", 120, 0, 0, ctypes_float, 0 }, - { "daily_2", 124, 0, 0, ctypes_float, 0 }, - { "daily_3", 128, 0, 0, ctypes_float, 0 }, - { "daily_sum", 144, 0, 0, ctypes_float, 0 }, - { "data_valid", 206, 0, 0, ctypes_u8, 0 }, - { "data_valid_2", 207, 0, 0, ctypes_u8, 0 }, - { "data_valid_3", 208, 0, 0, ctypes_u8, 0 }, - { "export_active", 96, 0, 0, ctypes_float, 0 }, - { "export_active_2", 100, 0, 0, ctypes_float, 0 }, - { "export_active_3", 104, 0, 0, ctypes_float, 0 }, - { "fifth_second", 204, 0, 0, ctypes_u8, 0 }, - { "frequency", 72, 0, 0, ctypes_float, 0 }, - { "frequency_2", 76, 0, 0, ctypes_float, 0 }, - { "frequency_3", 80, 0, 0, ctypes_float, 0 }, - { "frequency_common", 211, 0, 0, ctypes_u8, 0 }, - { "import_active", 84, 0, 0, ctypes_float, 0 }, - { "import_active_2", 88, 0, 0, ctypes_float, 0 }, - { "import_active_3", 92, 0, 0, ctypes_float, 0 }, - { "max_current_flag", 242, 0, 0, ctypes_u8, 0 }, - { "max_energy_state", 249, 0, 0, ctypes_u8, 0 }, - { "max_power_flag", 238, 0, 0, ctypes_u8, 0 }, - { "max_voltage_flag", 240, 0, 0, ctypes_u8, 0 }, - { "min_current_flag", 241, 0, 0, ctypes_u8, 0 }, - { "min_power_flag", 237, 0, 0, ctypes_u8, 0 }, - { "min_voltage_flag", 239, 0, 0, ctypes_u8, 0 }, - { "mplh_counter", 244, 0, 0, ctypes_u16, 0 }, - { "mplr_counter", 248, 0, 0, ctypes_u8, 0 }, - { "mplw_counter", 246, 0, 0, ctypes_u16, 0 }, - { "period", 192, 0, 0, ctypes_u32, 0 }, - { "period_2", 196, 0, 0, ctypes_u32, 0 }, - { "period_3", 200, 0, 0, ctypes_u32, 0 }, - { "phase_count", 209, 0, 0, ctypes_u8, 0 }, - { "power_factor", 60, 0, 0, ctypes_float, 0 }, - { "power_factor_2", 64, 0, 0, ctypes_float, 0 }, - { "power_factor_3", 68, 0, 0, ctypes_float, 0 }, - { "power_history_0", 218, 0, 0, ctypes_u16, 0 }, - { "power_history_0_2", 220, 0, 0, ctypes_u16, 0 }, - { "power_history_0_3", 222, 0, 0, ctypes_u16, 0 }, - { "power_history_1", 224, 0, 0, ctypes_u16, 0 }, - { "power_history_1_2", 226, 0, 0, ctypes_u16, 0 }, - { "power_history_1_3", 228, 0, 0, ctypes_u16, 0 }, - { "power_history_2", 230, 0, 0, ctypes_u16, 0 }, - { "power_history_2_2", 232, 0, 0, ctypes_u16, 0 }, - { "power_history_2_3", 234, 0, 0, ctypes_u16, 0 }, - { "power_on", 217, 0, 0, ctypes_u8, 0 }, - { "power_steady_counter", 236, 0, 0, ctypes_u8, 0 }, - { "reactive_power", 48, 0, 0, ctypes_float, 0 }, - { "reactive_power_2", 52, 0, 0, ctypes_float, 0 }, - { "reactive_power_3", 56, 0, 0, ctypes_float, 0 }, - { "start_energy", 108, 0, 0, ctypes_float, 0 }, - { "start_energy_2", 112, 0, 0, ctypes_float, 0 }, - { "start_energy_3", 116, 0, 0, ctypes_float, 0 }, - { "today_delta_kwh", 156, 0, 0, ctypes_u32, 0 }, - { "today_delta_kwh_2", 160, 0, 0, ctypes_u32, 0 }, - { "today_delta_kwh_3", 164, 0, 0, ctypes_u32, 0 }, - { "today_kwh", 180, 0, 0, ctypes_u32, 0 }, - { "today_kwh_2", 184, 0, 0, ctypes_u32, 0 }, - { "today_kwh_3", 188, 0, 0, ctypes_u32, 0 }, - { "today_offset_init_kwh", 213, 0, 0, ctypes_u8, 0 }, - { "today_offset_kwh", 168, 0, 0, ctypes_u32, 0 }, - { "today_offset_kwh_2", 172, 0, 0, ctypes_u32, 0 }, - { "today_offset_kwh_3", 176, 0, 0, ctypes_u32, 0 }, - { "total", 132, 0, 0, ctypes_float, 0 }, - { "total_2", 136, 0, 0, ctypes_float, 0 }, - { "total_3", 140, 0, 0, ctypes_float, 0 }, - { "total_sum", 148, 0, 0, ctypes_float, 0 }, - { "type_dc", 216, 0, 0, ctypes_u8, 0 }, - { "use_overtemp", 212, 0, 0, ctypes_u8, 0 }, - { "voltage", 0, 0, 0, ctypes_float, 0 }, - { "voltage_2", 4, 0, 0, ctypes_float, 0 }, - { "voltage_3", 8, 0, 0, ctypes_float, 0 }, - { "voltage_available", 214, 0, 0, ctypes_u8, 0 }, - { "voltage_common", 210, 0, 0, ctypes_u8, 0 }, - { "yesterday_sum", 152, 0, 0, ctypes_float, 0 }, -}}; - -static const char * be_ctypes_instance_mappings[] = { - NULL -}; - +extern const be_ctypes_structure_t be_energy_struct[]; be_define_ctypes_class(energy_struct, &be_energy_struct, &be_class_ctypes_bytes, "energy_struct"); -#endif // USE_ENERGY_SENSOR \ No newline at end of file +#endif // USE_ENERGY_SENSOR diff --git a/tasmota/berry/modules/energy_ctypes.be b/tasmota/berry/modules/energy_ctypes.be deleted file mode 100644 index 4d2ebea1c..000000000 --- a/tasmota/berry/modules/energy_ctypes.be +++ /dev/null @@ -1,179 +0,0 @@ -# -# ctype buidings for Tasmota Energy driver -# -# To generate C bindings, do: -# > compile("energy_ctypes.be","file")() -# -# and copy/paste output in C format -# -import ctypes - -ctypes.print_types() - -float = ctypes.float -uint8 = ctypes.u8 -uint16 = ctypes.u16 -uint32 = ctypes.u32 -int32 = ctypes.i32 -bol = ctypes.u8 - -energy_struct = [ - [float, "voltage"], - [float, "voltage_2"], - [float, "voltage_3"], - [float, "current"], - [float, "current_2"], - [float, "current_3"], - [float, "active_power"], - [float, "active_power_2"], - [float, "active_power_3"], - [float, "apparent_power"], - [float, "apparent_power_2"], - [float, "apparent_power_3"], - [float, "reactive_power"], - [float, "reactive_power_2"], - [float, "reactive_power_3"], - [float, "power_factor"], - [float, "power_factor_2"], - [float, "power_factor_3"], - [float, "frequency"], - [float, "frequency_2"], - [float, "frequency_3"], - [float, "import_active"], - [float, "import_active_2"], - [float, "import_active_3"], - [float, "export_active"], - [float, "export_active_2"], - [float, "export_active_3"], - [float, "start_energy"], - [float, "start_energy_2"], - [float, "start_energy_3"], - [float, "daily"], - [float, "daily_2"], - [float, "daily_3"], - [float, "total"], - [float, "total_2"], - [float, "total_3"], - - [float, "daily_sum"], - [float, "total_sum"], - [float, "yesterday_sum"], - - [uint32, "today_delta_kwh"], - [uint32, "today_delta_kwh_2"], - [uint32, "today_delta_kwh_3"], - [uint32, "today_offset_kwh"], - [uint32, "today_offset_kwh_2"], - [uint32, "today_offset_kwh_3"], - [uint32, "today_kwh"], - [uint32, "today_kwh_2"], - [uint32, "today_kwh_3"], - [uint32, "period"], - [uint32, "period_2"], - [uint32, "period_3"], - - [uint8, "fifth_second"], - [uint8, "command_code"], - [uint8, "data_valid"], - [uint8, "data_valid_2"], - [uint8, "data_valid_3"], - - [uint8, "phase_count"], - - [bol, "voltage_common"], - [bol, "frequency_common"], - [bol, "use_overtemp"], - [bol, "today_offset_init_kwh"], - - [bol, "voltage_available"], - [bol, "current_available"], - - [bol, "type_dc"], - [bol, "power_on"], -# #ifdef USE_ENERGY_MARGIN_DETECTION - [uint16, "power_history_0"], - [uint16, "power_history_0_2"], - [uint16, "power_history_0_3"], - [uint16, "power_history_1"], - [uint16, "power_history_1_2"], - [uint16, "power_history_1_3"], - [uint16, "power_history_2"], - [uint16, "power_history_2_2"], - [uint16, "power_history_2_3"], - - [uint8, "power_steady_counter"], - - [bol, "min_power_flag"], - [bol, "max_power_flag"], - [bol, "min_voltage_flag"], - [bol, "max_voltage_flag"], - [bol, "min_current_flag"], - [bol, "max_current_flag"], - -# #ifdef USE_ENERGY_POWER_LIMIT - [uint16, "mplh_counter"], - [uint16, "mplw_counter"], - [uint8, "mplr_counter"], - [uint8, "max_energy_state"], -] -energy_struct = ctypes.structure(energy_struct, "energy_struct") - -# struct ENERGY { -# float voltage[ENERGY_MAX_PHASES]; // 123.1 V -# float current[ENERGY_MAX_PHASES]; // 123.123 A -# float active_power[ENERGY_MAX_PHASES]; // 123.1 W -# float apparent_power[ENERGY_MAX_PHASES]; // 123.1 VA -# float reactive_power[ENERGY_MAX_PHASES]; // 123.1 VAr -# float power_factor[ENERGY_MAX_PHASES]; // 0.12 -# float frequency[ENERGY_MAX_PHASES]; // 123.1 Hz -# #if defined(SDM630_IMPORT) || defined(SDM72_IMPEXP) -# float import_active[ENERGY_MAX_PHASES]; // 123.123 kWh -# #endif // SDM630_IMPORT || SDM72_IMPEXP -# float export_active[ENERGY_MAX_PHASES]; // 123.123 kWh - -# float start_energy; // 12345.12345 kWh total previous -# float daily; // 123.123 kWh -# float total; // 12345.12345 kWh total energy - -# unsigned long kWhtoday_delta; // 1212312345 Wh 10^-5 (deca micro Watt hours) - Overflows to Energy.kWhtoday (HLW and CSE only) -# unsigned long kWhtoday_offset; // 12312312 Wh * 10^-2 (deca milli Watt hours) - 5764 = 0.05764 kWh = 0.058 kWh = Energy.daily -# unsigned long kWhtoday; // 12312312 Wh * 10^-2 (deca milli Watt hours) - 5764 = 0.05764 kWh = 0.058 kWh = Energy.daily -# unsigned long period; // 12312312 Wh * 10^-2 (deca milli Watt hours) - 5764 = 0.05764 kWh = 0.058 kWh = Energy.daily - -# uint8_t fifth_second; -# uint8_t command_code; -# uint8_t data_valid[ENERGY_MAX_PHASES]; - -# uint8_t phase_count; // Number of phases active -# bool voltage_common; // Use single voltage -# bool frequency_common; // Use single frequency -# bool use_overtemp; // Use global temperature as overtemp trigger on internal energy monitor hardware -# bool kWhtoday_offset_init; - -# bool voltage_available; // Enable if voltage is measured -# bool current_available; // Enable if current is measured - -# bool type_dc; -# bool power_on; - -# #ifdef USE_ENERGY_MARGIN_DETECTION -# uint16_t power_history[ENERGY_MAX_PHASES][3]; -# uint8_t power_steady_counter; // Allow for power on stabilization -# bool min_power_flag; -# bool max_power_flag; -# bool min_voltage_flag; -# bool max_voltage_flag; -# bool min_current_flag; -# bool max_current_flag; - -# #ifdef USE_ENERGY_POWER_LIMIT -# uint16_t mplh_counter; -# uint16_t mplw_counter; -# uint8_t mplr_counter; -# uint8_t max_energy_state; -# #endif // USE_ENERGY_POWER_LIMIT -# #endif // USE_ENERGY_MARGIN_DETECTION -# } Energy; - -# -ctypes.print_classes("energy") diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_energy.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_energy.ino new file mode 100644 index 000000000..f9eca21f5 --- /dev/null +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_energy.ino @@ -0,0 +1,141 @@ +/* + xdrv_52_3_berry_energy.ino - Berry scripting language, native fucnctions + + Copyright (C) 2021 Stephan Hadinger, Berry language by Guan Wenliang https://github.com/Skiars/berry + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +// Mappgin from internal light and a generic `light_state` Berry class + +#ifdef USE_BERRY +#ifdef USE_ENERGY_SENSOR + +#include "berry.h" +#include "be_func.h" +#include "be_ctypes.h" + +/*********************************************************************************************\ + * Mapping for tEnergy + * +\*********************************************************************************************/ +extern "C" { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winvalid-offsetof" // avoid warnings since we're using offsetof() in a risky way + + static const char * be_ctypes_instance_mappings[] = { + NULL + }; + extern "C" const be_ctypes_structure_t be_energy_struct = { + sizeof(tEnergy), /* size in bytes */ + 88, /* number of elements */ + be_ctypes_instance_mappings, + (const be_ctypes_structure_item_t[88]) { + { "active_power", offsetof(tEnergy, active_power[0]), 0, 0, ctypes_float, 0 }, + { "active_power_2", offsetof(tEnergy, active_power[1]), 0, 0, ctypes_float, 0 }, + { "active_power_3", offsetof(tEnergy, active_power[2]), 0, 0, ctypes_float, 0 }, + { "apparent_power", offsetof(tEnergy, apparent_power[0]), 0, 0, ctypes_float, 0 }, + { "apparent_power_2", offsetof(tEnergy, apparent_power[1]), 0, 0, ctypes_float, 0 }, + { "apparent_power_3", offsetof(tEnergy, apparent_power[2]), 0, 0, ctypes_float, 0 }, + { "command_code", offsetof(tEnergy, command_code), 0, 0, ctypes_u8, 0 }, + { "current", offsetof(tEnergy, current[0]), 0, 0, ctypes_float, 0 }, + { "current_2", offsetof(tEnergy, current[1]), 0, 0, ctypes_float, 0 }, + { "current_3", offsetof(tEnergy, current[2]), 0, 0, ctypes_float, 0 }, + { "current_available", offsetof(tEnergy, current_available), 0, 0, ctypes_u8, 0 }, + { "daily", offsetof(tEnergy, daily_kWh[0]), 0, 0, ctypes_float, 0 }, + { "daily_2", offsetof(tEnergy, daily_kWh[1]), 0, 0, ctypes_float, 0 }, + { "daily_3", offsetof(tEnergy, daily_kWh[2]), 0, 0, ctypes_float, 0 }, + { "daily_sum", offsetof(tEnergy, daily_sum), 0, 0, ctypes_float, 0 }, + { "daily_sum_export_balanced", offsetof(tEnergy, daily_sum_export_balanced), 0, 0, ctypes_float, 0 }, + { "daily_sum_import_balanced", offsetof(tEnergy, daily_sum_import_balanced), 0, 0, ctypes_float, 0 }, + { "data_valid", offsetof(tEnergy, data_valid[0]), 0, 0, ctypes_u8, 0 }, + { "data_valid_2", offsetof(tEnergy, data_valid[1]), 0, 0, ctypes_u8, 0 }, + { "data_valid_3", offsetof(tEnergy, data_valid[2]), 0, 0, ctypes_u8, 0 }, + { "energy_active_export", offsetof(tEnergy, local_energy_active_export), 0, 0, ctypes_u8, 0 }, + { "export_active", offsetof(tEnergy, export_active[0]), 0, 0, ctypes_float, 0 }, + { "export_active_2", offsetof(tEnergy, export_active[1]), 0, 0, ctypes_float, 0 }, + { "export_active_3", offsetof(tEnergy, export_active[2]), 0, 0, ctypes_float, 0 }, + { "fifth_second", offsetof(tEnergy, fifth_second), 0, 0, ctypes_u8, 0 }, + { "frequency", offsetof(tEnergy, frequency[0]), 0, 0, ctypes_float, 0 }, + { "frequency_2", offsetof(tEnergy, frequency[1]), 0, 0, ctypes_float, 0 }, + { "frequency_3", offsetof(tEnergy, frequency[2]), 0, 0, ctypes_float, 0 }, + { "frequency_common", offsetof(tEnergy, frequency_common), 0, 0, ctypes_u8, 0 }, + { "import_active", offsetof(tEnergy, import_active[0]), 0, 0, ctypes_float, 0 }, + { "import_active_2", offsetof(tEnergy, import_active[1]), 0, 0, ctypes_float, 0 }, + { "import_active_3", offsetof(tEnergy, import_active[2]), 0, 0, ctypes_float, 0 }, + { "max_current_flag", offsetof(tEnergy, max_current_flag), 0, 0, ctypes_u8, 0 }, + { "max_energy_state", offsetof(tEnergy, max_energy_state), 0, 0, ctypes_u8, 0 }, + { "max_power_flag", offsetof(tEnergy, max_power_flag), 0, 0, ctypes_u8, 0 }, + { "max_voltage_flag", offsetof(tEnergy, max_voltage_flag), 0, 0, ctypes_u8, 0 }, + { "min_current_flag", offsetof(tEnergy, min_current_flag), 0, 0, ctypes_u8, 0 }, + { "min_power_flag", offsetof(tEnergy, min_power_flag), 0, 0, ctypes_u8, 0 }, + { "min_voltage_flag", offsetof(tEnergy, min_voltage_flag), 0, 0, ctypes_u8, 0 }, + { "mplh_counter", offsetof(tEnergy, mplh_counter), 0, 0, ctypes_u16, 0 }, + { "mplr_counter", offsetof(tEnergy, mplr_counter), 0, 0, ctypes_u8, 0 }, + { "mplw_counter", offsetof(tEnergy, mplw_counter), 0, 0, ctypes_u16, 0 }, + { "period", offsetof(tEnergy, period_kWh[0]), 0, 0, ctypes_float, 0 }, + { "period_2", offsetof(tEnergy, period_kWh[1]), 0, 0, ctypes_float, 0 }, + { "period_3", offsetof(tEnergy, period_kWh[2]), 0, 0, ctypes_float, 0 }, + { "phase_count", offsetof(tEnergy, phase_count), 0, 0, ctypes_u8, 0 }, + { "power_factor", offsetof(tEnergy, power_factor[0]), 0, 0, ctypes_float, 0 }, + { "power_factor_2", offsetof(tEnergy, power_factor[1]), 0, 0, ctypes_float, 0 }, + { "power_factor_3", offsetof(tEnergy, power_factor[2]), 0, 0, ctypes_float, 0 }, + { "power_history_0", offsetof(tEnergy, power_history[0][0]), 0, 0, ctypes_u16, 0 }, + { "power_history_0_2", offsetof(tEnergy, power_history[0][1]), 0, 0, ctypes_u16, 0 }, + { "power_history_0_3", offsetof(tEnergy, power_history[0][2]), 0, 0, ctypes_u16, 0 }, + { "power_history_1", offsetof(tEnergy, power_history[1][0]), 0, 0, ctypes_u16, 0 }, + { "power_history_1_2", offsetof(tEnergy, power_history[1][1]), 0, 0, ctypes_u16, 0 }, + { "power_history_1_3", offsetof(tEnergy, power_history[1][2]), 0, 0, ctypes_u16, 0 }, + { "power_history_2", offsetof(tEnergy, power_history[2][0]), 0, 0, ctypes_u16, 0 }, + { "power_history_2_2", offsetof(tEnergy, power_history[2][1]), 0, 0, ctypes_u16, 0 }, + { "power_history_2_3", offsetof(tEnergy, power_history[2][2]), 0, 0, ctypes_u16, 0 }, + { "power_on", offsetof(tEnergy, power_on), 0, 0, ctypes_u8, 0 }, + { "power_steady_counter", offsetof(tEnergy, power_steady_counter), 0, 0, ctypes_u8, 0 }, + { "reactive_power", offsetof(tEnergy, reactive_power[0]), 0, 0, ctypes_float, 0 }, + { "reactive_power_2", offsetof(tEnergy, reactive_power[1]), 0, 0, ctypes_float, 0 }, + { "reactive_power_3", offsetof(tEnergy, reactive_power[2]), 0, 0, ctypes_float, 0 }, + { "start_energy", offsetof(tEnergy, start_energy[0]), 0, 0, ctypes_float, 0 }, + { "start_energy_2", offsetof(tEnergy, start_energy[1]), 0, 0, ctypes_float, 0 }, + { "start_energy_3", offsetof(tEnergy, start_energy[2]), 0, 0, ctypes_float, 0 }, + { "today_delta_kwh", offsetof(tEnergy, kWhtoday_delta[0]), 0, 0, ctypes_u32, 0 }, + { "today_delta_kwh_2", offsetof(tEnergy, kWhtoday_delta[1]), 0, 0, ctypes_u32, 0 }, + { "today_delta_kwh_3", offsetof(tEnergy, kWhtoday_delta[2]), 0, 0, ctypes_u32, 0 }, + { "today_kwh", offsetof(tEnergy, kWhtoday[0]), 0, 0, ctypes_u32, 0 }, + { "today_kwh_2", offsetof(tEnergy, kWhtoday[1]), 0, 0, ctypes_u32, 0 }, + { "today_kwh_3", offsetof(tEnergy, kWhtoday[2]), 0, 0, ctypes_u32, 0 }, + { "today_offset_init_kwh", offsetof(tEnergy, kWhtoday_offset_init), 0, 0, ctypes_u8, 0 }, + { "today_offset_kwh", offsetof(tEnergy, energy_today_offset_kWh[0]), 0, 0, ctypes_float, 0 }, + { "today_offset_kwh_2", offsetof(tEnergy, energy_today_offset_kWh[1]), 0, 0, ctypes_float, 0 }, + { "today_offset_kwh_3", offsetof(tEnergy, energy_today_offset_kWh[2]), 0, 0, ctypes_float, 0 }, + { "total", offsetof(tEnergy, total[0]), 0, 0, ctypes_float, 0 }, + { "total_2", offsetof(tEnergy, total[1]), 0, 0, ctypes_float, 0 }, + { "total_3", offsetof(tEnergy, total[2]), 0, 0, ctypes_float, 0 }, + { "total_sum", offsetof(tEnergy, total_sum), 0, 0, ctypes_float, 0 }, + { "type_dc", offsetof(tEnergy, type_dc), 0, 0, ctypes_u8, 0 }, + { "use_overtemp", offsetof(tEnergy, use_overtemp), 0, 0, ctypes_u8, 0 }, + { "voltage", offsetof(tEnergy, voltage[0]), 0, 0, ctypes_float, 0 }, + { "voltage_2", offsetof(tEnergy, voltage[1]), 0, 0, ctypes_float, 0 }, + { "voltage_3", offsetof(tEnergy, voltage[2]), 0, 0, ctypes_float, 0 }, + { "voltage_available", offsetof(tEnergy, voltage_available), 0, 0, ctypes_u8, 0 }, + { "voltage_common", offsetof(tEnergy, voltage_common), 0, 0, ctypes_u8, 0 }, + { "yesterday_sum", offsetof(tEnergy, yesterday_sum), 0, 0, ctypes_float, 0 }, + }}; + // be_define_ctypes_class(energy_struct, &be_energy_struct, &be_class_ctypes_bytes, "energy_struct"); + +#pragma GCC diagnostic pop +} + + +#endif // USE_ZIGBEE +#endif // USE_BERRY