From e39927d3b482935a3f6079a858676ca05c4bf11d Mon Sep 17 00:00:00 2001 From: nlindn <95648815+nlindn@users.noreply.github.com> Date: Mon, 8 Sep 2025 22:05:31 +0300 Subject: [PATCH] Fix config flow to persist cpids data in HA config entries --- custom_components/ocpp/config_flow.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/custom_components/ocpp/config_flow.py b/custom_components/ocpp/config_flow.py index 4556c305..05764118 100644 --- a/custom_components/ocpp/config_flow.py +++ b/custom_components/ocpp/config_flow.py @@ -167,15 +167,19 @@ async def async_step_cp_user( **user_input, CONF_NUM_CONNECTORS: self._detected_num_connectors, } - self._data[CONF_CPIDS].append({self._cp_id: cp_data}) + cpids_list = self._data.get(CONF_CPIDS, []).copy() + cpids_list.append({self._cp_id: cp_data}) + self._data = {**self._data, CONF_CPIDS: cpids_list} + if user_input[CONF_MONITORED_VARIABLES_AUTOCONFIG]: self._data[CONF_CPIDS][-1][self._cp_id][CONF_MONITORED_VARIABLES] = ( DEFAULT_MONITORED_VARIABLES ) - return self.async_update_reload_and_abort( - self._entry, - data_updates=self._data, + self.hass.config_entries.async_update_entry( + self._entry, data=self._data ) + return self.async_abort(reason="Added/Updated charge point") + else: return await self.async_step_measurands() @@ -201,10 +205,11 @@ async def async_step_measurands(self, user_input=None): self._data[CONF_CPIDS][-1][self._cp_id][CONF_MONITORED_VARIABLES] = ( self._measurands ) - return self.async_update_reload_and_abort( - self._entry, - data_updates=self._data, + + self.hass.config_entries.async_update_entry( + self._entry, data=self._data ) + return self.async_abort(reason="Added/Updated charge point") return self.async_show_form( step_id="measurands",