-
Notifications
You must be signed in to change notification settings - Fork 3
Decoding of Battery Type and Error Code; small fixes; CT Info and Settings #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d281dd5
9ef7bf7
9332284
4b0b520
8d9232d
b62c00f
d51f8a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
KastB marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
alias: Set CT Ratio Based on Netzanschluss Leistung | ||
description: Adjust sun12k_general_ct_ratio based on netzanschluss_leistung | ||
triggers: | ||
- entity_id: sensor.netzanschluss_leistung | ||
below: -8000 | ||
for: "00:00:10" | ||
trigger: numeric_state | ||
- entity_id: sensor.netzanschluss_leistung | ||
above: -1000 | ||
for: "00:00:10" | ||
trigger: numeric_state | ||
- trigger: time_pattern | ||
seconds: "30" | ||
actions: | ||
- choose: | ||
- conditions: | ||
- condition: numeric_state | ||
entity_id: sensor.netzanschluss_leistung | ||
below: -8000 | ||
sequence: | ||
- target: | ||
entity_id: number.sun12k_general_ct_ratio | ||
data: | ||
value: 1000 | ||
action: number.set_value | ||
- conditions: | ||
- condition: numeric_state | ||
entity_id: sensor.netzanschluss_leistung | ||
above: -1000 | ||
sequence: | ||
- target: | ||
entity_id: number.sun12k_general_ct_ratio | ||
data: | ||
value: 2000 | ||
action: number.set_value | ||
mode: restart |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where I am more concerned. I originally structured the Repository in:
Your Not sure how / if we should restructure everything to make it a bit more Consistent, since it's a bit of à La Carte Menu, where everybody can choose the different Components they would like. And obviously no 2 Configurations will ever be the same. Any Tips ? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
substitutions: | ||
name: deye #name in ESPhome | ||
esp_name: deye | ||
device_description: "Esphome component for Deye sun-12k-sg04lp3" #Description in ESPhome | ||
modbus_controller_id: deye_modbus_controller #just a random name for the modbus controler - this is the high frequency controller for live values | ||
device_type: sun12k #all entities in Home Assistant will start with this text to help identify the entitys | ||
entities_id_prefix: SUN12K | ||
entities_name_prefix: SUN12K | ||
esphome: | ||
name: ${name} | ||
|
||
esp32: | ||
board: wt32-eth01 | ||
framework: | ||
type: esp-idf | ||
|
||
# Enable logging | ||
logger: | ||
level: INFO | ||
baud_rate: 0 | ||
|
||
# Enable Home Assistant API | ||
ota: | ||
platform: esphome | ||
password: !secret ota_password | ||
|
||
# Enable Home Assistant API | ||
api: | ||
encryption: | ||
key: !secret api_encryption | ||
|
||
ethernet: | ||
type: LAN8720 | ||
mdc_pin: GPIO23 | ||
mdio_pin: GPIO18 | ||
clk_mode: GPIO0_IN | ||
phy_addr: 1 | ||
power_pin: GPIO16 | ||
|
||
time: | ||
- platform: homeassistant | ||
|
||
uart: | ||
- id: uart_deye | ||
tx_pin: GPIO17 | ||
rx_pin: GPIO05 | ||
baud_rate: 115200 | ||
stop_bits: 1 | ||
rx_buffer_size: 4096 | ||
|
||
modbus: | ||
- id: modbus_deye | ||
uart_id: uart_deye | ||
|
||
modbus_controller: | ||
- id: ${modbus_controller_id} | ||
address: 0x1 | ||
modbus_id: modbus_deye | ||
setup_priority: -10 | ||
update_interval: 1sec | ||
|
||
packages: | ||
# Different modules for the different sections of the inverter | ||
solar: !include esphome-for-deye/modules/solar.yaml | ||
battery: !include esphome-for-deye/modules/battery.yaml | ||
|
||
load: !include esphome-for-deye/modules/load.yaml | ||
generator: !include esphome-for-deye/modules/generator.yaml # Generator, Micro Inverter or Smart Load | ||
general: !include esphome-for-deye/modules/general.yaml | ||
status: !include esphome-for-deye/modules/status.yaml | ||
internal: !include esphome-for-deye/modules/internal.yaml # Internal CTs Current/Power Measurement | ||
inverter: !include esphome-for-deye/modules/inverter.yaml | ||
ups: !include esphome-for-deye/modules/ups.yaml | ||
out-of-grid: !include esphome-for-deye/modules/out-of-grid.yaml | ||
|
||
# | ||
# Enable for grid-connected systems | ||
grid: !include esphome-for-deye/modules/grid.yaml | ||
external: !include esphome-for-deye/modules/external.yaml # External CTs Current/Power Measurement | ||
|
||
|
||
advanced: !include esphome-for-deye/modules/advanced_readwrite_select.yaml | ||
# Time of Use for Grid-Connected Systems | ||
time-of-use-common: !include esphome-for-deye/modules/time-of-use-common.yaml | ||
# Only Include ONE of these (select OR number) | ||
time-of-use-time-as-select: !include esphome-for-deye/modules/time-of-use-time-as-select.yaml | ||
#time-of-use-time-as-number: !include modules/time-of-use-time-as-number.yaml |
KastB marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
template: | ||
sensor: | ||
- name: "Netzanschluss Leistung" | ||
unit_of_measurement: "W" | ||
state: > | ||
{% set netz_deye = states('sensor.sun12k_external_ct_active_power_total') | float %} | ||
{% set ratio = states('number.sun12k_general_ct_ratio') | float %} | ||
|
||
{{ (netz_deye * 2000 / ratio) | round(1, default=0) }} | ||
device_class: power |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -416,13 +416,13 @@ select: | |
uint16_t select_value = uint16_t(value); | ||
|
||
// Debug | ||
esphome::ESP_LOGI("main","Modbus: Write - Advanced_BMS_Err_Stop set to %d" , select_value); | ||
ESP_LOGI("main","Modbus: Write - Advanced_BMS_Err_Stop set to %d" , select_value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this Change (just dropping the |
||
|
||
// Current Value of the Register (all bits) | ||
uint16_t current_value = id(${entities_id_prefix}_Advanced_Register_178).state; | ||
|
||
// Debug | ||
esphome::ESP_LOGI("main","Modbus: Write - Previous Register 178 Value (unmodified) = %d", current_value); | ||
ESP_LOGI("main","Modbus: Write - Previous Register 178 Value (unmodified) = %d", current_value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this Change (just dropping the |
||
|
||
// Declare Variable | ||
uint16_t write_value = 0; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,18 +10,27 @@ select: | |
"Lead Acid": 0 | ||
"Lithium (BMS)": 1 | ||
|
||
# To be completed | ||
#- platform: modbus_controller | ||
# use_write_multiple: true | ||
# modbus_controller_id: ${modbus_controller_id} | ||
# id: "${entities_id_prefix}_Battery_Lithium_Type" | ||
# name: "${entities_name_prefix}-Battery Lithium Type" | ||
# address: 223 | ||
# bitmask: 0x1 | ||
# value_type: U_WORD | ||
# optionsmap: | ||
# "Pylon (CAN)": 0 | ||
# "": 1 | ||
|
||
- platform: modbus_controller | ||
use_write_multiple: true | ||
modbus_controller_id: ${modbus_controller_id} | ||
id: "${entities_id_prefix}_Battery_Lithium_Type" | ||
name: "${entities_name_prefix}-Battery Lithium Type" | ||
address: 223 | ||
value_type: U_WORD | ||
optionsmap: | ||
"Pylon / Solax / Universal CAN Protocol (CAN)": 0x0000 | ||
"Tianbangda RS485 Modbus": 0x0001 | ||
"KOK Protocol": 0x0002 | ||
"Keith Protocol": 0x0003 | ||
"Topband Protocol": 0x0004 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get |
||
"Pylontech 485 Protocol": 0x0005 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get |
||
"Jelais 485 Protocol": 0x0006 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get |
||
"Sunwoda 485 Protocol": 0x0007 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get |
||
"Xinruineng 485 Protocol": 0x0008 | ||
"Tianbangda 485 Protocol": 0x0009 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get slightly different over Google Translate |
||
"Shenggao Electric CAN Protocol": 0x000A | ||
|
||
|
||
number: | ||
- platform: modbus_controller | ||
|
@@ -90,8 +99,8 @@ number: | |
modbus_controller_id: ${modbus_controller_id} | ||
id: "${entities_id_prefix}_Battery_capacity" | ||
name: "${entities_name_prefix}-Battery capacity" | ||
address: 101 | ||
unit_of_measurement: V | ||
address: 102 | ||
KastB marked this conversation as resolved.
Show resolved
Hide resolved
|
||
unit_of_measurement: Ah | ||
value_type: U_WORD | ||
multiply: 1.0 | ||
min_value: 0.00 | ||
|
@@ -133,6 +142,7 @@ sensor: | |
value_type: S_WORD | ||
filters: | ||
- multiply: 0.1 | ||
|
||
- platform: modbus_controller | ||
modbus_controller_id: ${modbus_controller_id} | ||
skip_updates: 10 | ||
|
@@ -147,6 +157,7 @@ sensor: | |
value_type: S_WORD | ||
filters: | ||
- multiply: 0.1 | ||
|
||
- platform: modbus_controller | ||
modbus_controller_id: ${modbus_controller_id} | ||
skip_updates: 5 | ||
|
@@ -185,7 +196,7 @@ sensor: | |
address: 586 | ||
unit_of_measurement: "°C" | ||
accuracy_decimals: 1 | ||
value_type: U_WORD | ||
value_type: S_WORD | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This kinda makes Sense, however the Reference Guide indicates |
||
filters: | ||
- offset: -1000 | ||
- multiply: 0.1 | ||
|
@@ -226,6 +237,7 @@ sensor: | |
accuracy_decimals: 0 | ||
value_type: S_WORD | ||
|
||
|
||
- platform: modbus_controller | ||
modbus_controller_id: ${modbus_controller_id} | ||
name: "${entities_name_prefix}-Battery Output Current" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ sensor: | |
accuracy_decimals: 0 | ||
value_type: S_WORD | ||
|
||
|
||
|
||
- platform: modbus_controller | ||
modbus_controller_id: ${modbus_controller_id} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you remove the High Refresh Rate Controller for this Signal ? |
||
skip_updates: 2 | ||
|
@@ -23,6 +25,8 @@ sensor: | |
accuracy_decimals: 0 | ||
value_type: S_WORD | ||
|
||
|
||
|
||
- platform: modbus_controller | ||
modbus_controller_id: ${modbus_controller_id} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you remove the High Refresh Rate Controller for this Signal ? |
||
skip_updates: 2 | ||
|
@@ -35,6 +39,8 @@ sensor: | |
accuracy_decimals: 0 | ||
value_type: S_WORD | ||
|
||
|
||
|
||
- platform: modbus_controller | ||
modbus_controller_id: ${modbus_controller_id} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you remove the High Refresh Rate Controller for this Signal ? |
||
skip_updates: 2 | ||
|
@@ -47,6 +53,8 @@ sensor: | |
accuracy_decimals: 0 | ||
value_type: S_WORD | ||
|
||
|
||
|
||
# External Power Grid - Total Apparent Power | ||
- platform: modbus_controller | ||
modbus_controller_id: ${modbus_controller_id} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you remove the High Refresh Rate Controller for this Signal ? |
||
|
@@ -58,4 +66,4 @@ sensor: | |
unit_of_measurement: "VA" | ||
state_class: "measurement" | ||
accuracy_decimals: 0 | ||
value_type: S_WORD | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the Change ? Did you remove an empty NewLine ? |
||
value_type: S_WORD |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,15 @@ binary_sensor: | |
bitmask: 0x1 | ||
|
||
sensor: | ||
# New - To be Tested | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 - 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't be easier to have an |
||
|
||
- platform: modbus_controller | ||
modbus_controller_id: ${modbus_controller_id} | ||
name: "${entities_name_prefix}-General - DC Transformer Temperature" | ||
|
@@ -138,3 +146,16 @@ select: | |
"Selling first": 0 | ||
"Zero export to load": 1 | ||
"Zero export to CT": 2 | ||
|
||
|
||
number: | ||
- platform: modbus_controller | ||
use_write_multiple: true | ||
modbus_controller_id: ${modbus_controller_id} | ||
id: "${entities_id_prefix}_General_CT_Ratio" | ||
name: "${entities_name_prefix}-General - CT Ratio" | ||
address: 347 | ||
value_type: U_WORD | ||
multiply: 1.0 | ||
min_value: 100.00 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am Off-Grid so I don't know if this is Correct. Are you sure it's Correct ? According to the Reference Guide, they Provide an Example (?) Value of 30 for 30:1. Why is the |
||
max_value: 10000.00 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,9 +47,7 @@ sensor: | |
unit_of_measurement: "W" | ||
state_class: "measurement" | ||
accuracy_decimals: 1 | ||
filters: | ||
- multiply: 0.1 | ||
value_type: U_WORD | ||
value_type: S_WORD | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did I get the Data Type wrong ? The Reference Guide didn't specify neither U16 nor S16 and I never tested the Generator, so it could very well be. Did you check your Results ? |
||
|
||
- platform: modbus_controller | ||
modbus_controller_id: ${modbus_controller_id} | ||
|
@@ -60,7 +58,7 @@ sensor: | |
unit_of_measurement: "W" | ||
state_class: "measurement" | ||
accuracy_decimals: 1 | ||
value_type: U_WORD | ||
value_type: S_WORD | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did I get the Data Type wrong ? The Reference Guide didn't specify neither U16 nor S16 and I never tested the Generator, so it could very well be. Did you check your Results ? |
||
|
||
- platform: modbus_controller | ||
modbus_controller_id: ${modbus_controller_id} | ||
|
@@ -71,7 +69,7 @@ sensor: | |
unit_of_measurement: "W" | ||
state_class: "measurement" | ||
accuracy_decimals: 1 | ||
value_type: U_WORD | ||
value_type: S_WORD | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did I get the Data Type wrong ? The Reference Guide didn't specify neither U16 nor S16 and I never tested the Generator, so it could very well be. Did you check your Results ? |
||
|
||
- platform: modbus_controller | ||
modbus_controller_id: ${modbus_controller_id} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you remove the High Refresh Rate Controller for this Signal ? |
||
|
@@ -82,4 +80,16 @@ sensor: | |
unit_of_measurement: "W" | ||
state_class: "measurement" | ||
accuracy_decimals: 1 | ||
value_type: U_WORD | ||
value_type: S_WORD | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you test and check your Results of this new Parameter ? |
||
|
||
number: | ||
- platform: modbus_controller | ||
use_write_multiple: true | ||
modbus_controller_id: ${modbus_controller_id} | ||
id: "${entities_id_prefix}_Generator_Minimum_Solar_Power" | ||
name: "${entities_name_prefix}-Generator Minimum Solar Power to Enable" | ||
address: 139 | ||
unit_of_measurement: W | ||
value_type: U_WORD | ||
min_value: 0 | ||
max_value: 8000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice that we could reconfigure the Modbus Baudrate to 115200 ...
In that Case we can definitively increase the refresh Rate and avoid that the ESP32 crashes / gets stuck if refreshing too frequently.
On my Side I have them maybe disappearing from my Network for a Minute or Two each Day, but I thought that it was more related to the DHCP Server renewing IP Address rather than a ESP32 Crash / Reboot (and I still don't think it's that !).
Would that be in Page 2? I cannot see that Setting in the Advanced Menu in the Manual of the Deye Inverter.