From d26ff540a139cdf8f4ddd4e9632aa9a3ae2cea64 Mon Sep 17 00:00:00 2001 From: mletenay Date: Thu, 16 May 2024 23:47:02 +0200 Subject: [PATCH] Update to goodwe 0.4.2 --- custom_components/goodwe/__init__.py | 3 +++ custom_components/goodwe/config_flow.py | 5 +++++ custom_components/goodwe/const.py | 2 ++ custom_components/goodwe/manifest.json | 2 +- custom_components/goodwe/sensor.py | 1 - custom_components/goodwe/strings.json | 1 + custom_components/goodwe/translations/en.json | 1 + 7 files changed, 13 insertions(+), 2 deletions(-) diff --git a/custom_components/goodwe/__init__.py b/custom_components/goodwe/__init__.py index f966945..8aae1f9 100644 --- a/custom_components/goodwe/__init__.py +++ b/custom_components/goodwe/__init__.py @@ -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, @@ -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) @@ -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 diff --git a/custom_components/goodwe/config_flow.py b/custom_components/goodwe/config_flow.py index 180571e..de07c74 100644 --- a/custom_components/goodwe/config_flow.py +++ b/custom_components/goodwe/config_flow.py @@ -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, @@ -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, @@ -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 diff --git a/custom_components/goodwe/const.py b/custom_components/goodwe/const.py index d7d48c3..a07823b 100644 --- a/custom_components/goodwe/const.py +++ b/custom_components/goodwe/const.py @@ -1,4 +1,5 @@ """Constants for the Goodwe component.""" + from datetime import timedelta from homeassistant.const import Platform @@ -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" diff --git a/custom_components/goodwe/manifest.json b/custom_components/goodwe/manifest.json index fb7ba28..755aa2e 100644 --- a/custom_components/goodwe/manifest.json +++ b/custom_components/goodwe/manifest.json @@ -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" } diff --git a/custom_components/goodwe/sensor.py b/custom_components/goodwe/sensor.py index 9125622..0b053a0 100644 --- a/custom_components/goodwe/sensor.py +++ b/custom_components/goodwe/sensor.py @@ -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) diff --git a/custom_components/goodwe/strings.json b/custom_components/goodwe/strings.json index f6fab72..95e60df 100644 --- a/custom_components/goodwe/strings.json +++ b/custom_components/goodwe/strings.json @@ -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", diff --git a/custom_components/goodwe/translations/en.json b/custom_components/goodwe/translations/en.json index b2dd5ac..5298ae9 100644 --- a/custom_components/goodwe/translations/en.json +++ b/custom_components/goodwe/translations/en.json @@ -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",