Skip to content
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

DOD holding and offline battery DOD settings added #321

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions custom_components/goodwe/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"battery_discharge_depth": {
"default": "mdi:battery-arrow-down"
},
"battery_discharge_depth_offline": {
"default": "mdi:battery-arrow-down"
},
"eco_mode_power": {
"default": "mdi:battery-charging-low"
},
Expand Down Expand Up @@ -64,6 +67,13 @@
"on": "mdi:battery-medium",
"off": "mdi:battery-medium"
}
},
"dod_holding_switch": {
"default": "mdi:battery-arrow-down",
"state": {
"on": "mdi:battery-arrow-down",
"off": "mdi:battery-arrow-down"
}
}
}
}
Expand Down
23 changes: 23 additions & 0 deletions custom_components/goodwe/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ def _get_setting_unit(inverter: Inverter, setting: str) -> str:
return next((s.unit for s in inverter.settings() if s.id_ == setting), "")


async def set_offline_battery_dod(inverter: Inverter, dod: int) -> None:
"""Sets offline battery dod - dod for backup output"""
if 10 <= dod <= 100:
await inverter.write_setting('battery_discharge_depth_offline', 100 - dod)


async def get_offline_battery_dod(inverter: Inverter) -> int:
"""Returns offline battery dod - dod for backup output"""
return 100 - (await inverter.read_setting('battery_discharge_depth_offline'))

NUMBERS = (
# Only one of the export limits are added.
# Availability is checked in the filter method.
Expand Down Expand Up @@ -82,6 +92,19 @@ def _get_setting_unit(inverter: Inverter, setting: str) -> str:
setter=lambda inv, val: inv.set_ongrid_battery_dod(val),
filter=lambda inv: True,
),
GoodweNumberEntityDescription(
key="battery_discharge_depth_offline",
translation_key="battery_discharge_depth_offline",
entity_category=EntityCategory.CONFIG,
native_unit_of_measurement=PERCENTAGE,
native_step=1,
native_min_value=0,
native_max_value=99,
getter=lambda inv: get_offline_battery_dod(inv),
mapper=lambda v: v,
setter=lambda inv, val: set_offline_battery_dod(inv, val),
filter=lambda inv: True,
),
GoodweNumberEntityDescription(
key="eco_mode_power",
translation_key="eco_mode_power",
Expand Down
6 changes: 6 additions & 0 deletions custom_components/goodwe/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"battery_discharge_depth": {
"name": "Depth of discharge (on-grid)"
},
"battery_discharge_depth_offline": {
"name": "Depth of discharge (backup)"
},
"fast_charging_power": {
"name": "Fast charging power"
},
Expand Down Expand Up @@ -77,6 +80,9 @@
},
"backup_supply_switch": {
"name": "Backup supply switch"
},
"dod_holding_switch": {
"name": "DOD holding"
}
}
},
Expand Down
7 changes: 7 additions & 0 deletions custom_components/goodwe/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ class GoodweSwitchEntityDescription(SwitchEntityDescription):
device_class=SwitchDeviceClass.SWITCH,
setting="backup_supply",
),
GoodweSwitchEntityDescription(
key="dod_holding_switch",
translation_key="dod_holding_switch",
entity_category=EntityCategory.CONFIG,
device_class=SwitchDeviceClass.SWITCH,
setting="dod_holding",
),
)


Expand Down
6 changes: 6 additions & 0 deletions custom_components/goodwe/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"battery_discharge_depth": {
"name": "Maximum vybití (v síti)"
},
"battery_discharge_depth_offline": {
"name": "Maximum vybití (backup)"
},
"eco_mode_power": {
"name": "Výkon v ekonomickém režimu"
},
Expand Down Expand Up @@ -89,6 +92,9 @@
},
"backup_supply_switch": {
"name": "Záloha"
},
"dod_holding_switch": {
"name": "Udržovat DOD baterie"
}
}
},
Expand Down
6 changes: 6 additions & 0 deletions custom_components/goodwe/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"battery_discharge_depth": {
"name": "Depth of discharge (on-grid)"
},
"battery_discharge_depth_offline": {
"name": "Depth of discharge (backup)"
},
"eco_mode_power": {
"name": "Eco mode power"
},
Expand Down Expand Up @@ -88,6 +91,9 @@
},
"backup_supply_switch": {
"name": "Backup supply"
},
"dod_holding_switch": {
"name": "DOD holding"
}
}
},
Expand Down
Loading