Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions custom_components/evsemasterudp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion custom_components/evsemasterudp/evse_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down