diff --git a/custom_components/evsemasterudp/__init__.py b/custom_components/evsemasterudp/__init__.py index 5c945ab..08539c9 100644 --- a/custom_components/evsemasterudp/__init__.py +++ b/custom_components/evsemasterudp/__init__.py @@ -58,6 +58,9 @@ async def _async_update_data(self): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up the EVSE integration from a config entry""" + # Check if this entry has been set up before using options + is_first_setup = not entry.options.get("setup_complete", False) + # Retrieve configuration parameters serial = entry.data.get("serial") password = entry.data.get("password") @@ -115,13 +118,20 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) # Notification recommending a restart after installation/update - create( - hass, - f"EVSE Master UDP successfully configured for EVSE {serial}.\n\n" - "It is recommended to restart Home Assistant for optimal operation.", - title="EVSE Master UDP - Installation successful", - notification_id=f"evsemasterudp_setup_{serial}" - ) + if is_first_setup: + # Mark this entry as configured by updating options + hass.config_entries.async_update_entry( + entry, + options={**entry.options, "setup_complete": True} + ) + + create( + hass, + f"EVSE Master UDP successfully configured for EVSE {serial}.\n\n" + "It is recommended to restart Home Assistant for optimal operation.", + title="EVSE Master UDP - Installation successful", + notification_id=f"evsemasterudp_setup_{serial}" + ) return True diff --git a/custom_components/evsemasterudp/evse_client.py b/custom_components/evsemasterudp/evse_client.py index 12d13b3..55d1c84 100644 --- a/custom_components/evsemasterudp/evse_client.py +++ b/custom_components/evsemasterudp/evse_client.py @@ -284,7 +284,7 @@ def _can_start_charge(self, serial: str) -> bool: def _record_charge_state_change(self, serial: str) -> None: """Record a charge stop (to protect the next start)""" self._last_charge_change[serial] = datetime.now() - _LOGGER.debug(f"Charge stop recorded for {serial}") + _LOGGER.debug(f"Charge stop recorded for {serial}") # --- Utility exposure for UI / sensors --- def get_cooldown_remaining(self, serial: str) -> timedelta: