Skip to content

Commit

Permalink
feat: Battery parameters made configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Jul 18, 2024
1 parent b836ff0 commit 6d3367d
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 114 deletions.
3 changes: 3 additions & 0 deletions custom_components/solarman/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def format_exception(e):
def Raise(exception) -> None:
raise exception

def get_numbe(value):
return int(value) if isinstance(value, int) or (isinstance(value, float) and value.is_integer()) else float(value)

def get_number(value, digits):
return int(value) if isinstance(value, int) or (isinstance(value, float) and value.is_integer()) else (n if (n := round(value, digits)) and not n.is_integer() else int(n))

Expand Down
78 changes: 41 additions & 37 deletions custom_components/solarman/inverter_definitions/deye_sg01hp3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,65 +132,80 @@ parameters:
value: "Lithium"

- name: "Battery Equalization"
attribute:
class: "voltage"
state_class: "measurement"
uom: "V"
scale: 0.01
rule: 1
registers: [0x0063]
configurable:
min: 38
max: 61
step: 0.1
icon: "mdi:battery"
range:
min: 3800
max: 6100

- name: "Battery Absorption"
attribute:
class: "voltage"
state_class: "measurement"
uom: "V"
scale: 0.01
rule: 1
registers: [0x0064]
configurable:
min: 38
max: 61
step: 0.1
icon: "mdi:battery"
range:
min: 3800
max: 6100

- name: "Battery Float"
attribute:
class: "voltage"
state_class: "measurement"
uom: "V"
scale: 0.01
rule: 1
registers: [0x0065]
configurable:
min: 38
max: 61
step: 0.1
icon: "mdi:battery"
range:
min: 3800
max: 6100

- name: "Battery Capacity"
attribute:
class: ""
state_class: "measurement"
uom: "Ah"
scale: 1
rule: 1
registers: [0x0066]
configurable:
min: 0
max: 2000
icon: "mdi:battery"
range:
min: 0
max: 2000
attributes: ["Battery Corrected Capacity"]

- name: "Battery Empty"
attribute:
class: "voltage"
state_class: "measurement"
uom: "V"
scale: 0.01
rule: 1
registers: [0x0067]
configurable:
min: 38
max: 61
step: 0.1
icon: "mdi:battery"

- name: "Zero Export power"
Expand All @@ -206,99 +221,104 @@ parameters:
icon: "mdi:transmission-tower-import"

- name: "Battery Equalization Cycle"
attribute:
class: "duration"
state_class: "measurement"
uom: "d"
display_precision: 0
scale: 1
rule: 1
registers: [0x0069]
configurable:
min: 0
max: 90
icon: "mdi:battery"
range:
min: 0
max: 90

- name: "Battery Equalization Time"
attribute:
class: "duration"
state_class: "measurement"
uom: "h"
scale: 0.5
rule: 1
registers: [0x006A]
configurable:
min: 0
max: 10
icon: "mdi:battery"
range:
min: 0
max: 20

- name: "Battery Temperature Compensation"
attribute:
class: ""
state_class: "measurement"
uom: "mV/*C"
scale: 1
rule: 2
registers: [0x006B]
configurable:
min: 0
max: 50
step: 0.1
icon: "mdi:battery"
range:
min: 0
max: 50

- name: "Battery Max Charging Current"
attribute:
class: "current"
state_class: "measurement"
uom: "A"
scale: 1
rule: 1
registers: [0x006C]
configurable:
min: 0
max: 185
icon: "mdi:battery"
range:
min: 0
max: 185

- name: "Battery Max Discharging Current"
attribute:
class: "current"
state_class: "measurement"
uom: "A"
scale: 1
rule: 1
registers: [0x006D]
configurable:
min: 0
max: 185
icon: "mdi:battery"
range:
min: 0
max: 185

- name: "Battery Grid Charging Current"
attribute:
class: "current"
state_class: "measurement"
uom: "A"
scale: 1
rule: 1
registers: [0x0080]
configurable:
min: 0
max: 185
icon: "mdi:battery"
range:
min: 0
max: 185

- name: "Battery Grid Charging"
attribute:
class: "enum"
class: "switch"
state_class: ""
uom: ""
scale: 1
rule: 1
registers: [0x0082]
icon: "mdi:battery"
options: ["Disabled", "Enabled"]
lookup:
- key: 0x0000
value: "Disabled"
- key: 0x0001
value: "Enabled"

- name: "SmartLoad Mode"
class: "enum"
Expand Down Expand Up @@ -980,23 +1000,7 @@ parameters:
validation:
min: 0
max: 101
attributes:
[
"Battery Control Mode",
"Battery Capacity",
"Battery Corrected Capacity",
"Battery Absorption",
"Battery Float",
"Battery Empty",
"Battery Equalization",
"Battery Equalization Cycle",
"Battery Equalization Time",
"Battery Temperature Compensation",
"Battery Max Charging Current",
"Battery Max Discharging Current",
"Battery Grid Charging",
"Battery Grid Charging Current",
]
attributes: ["Battery Control Mode"]

# Battery - The power of battery is S16bit
- name: "Battery Power"
Expand Down
Loading

0 comments on commit 6d3367d

Please sign in to comment.