Skip to content

Commit

Permalink
Update to goodwe 0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mletenay committed May 16, 2024
1 parent 07bb738 commit d26ff54
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions custom_components/goodwe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from homeassistant.helpers.entity import DeviceInfo

from .const import (
CONF_KEEP_ALIVE,
CONF_MODEL_FAMILY,
CONF_NETWORK_RETRIES,
CONF_NETWORK_TIMEOUT,
Expand All @@ -28,6 +29,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.data.setdefault(DOMAIN, {})
host = entry.options.get(CONF_HOST, entry.data[CONF_HOST])
protocol = entry.options.get(CONF_PROTOCOL, entry.data[CONF_PROTOCOL])
keep_alive = entry.options.get(CONF_KEEP_ALIVE, entry.data[CONF_PROTOCOL] != "TCP")
model_family = entry.options.get(CONF_MODEL_FAMILY, entry.data[CONF_MODEL_FAMILY])
network_retries = entry.options.get(CONF_NETWORK_RETRIES, DEFAULT_NETWORK_RETRIES)
network_timeout = entry.options.get(CONF_NETWORK_TIMEOUT, DEFAULT_NETWORK_TIMEOUT)
Expand All @@ -42,6 +44,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
timeout=network_timeout,
retries=network_retries,
)
inverter.keep_alive = keep_alive
except InverterError as err:
raise ConfigEntryNotReady from err

Expand Down
5 changes: 5 additions & 0 deletions custom_components/goodwe/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from homeassistant.helpers import config_validation as cv

from .const import (
CONF_KEEP_ALIVE,
CONF_MODEL_FAMILY,
CONF_NETWORK_RETRIES,
CONF_NETWORK_TIMEOUT,
Expand All @@ -36,6 +37,7 @@
{
vol.Required(CONF_HOST): str,
vol.Required(CONF_PROTOCOL): vol.In(PROTOCOL_CHOICES),
vol.Required(CONF_KEEP_ALIVE): cv.boolean,
vol.Required(CONF_MODEL_FAMILY): str,
vol.Optional(CONF_SCAN_INTERVAL): int,
vol.Optional(CONF_NETWORK_RETRIES): cv.positive_int,
Expand Down Expand Up @@ -65,6 +67,9 @@ async def async_step_init(self, user_input: dict | None = None) -> FlowResult:
{
CONF_HOST: self.config_entry.data[CONF_HOST],
CONF_PROTOCOL: self.config_entry.data[CONF_PROTOCOL],
CONF_KEEP_ALIVE: self.config_entry.options.get(
CONF_KEEP_ALIVE, self.config_entry.data[CONF_PROTOCOL] != "TCP"
),
CONF_MODEL_FAMILY: self.config_entry.data[CONF_MODEL_FAMILY],
CONF_SCAN_INTERVAL: self.config_entry.options.get(
CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL
Expand Down
2 changes: 2 additions & 0 deletions custom_components/goodwe/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Constants for the Goodwe component."""

from datetime import timedelta

from homeassistant.const import Platform
Expand All @@ -19,6 +20,7 @@
DEFAULT_NETWORK_RETRIES = 10
DEFAULT_NETWORK_TIMEOUT = 1

CONF_KEEP_ALIVE = "keep_alive"
CONF_MODEL_FAMILY = "model_family"
CONF_NETWORK_RETRIES = "network_retries"
CONF_NETWORK_TIMEOUT = "network_timeout"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/goodwe/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"iot_class": "local_polling",
"issue_tracker": "/~https://github.com/mletenay/home-assistant-goodwe-inverter/issues",
"loggers": ["goodwe"],
"requirements": ["goodwe==0.4.1"],
"requirements": ["goodwe==0.4.2"],
"version": "0.9.9.20"
}
1 change: 0 additions & 1 deletion custom_components/goodwe/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ async def async_setup_entry(
entities.extend(
InverterSensor(coordinator, device_info, inverter, sensor)
for sensor in inverter.sensors()
if not sensor.id_.startswith("xx")
)

async_add_entities(entities)
Expand Down
1 change: 1 addition & 0 deletions custom_components/goodwe/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"data": {
"host": "[%key:common::config_flow::data::ip%]",
"protocol": "Protocol",
"keep_alive": "TCP Keep alive",
"model_family": "Inverter Family (optional)",
"scan_interval": "Scan interval (s)",
"network_retries": "Network retry attempts",
Expand Down
1 change: 1 addition & 0 deletions custom_components/goodwe/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"data": {
"host": "Hostname / IP Address",
"protocol": "Protocol",
"keep_alive": "TCP Keep alive",
"model_family": "Inverter Family",
"scan_interval": "Scan interval (s)",
"network_retries": "Network retry attempts",
Expand Down

0 comments on commit d26ff54

Please sign in to comment.