Skip to content

Commit

Permalink
added support for mgw lan
Browse files Browse the repository at this point in the history
  • Loading branch information
grimmpp committed May 23, 2024
1 parent 6b03e78 commit d96961f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions custom_components/eltako/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import voluptuous as vol

import ipaddress

from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import device_registry as dr
Expand Down Expand Up @@ -119,11 +121,21 @@ async def validate_eltako_conf(self, user_input) -> bool:
if gdc in gateway_selection and gdc in gateway.BAUD_RATE_DEVICE_TYPE_MAPPING:
baud_rate = gateway.BAUD_RATE_DEVICE_TYPE_MAPPING[gdc]
break

# check ip address for esp3 over tcp
if GatewayDeviceType.LAN in gateway_selection:
try:
ip = ipaddress.ip_address(serial_path)
return True
except Exception:
return False
# check serial ports / usb
else:
path_is_valid = await self.hass.async_add_executor_job(
gateway.validate_path, serial_path, baud_rate
)
LOGGER.debug("serial_path: %s, validated with baud rate %d is %s", serial_path, baud_rate, path_is_valid)

path_is_valid = await self.hass.async_add_executor_job(
gateway.validate_path, serial_path, baud_rate
)
LOGGER.debug("serial_path: %s, validated with baud rate %d is %s", serial_path, baud_rate, path_is_valid)
return path_is_valid

def create_eltako_entry(self, user_input):
Expand Down

0 comments on commit d96961f

Please sign in to comment.