Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 1 addition & 53 deletions modules/general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,67 +45,15 @@ binary_sensor:
bitmask: 0x1

sensor:
# New - To be Tested
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove all of these Sensors after you Added them a few Commit earlier ?


- platform: modbus_controller
modbus_controller_id: ${modbus_controller_id}
name: "${entities_name_prefix}-General - Active Power Regulation"
id: "${entities_id_prefix}_General_Active_Power_Regulation"
register_type: holding
address: 77
unit_of_measurement: "%"
value_type: S_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1 # Converts value to percentage

- platform: modbus_controller
modbus_controller_id: ${modbus_controller_id}
name: "${entities_name_prefix}-General - Reactive Power Regulation"
id: "${entities_id_prefix}_General_Reactive_Power_Regulation"
register_type: holding
address: 78
unit_of_measurement: "%"
value_type: S_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1 # Converts value to percentage

- platform: modbus_controller
modbus_controller_id: ${modbus_controller_id}
name: "${entities_name_prefix}-General - Apparent Power Regulation"
id: "${entities_id_prefix}_General_Apparent_Power_Regulation"
register_type: holding
address: 79
unit_of_measurement: ""
value_type: S_WORD

- platform: modbus_controller
modbus_controller_id: ${modbus_controller_id}
name: "${entities_name_prefix}-General - Island Protection Enable"
id: "${entities_id_prefix}_General_Island_Protection_Enable"
register_type: holding
address: 83
unit_of_measurement: ""
value_type: S_WORD
- platform: modbus_controller
modbus_controller_id: ${modbus_controller_id}
name: "${entities_name_prefix}-General - Grid Check Source"
name: "${entities_name_prefix}-General - Grid check from Meter or CT"
id: "${entities_id_prefix}_General_Grid_Check_Source"
register_type: holding
address: 344
unit_of_measurement: ""
value_type: U_WORD
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't be easier to have an optionsmap here ?


- platform: modbus_controller
modbus_controller_id: ${modbus_controller_id}
name: "${entities_name_prefix}-General - External Current Clamp Phase"
id: "${entities_id_prefix}_General_External_Current_Clamp_Phase"
register_type: holding
address: 144
unit_of_measurement: ""
value_type: S_WORD

- platform: modbus_controller
modbus_controller_id: ${modbus_controller_id}
name: "${entities_name_prefix}-General - DC Transformer Temperature"
Expand Down
115 changes: 86 additions & 29 deletions modules/status.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
text_sensor:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed ?

- platform: modbus_controller
modbus_controller_id: ${modbus_controller_id}
skip_updates: 2
bitmask: 0
register_type: holding
address: 500
raw_encode: HEXBYTES
id: "${entities_id_prefix}_Status_Running_Status"
name: "${entities_name_prefix}-Status - Running Status"
lambda: |-
uint16_t value = modbus_controller::word_from_hex_str(x, 0);
switch (value) {
case 0: return std::string("standby");
case 1: return std::string("selfcheck");
case 2: return std::string("normal");
case 3: return std::string("alarm");
case 4: return std::string("fault");
default: return std::string("----");
}
return x;

sensor:
- platform: modbus_controller
Expand All @@ -44,8 +23,8 @@ sensor:
- platform: modbus_controller
modbus_controller_id: ${modbus_controller_id}
skip_updates: 2
name: "${entities_name_prefix}-Status - Warning3"
id: "${entities_id_prefix}_Status_Warning3"
name: "${entities_name_prefix}-Status - Error1"
id: "${entities_id_prefix}_Status_Error1"
register_type: holding
address: 555
accuracy_decimals: 0
Expand All @@ -54,8 +33,8 @@ sensor:
- platform: modbus_controller
modbus_controller_id: ${modbus_controller_id}
skip_updates: 2
name: "${entities_name_prefix}-Status - Error1"
id: "${entities_id_prefix}_Status_Error1"
name: "${entities_name_prefix}-Status - Error2"
id: "${entities_id_prefix}_Status_Error2"
register_type: holding
address: 556
accuracy_decimals: 0
Expand All @@ -64,8 +43,8 @@ sensor:
- platform: modbus_controller
modbus_controller_id: ${modbus_controller_id}
skip_updates: 2
name: "${entities_name_prefix}-Status - Error2"
id: "${entities_id_prefix}_Status_Error2"
name: "${entities_name_prefix}-Status - Error3"
id: "${entities_id_prefix}_Status_Error3"
register_type: holding
address: 557
accuracy_decimals: 0
Expand All @@ -74,13 +53,14 @@ sensor:
- platform: modbus_controller
modbus_controller_id: ${modbus_controller_id}
skip_updates: 2
name: "${entities_name_prefix}-Status - Error3"
id: "${entities_id_prefix}_Status_Error3"
name: "${entities_name_prefix}-Status - Error4"
id: "${entities_id_prefix}_Status_Error4"
register_type: holding
address: 558
accuracy_decimals: 0
value_type: U_WORD


- platform: modbus_controller
modbus_controller_id: ${modbus_controller_id}
name: "${entities_name_prefix}-Status - Failure Status of Communication Board"
Expand All @@ -89,3 +69,80 @@ sensor:
address: 548
accuracy_decimals: 0
value_type: U_WORD


text_sensor:
- platform: modbus_controller
modbus_controller_id: ${modbus_controller_id}
skip_updates: 2
bitmask: 0
register_type: holding
address: 500
raw_encode: HEXBYTES
id: "${entities_id_prefix}_Status_Running_Status"
name: "${entities_name_prefix}-Status - Running Status"
lambda: |-
uint16_t value = modbus_controller::word_from_hex_str(x, 0);
switch (value) {
case 0: return std::string("standby");
case 1: return std::string("selfcheck");
case 2: return std::string("normal");
case 3: return std::string("alarm");
case 4: return std::string("fault");
default: return std::string("----");
}
return x;

#new / untested
- platform: template
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very interesting 👍 (but I cannot really evaluate the Logic of the Code without diving into it in Detail & troubleshooting with the Deye Inverter).

name: "${entities_name_prefix}-Status - Inverter Faults"
lambda: |-
static const std::map<int, std::string> faults = {
{7, "DC/DC Soft Start Fault"},
{10, "Auxiliary Power Supply Failure"},
{13, "Working Mode Change"},
{18, "AC Over Current"},
{20, "DC Over Current"},
{22, "Emergency Stop Fault"},
{23, "AC Leakage Current or Transient Over Current"},
{24, "DC Insulation Impedance Failure"},
{26, "DC Busbar Imbalanced"},
{29, "Parallel Communication Fault"},
{35, "No AC Grid"},
{41, "Parallel System Stop"},
{42, "AC Line Low Voltage"},
{46, "Backup Battery Fault"},
{47, "AC Over Frequency"},
{48, "AC Lower Frequency"},
{49, "Backup Battery Fault"},
{56, "DC Busbar Voltage Low"},
{58, "BMS Communication Fault"},
{63, "ARC Fault"},
{64, "Heat Sink Temperature Failure"},
};

std::vector<std::string> errors;
uint16_t registers[4] = {id(${entities_id_prefix}_Status_Error1).state, id(${entities_id_prefix}_Status_Error1).state, id(${entities_id_prefix}_Status_Error3).state, id(${entities_id_prefix}_Status_Error4).state};
int offset = 0;

for (int i = 0; i < 4; i++) {
for (int bit = 0; bit < 16; bit++) {
if (registers[i] & (1 << bit)) {
int fault_code = offset + bit + 1;
if (faults.count(fault_code)) {
errors.push_back("F" + std::to_string(fault_code) + " " + faults.at(fault_code));
} else {
errors.push_back("F" + std::to_string(fault_code));
}
}
}
offset += 16;
}
std::string result;
for (size_t i = 0; i < errors.size(); i++) {
if (i > 0) result += ", ";
result += errors[i];
}

return errors.empty() ? "No Faults" : result;
update_interval: 10s