File tree Expand file tree Collapse file tree
custom_components/ecoflow_powerocean Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -139,7 +139,13 @@ async def async_step_init(
139139 ) -> ConfigFlowResult :
140140 """Zeigt das Options-Formular und speichert Änderungen."""
141141 if user_input is not None :
142- return self .async_create_entry (data = user_input )
142+ # NumberSelector liefert je nach UI-Pfad manchmal float (z. B. 2.0).
143+ # Für die weitere Verarbeitung benötigen wir einen sicheren int-Wert.
144+ normalized_input = dict (user_input )
145+ normalized_input [CONF_NUM_BATTERY_PACKS ] = int (
146+ normalized_input [CONF_NUM_BATTERY_PACKS ]
147+ )
148+ return self .async_create_entry (data = normalized_input )
143149
144150 current_packs = int (
145151 self .config_entry .options .get (
Original file line number Diff line number Diff line change 11{
22 "domain" : " ecoflow_powerocean" ,
33 "name" : " EcoFlow PowerOcean" ,
4- "version" : " 0.3.4 " ,
4+ "version" : " 0.3.5 " ,
55 "codeowners" : [],
66 "config_flow" : true ,
77 "documentation" : " https://github.com/Feberdin/ecoflow-powerocean-ha" ,
Original file line number Diff line number Diff line change 6161 DEFAULT_NUM_BATTERY_PACKS ,
6262 DOMAIN ,
6363 MANUFACTURER ,
64+ MAX_BATTERY_PACKS ,
6465 MODEL ,
6566)
6667from .coordinator import EcoFlowCoordinator
@@ -753,10 +754,23 @@ async def async_setup_entry(
753754 coordinator : EcoFlowCoordinator = hass .data [DOMAIN ][entry .entry_id ]
754755 serial = entry .data [CONF_SERIAL_NUMBER ]
755756 # Options haben Vorrang vor initialen Konfigurationsdaten
756- num_packs : int = entry .options .get (
757+ raw_num_packs = entry .options .get (
757758 CONF_NUM_BATTERY_PACKS ,
758759 entry .data .get (CONF_NUM_BATTERY_PACKS , DEFAULT_NUM_BATTERY_PACKS ),
759760 )
761+ try :
762+ num_packs = int (raw_num_packs )
763+ except (TypeError , ValueError ):
764+ _LOGGER .warning (
765+ "Ungültiger Wert für %s: %r. Fallback auf Standard: %d" ,
766+ CONF_NUM_BATTERY_PACKS ,
767+ raw_num_packs ,
768+ DEFAULT_NUM_BATTERY_PACKS ,
769+ )
770+ num_packs = DEFAULT_NUM_BATTERY_PACKS
771+
772+ # Defensive Begrenzung, damit keine ungültigen Sensor-Indizes entstehen.
773+ num_packs = max (1 , min (MAX_BATTERY_PACKS , num_packs ))
760774
761775 device_info = DeviceInfo (
762776 identifiers = {(DOMAIN , serial )},
You can’t perform that action at this time.
0 commit comments