Skip to content

Commit

Permalink
meters-modbus-tcp: Add initial Deye hybrid inverter support
Browse files Browse the repository at this point in the history
Only based on datasheet information. Not yet tested in the wild.
  • Loading branch information
photron committed May 3, 2024
1 parent 0dec503 commit 92bf0d8
Show file tree
Hide file tree
Showing 7 changed files with 588 additions and 3 deletions.
34 changes: 34 additions & 0 deletions software/src/modules/meters_modbus_tcp/meter_modbus_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,40 @@ void MeterModbusTCP::setup(const Config &ephemeral_config)

break;

case MeterModbusTCPTableID::DeyeHybridInverter:
generic_read_request.register_type = TAddress::RegType::HREG;
generic_read_request.start_address_offset = 0; // register address mode
deye_hybrid_inverter_virtual_meter = ephemeral_config.get("table")->get()->get("virtual_meter")->asEnum<DeyeHybridInverterVirtualMeterID>();
device_address = static_cast<uint8_t>(ephemeral_config.get("table")->get()->get("device_address")->asUint());

switch (deye_hybrid_inverter_virtual_meter) {
case DeyeHybridInverterVirtualMeterID::None:
logger.printfln("No Deye Hybrid Inverter Virtual Meter selected");
return;

case DeyeHybridInverterVirtualMeterID::Inverter:
table = &deye_hybrid_inverter_table;
break;

case DeyeHybridInverterVirtualMeterID::Grid:
table = &deye_hybrid_inverter_grid_table;
break;

case DeyeHybridInverterVirtualMeterID::Battery:
table = &deye_hybrid_inverter_battery_table;
break;

case DeyeHybridInverterVirtualMeterID::Load:
table = &deye_hybrid_inverter_load_table;
break;

default:
logger.printfln("Unknown Deye Hybrid Inverter Virtual Meter: %u", static_cast<uint8_t>(deye_hybrid_inverter_virtual_meter));
return;
}

break;

default:
logger.printfln("Unknown table: %u", static_cast<uint8_t>(table_id));
return;
Expand Down
6 changes: 6 additions & 0 deletions software/src/modules/meters_modbus_tcp/meter_modbus_tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,16 @@ class MeterModbusTCP final : protected GenericModbusTCPClient, public IMeter

uint16_t register_buffer[2];

// Sungrow
SungrowHybridInverterVirtualMeterID sungrow_hybrid_inverter_virtual_meter;
SungrowStringInverterVirtualMeterID sungrow_string_inverter_virtual_meter;
int sungrow_inverter_output_type = -1;
uint16_t sungrow_hybrid_inverter_running_state;

// Solarmax
SolarmaxMaxStorageVirtualMeterID solarmax_max_storage_virtual_meter;

// Victron Energy
VictronEnergyColorControlGXVirtualMeterID victron_energy_color_control_gx_virtual_meter;
float victron_energy_color_control_gx_ac_coupled_pv_on_output_l1_power;
float victron_energy_color_control_gx_ac_coupled_pv_on_output_l2_power;
Expand All @@ -114,6 +117,9 @@ class MeterModbusTCP final : protected GenericModbusTCPClient, public IMeter
float victron_energy_color_control_gx_ac_consumption_l1_power;
float victron_energy_color_control_gx_ac_consumption_l2_power;
float victron_energy_color_control_gx_ac_consumption_l3_power;

// Deye
DeyeHybridInverterVirtualMeterID deye_hybrid_inverter_virtual_meter;
};

#if defined(__GNUC__)
Expand Down
5 changes: 5 additions & 0 deletions software/src/modules/meters_modbus_tcp/meters_modbus_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ void MetersModbusTCP::pre_setup()
{"device_address", Config::Uint(100, 1, 247)},
})});

table_prototypes.push_back({MeterModbusTCPTableID::DeyeHybridInverter, Config::Object({
{"virtual_meter", Config::Uint8(static_cast<uint8_t>(SungrowHybridInverterVirtualMeterID::None))},
{"device_address", Config::Uint(1, 1, 247)},
})});

Config table_union = Config::Union<MeterModbusTCPTableID>(
*Config::Null(),
MeterModbusTCPTableID::None,
Expand Down
Loading

0 comments on commit 92bf0d8

Please sign in to comment.