Fix goodwe export limit unit on single phase DT inverters (#90427)

* Fix export limit unit on single phase DT inverters

* Update homeassistant/components/goodwe/number.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
mletenay 2023-03-29 16:01:14 +02:00 committed by GitHub
parent d427c35c87
commit a1c94919de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 7 deletions

View File

@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/goodwe",
"iot_class": "local_polling",
"loggers": ["goodwe"],
"requirements": ["goodwe==0.2.25"]
"requirements": ["goodwe==0.2.29"]
}

View File

@ -39,8 +39,13 @@ class GoodweNumberEntityDescription(
"""Class describing Goodwe number entities."""
def _get_setting_unit(inverter: Inverter, setting: str) -> str:
"""Return the unit of an inverter setting."""
return next((s.unit for s in inverter.settings() if s.id_ == setting), "")
NUMBERS = (
# non DT inverters (limit in W)
# Export limit in W
GoodweNumberEntityDescription(
key="grid_export_limit",
name="Grid export limit",
@ -53,9 +58,9 @@ NUMBERS = (
native_max_value=10000,
getter=lambda inv: inv.get_grid_export_limit(),
setter=lambda inv, val: inv.set_grid_export_limit(val),
filter=lambda inv: type(inv).__name__ != "DT",
filter=lambda inv: _get_setting_unit(inv, "grid_export_limit") != "%",
),
# DT inverters (limit is in %)
# Export limit in %
GoodweNumberEntityDescription(
key="grid_export_limit",
name="Grid export limit",
@ -67,7 +72,7 @@ NUMBERS = (
native_max_value=100,
getter=lambda inv: inv.get_grid_export_limit(),
setter=lambda inv, val: inv.set_grid_export_limit(val),
filter=lambda inv: type(inv).__name__ == "DT",
filter=lambda inv: _get_setting_unit(inv, "grid_export_limit") == "%",
),
GoodweNumberEntityDescription(
key="battery_discharge_depth",

View File

@ -798,7 +798,7 @@ glances_api==0.4.1
goalzero==0.2.1
# homeassistant.components.goodwe
goodwe==0.2.25
goodwe==0.2.29
# homeassistant.components.google_mail
google-api-python-client==2.71.0

View File

@ -614,7 +614,7 @@ glances_api==0.4.1
goalzero==0.2.1
# homeassistant.components.goodwe
goodwe==0.2.25
goodwe==0.2.29
# homeassistant.components.google_mail
google-api-python-client==2.71.0