diff --git a/custom_components/pysmaplus/__init__.py b/custom_components/pysmaplus/__init__.py index b81dc4b..0076a51 100644 --- a/custom_components/pysmaplus/__init__.py +++ b/custom_components/pysmaplus/__init__.py @@ -41,16 +41,19 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up sma from a config entry.""" # Init the SMA interface - protocol = "https" if entry.data[CONF_SSL] else "http" - url = f"{protocol}://{entry.data[CONF_HOST]}" - verify_ssl = entry.data[CONF_VERIFY_SSL] - # group = entry.data[CONF_GROUP] - #password = entry.data[CONF_PASSWORD] - session = async_get_clientsession(hass, verify_ssl=verify_ssl) + session = None + if entry.data[CONF_ACCESS] == "speedwireinv": + url = entry.data[CONF_HOST] + elif CONF_SSL in entry.data and CONF_HOST in entry.data: + protocol = "https" if entry.data[CONF_SSL] else "http" + url = f"{protocol}://{entry.data[CONF_HOST]}" + session = async_get_clientsession(hass, verify_ssl=entry.data[CONF_VERIFY_SSL]) am = entry.data[CONF_ACCESS] if (am == "speedwire"): am = "speedwireem" + + _LOGGER.debug(f"Setup Entry => URL: {url} User: {entry.data[CONF_GROUP]} Method: {am}") sma = pysma.getDevice(session, url, password = entry.data[CONF_PASSWORD], groupuser = entry.data[CONF_GROUP], accessmethod = am) # sma = pysma.SMA(session, url, password, group) try: diff --git a/custom_components/pysmaplus/config_flow.py b/custom_components/pysmaplus/config_flow.py index 696a660..cc7da31 100644 --- a/custom_components/pysmaplus/config_flow.py +++ b/custom_components/pysmaplus/config_flow.py @@ -24,13 +24,16 @@ async def validate_input( """Validate the user input allows us to connect.""" url = None session = None - if CONF_SSL in data and CONF_HOST in data: + if data[CONF_ACCESS] == "speedwireinv": + url = data[CONF_HOST] + elif CONF_SSL in data and CONF_HOST in data: protocol = "https" if data[CONF_SSL] else "http" url = f"{protocol}://{data[CONF_HOST]}" session = async_get_clientsession(hass, verify_ssl=data[CONF_VERIFY_SSL]) am = data[CONF_ACCESS] if (am == "speedwire"): am = "speedwireem" + _LOGGER.debug(f"Validate URL: {url} User: {data[CONF_GROUP]} Method: {am}") sma = pysma.getDevice(session, url, password = data[CONF_PASSWORD], groupuser = data[CONF_GROUP], accessmethod = am) #sma = pysma.SMA(session, url, data[CONF_PASSWORD], group=data[CONF_GROUP])