2727from homeassistant .core import callback
2828from homeassistant .helpers import config_validation as cv
2929from homeassistant .helpers .aiohttp_client import async_get_clientsession
30- from homeassistant .helpers import translation
3130
3231from .discovery import discover_enpal_devices , quick_discover_enpal_devices
3332from .wallbox_api import WallboxApiClient
@@ -152,17 +151,6 @@ def __init__(self):
152151 super ().__init__ ()
153152 self ._discovered_devices = []
154153 self ._discovery_running = False
155- self ._translations = None
156-
157- async def _get_translation (self , key : str , default : str ) -> str :
158- """Get translation for a key with fallback to default."""
159- if self ._translations is None :
160- self ._translations = await translation .async_get_translations (
161- self .hass , self .hass .config .language , "config" , {DOMAIN }
162- )
163-
164- full_key = f"component.{ DOMAIN } .config.step.discovery_options.{ key } "
165- return self ._translations .get (full_key , default )
166154
167155 async def async_step_user (self , user_input = None ):
168156 """Handle the initial step - choose between manual and auto-discovery."""
@@ -174,16 +162,12 @@ async def async_step_user(self, user_input=None):
174162 elif user_input .get ("setup_mode" ) == "discover" :
175163 return await self .async_step_discovery ()
176164
177- # Get translated strings for options
178- discover_text = await self ._get_translation ("discover" , "Auto-discover Enpal boxes on network" )
179- manual_text = await self ._get_translation ("manual" , "Manual setup (enter URL)" )
180-
181165 return self .async_show_form (
182166 step_id = "user" ,
183167 data_schema = vol .Schema ({
184168 vol .Required ("setup_mode" , default = "discover" ): vol .In ({
185- "discover" : discover_text ,
186- "manual" : manual_text ,
169+ "discover" : "Auto-discover Enpal boxes on network" ,
170+ "manual" : "Manual setup (enter URL)" ,
187171 })
188172 }),
189173 )
@@ -221,13 +205,12 @@ async def async_step_discovery(self, user_input=None):
221205 # Show discovery results
222206 if not self ._discovered_devices :
223207 _LOGGER .warning ("[Enpal] No Enpal devices discovered" )
224- no_devices_text = await self ._get_translation ("no_devices" , "No devices found - Enter URL manually" )
225208
226209 return self .async_show_form (
227210 step_id = "discovery" ,
228211 data_schema = vol .Schema ({
229212 vol .Required ("discovered_device" ): vol .In ({
230- "manual" : no_devices_text ,
213+ "manual" : "No devices found - Enter URL manually" ,
231214 })
232215 }),
233216 errors = {"base" : "no_devices_found" },
@@ -238,8 +221,7 @@ async def async_step_discovery(self, user_input=None):
238221
239222 # Create selection dict from discovered devices
240223 device_options = {url : url for url in self ._discovered_devices }
241- none_of_these_text = await self ._get_translation ("none_of_these" , "None of these - Enter URL manually" )
242- device_options ["manual" ] = none_of_these_text
224+ device_options ["manual" ] = "None of these - Enter URL manually"
243225
244226 return self .async_show_form (
245227 step_id = "discovery" ,
@@ -303,6 +285,10 @@ async def async_step_configure(self, user_input=None):
303285 errors ["use_wallbox_addon" ] = "wallbox_unreachable"
304286
305287 if not errors :
288+ # Set unique_id based on URL to prevent duplicate entries
289+ await self .async_set_unique_id (self ._url )
290+ self ._abort_if_unique_id_configured ()
291+
306292 return self .async_create_entry (
307293 title = "Enpal Webparser" ,
308294 data = {"use_options_flow" : True },
0 commit comments