Skip to content

Commit

Permalink
Remove solaredge_modbus_multi_entries
Browse files Browse the repository at this point in the history
  • Loading branch information
WillCodeForCats committed Aug 23, 2024
1 parent b211ea7 commit 8c0e1ff
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions custom_components/solaredge_modbus_multi/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,13 @@
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry, OptionsFlow
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, CONF_SCAN_INTERVAL
from homeassistant.core import HomeAssistant, callback
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult

from .const import DEFAULT_NAME, DOMAIN, ConfDefaultFlag, ConfDefaultInt, ConfName
from .helpers import host_valid


@callback
def solaredge_modbus_multi_entries(hass: HomeAssistant):
"""Return the hosts already configured."""
return set(
entry.data[CONF_HOST].lower()
for entry in hass.config_entries.async_entries(DOMAIN)
)


class SolaredgeModbusMultiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle a config flow for SolarEdge Modbus Multi."""

Expand All @@ -48,8 +39,6 @@ async def async_step_user(

if not host_valid(user_input[CONF_HOST]):
errors[CONF_HOST] = "invalid_host"
elif user_input[CONF_HOST] in solaredge_modbus_multi_entries(self.hass):
errors[CONF_HOST] = "already_configured"
elif user_input[CONF_PORT] < 1:
errors[CONF_PORT] = "invalid_tcp_port"
elif user_input[CONF_PORT] > 65535:
Expand All @@ -70,6 +59,7 @@ async def async_step_user(
else:
await self.async_set_unique_id(user_input[CONF_HOST])
self._abort_if_unique_id_configured()

return self.async_create_entry(
title=user_input[CONF_NAME], data=user_input
)
Expand Down

0 comments on commit 8c0e1ff

Please sign in to comment.