From f355f0cc6d372c8116875edac7ee759f3c84ebfc Mon Sep 17 00:00:00 2001 From: Colin Robbins Date: Wed, 24 May 2023 12:44:12 +0100 Subject: [PATCH] Add UDP listener in Lightwave (#85385) --- .../components/lightwave/__init__.py | 19 +++++++++++++------ .../components/lightwave/manifest.json | 2 +- requirements_all.txt | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/lightwave/__init__.py b/homeassistant/components/lightwave/__init__.py index e774a27999d..9feefd6e24d 100644 --- a/homeassistant/components/lightwave/__init__.py +++ b/homeassistant/components/lightwave/__init__.py @@ -1,4 +1,6 @@ """Support for device connected via Lightwave WiFi-link hub.""" +import logging + from lightwave.lightwave import LWLink import voluptuous as vol @@ -20,12 +22,13 @@ CONF_PROXY_PORT = "proxy_port" CONF_TRV = "trv" CONF_TRVS = "trvs" DEFAULT_PROXY_PORT = 7878 -DEFAULT_PROXY_IP = "127.0.0.1" DOMAIN = "lightwave" LIGHTWAVE_LINK = f"{DOMAIN}_link" LIGHTWAVE_TRV_PROXY = f"{DOMAIN}_proxy" LIGHTWAVE_TRV_PROXY_PORT = f"{DOMAIN}_proxy_port" +_LOGGER = logging.getLogger(__name__) + CONFIG_SCHEMA = vol.Schema( { @@ -44,9 +47,7 @@ CONFIG_SCHEMA = vol.Schema( vol.Optional( CONF_PROXY_PORT, default=DEFAULT_PROXY_PORT ): cv.port, - vol.Optional( - CONF_PROXY_IP, default=DEFAULT_PROXY_IP - ): cv.string, + vol.Optional(CONF_PROXY_IP): cv.string, vol.Required(CONF_TRVS, default={}): { cv.string: vol.Schema( { @@ -84,9 +85,15 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: if trv := config[DOMAIN][CONF_TRV]: trvs = trv[CONF_TRVS] - proxy_ip = trv[CONF_PROXY_IP] + proxy_ip = trv.get(CONF_PROXY_IP) proxy_port = trv[CONF_PROXY_PORT] - lwlink.set_trv_proxy(proxy_ip, proxy_port) + if proxy_ip is None: + await lwlink.LW_listen() + else: + lwlink.set_trv_proxy(proxy_ip, proxy_port) + _LOGGER.warning( + "Proxy no longer required, remove `proxy_ip` from config to use builtin listener" + ) for platform in PLATFORMS: hass.async_create_task( diff --git a/homeassistant/components/lightwave/manifest.json b/homeassistant/components/lightwave/manifest.json index 86c6a9263f3..d242195a71c 100644 --- a/homeassistant/components/lightwave/manifest.json +++ b/homeassistant/components/lightwave/manifest.json @@ -5,5 +5,5 @@ "documentation": "https://www.home-assistant.io/integrations/lightwave", "iot_class": "assumed_state", "loggers": ["lightwave"], - "requirements": ["lightwave==0.20"] + "requirements": ["lightwave==0.24"] } diff --git a/requirements_all.txt b/requirements_all.txt index 80999fc96bb..3c0b6c24162 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1073,7 +1073,7 @@ life360==5.5.0 lightify==1.0.7.3 # homeassistant.components.lightwave -lightwave==0.20 +lightwave==0.24 # homeassistant.components.limitlessled limitlessled==1.1.3