Skip to content

Commit 6777789

Browse files
author
Antonio ...
committed
Make EV live activities opt-in
1 parent bb82d2f commit 6777789

19 files changed

Lines changed: 175 additions & 16 deletions

‎README.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Most projects target one charger brand or assume a single-phase home. EV Smart C
5656
5757
> **🆕 New in v2.6.0** — mass bug-fix & improvement release (issues #36–#42). Highlights: an optional **`grid_available` binary sensor** ([issue #36](https://github.com/antbald/ha-ev-smart-charger/issues/36)) stops Night Smart Charge grid mode during a **grid outage** so it doesn't drain the home battery on hybrid Battery First / UPS inverters (fail-safe: an unavailable sensor never triggers a false stop); a **customizable nighttime window** ([issue #42](https://github.com/antbald/ha-ev-smart-charger/issues/42)) via two opt-in offset numbers (start before sunset / end after sunrise); and a big **INFO log-noise reduction** ([issue #40](https://github.com/antbald/ha-ev-smart-charger/issues/40)) — idle ticks no longer flood the HA log. Also: valid day icons (#37), faster Generic-charger ramp-up (#38), a consistent Hybrid full-battery threshold (#39), and a cleaner telemetry log (#41). **All backward compatible** — the two features are opt-in.
5858
59-
> **📱 New in v2.7.3** — EV charging **Live Activities / Live Updates** for the Home Assistant Companion app. When mobile notify services are configured, the integration keeps a single `evsc_ev_charging` activity updated for Boost Charge, Night Smart Charge, Solar Surplus, Force Charge, and normal charging detected by the shared `charging_power` / charger-status SSOT. Updates are throttled to protect the iOS push budget and the activity closes only after charging has stopped for two monitor ticks.
59+
> **📱 New in v2.7.3+** — EV charging **Live Activities / Live Updates** for the Home Assistant Companion app. When enabled from **Dashboard → Settings → Notifications**, the integration keeps a single `evsc_ev_charging` activity updated for Boost Charge, Night Smart Charge, Solar Surplus, Force Charge, and normal charging detected by the shared `charging_power` / charger-status SSOT. Updates are throttled to protect the iOS push budget and the activity closes only after charging has stopped for two monitor ticks. **Default: OFF**.
6060
6161
---
6262

@@ -445,7 +445,7 @@ Used by Night Smart Charge to decide between home battery and grid charging. If
445445

446446
The `person` entity enables presence-based filtering: notifications are only sent when the car owner is home. If the entity is unavailable, notifications are sent anyway as a fail-safe.
447447

448-
The same mobile notify services are used for EV charging Live Activities / Live Updates on supported Companion App versions. No extra helper is required.
448+
The same mobile notify services can be used for EV charging Live Activities / Live Updates on supported Companion App versions. They are OFF by default and can be enabled later from the generated dashboard.
449449

450450
### Step 6 — External Connectors
451451

@@ -1169,7 +1169,9 @@ If the `person` entity is unavailable, notifications are always sent (fail-safe
11691169

11701170
### EV Charging Live Activities / Live Updates
11711171

1172-
On Home Assistant Core 2026.7+ with a supported Companion App, EV Smart Charger sends a single live notification tagged `evsc_ev_charging`.
1172+
On Home Assistant Core 2026.7+ with a supported Companion App, EV Smart Charger can send a single live notification tagged `evsc_ev_charging`.
1173+
1174+
Enable it with `switch.evsc_live_activities_enabled` or from **Dashboard → Settings → Notifications → EV Live Activities**. The default is **OFF**, so upgrades never start Live Activities without an explicit opt-in.
11731175

11741176
It starts or updates automatically when the EV is drawing current, including:
11751177

@@ -1190,6 +1192,7 @@ Updates are intentionally coarse: the integration reuses meaningful state change
11901192
| `evsc_notify_smart_blocker_enabled` | ON | Notifications when Smart Charger Blocker stops the charger |
11911193
| `evsc_notify_priority_balancer_enabled` | ON | Notifications when Priority Balancer state changes |
11921194
| `evsc_notify_night_charge_enabled` | ON | Notifications when Night Smart Charge starts or completes |
1195+
| `evsc_live_activities_enabled` | OFF | EV charging Live Activities / Live Updates |
11931196

11941197
---
11951198

‎RELEASE_v2.7.4.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Release v2.7.4
2+
3+
## Changed
4+
5+
- EV charging Live Activities / Live Updates are now opt-in instead of automatic.
6+
- Added `evsc_live_activities_enabled`, default OFF, to control Live Activities from the generated dashboard.
7+
- The normal charging monitor clears the existing `evsc_ev_charging` activity once when the toggle is turned OFF.
8+
- Bumped integration version metadata to `2.7.4`.
9+
10+
## Documentation
11+
12+
- Updated README, frontend dashboard docs, and maintainer docs for the new default-OFF behavior.
13+
14+
## Tests
15+
16+
- `./.venv/bin/python -m pytest -q`

‎custom_components/ev_smart_charger/const.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# ========== INTEGRATION METADATA ==========
44
DOMAIN = "ev_smart_charger"
5-
VERSION = "2.7.3"
5+
VERSION = "2.7.4"
66
DEFAULT_NAME = "EV Smart Charger"
77
FRONTEND_URL_BASE = "/api/ev_smart_charger/frontend"
88
FRONTEND_CARD_FILENAME = "ev-smart-charger-dashboard.js"
@@ -189,6 +189,7 @@
189189
HELPER_NOTIFY_SMART_BLOCKER_SUFFIX = "evsc_notify_smart_blocker_enabled"
190190
HELPER_NOTIFY_PRIORITY_BALANCER_SUFFIX = "evsc_notify_priority_balancer_enabled"
191191
HELPER_NOTIFY_NIGHT_CHARGE_SUFFIX = "evsc_notify_night_charge_enabled"
192+
HELPER_LIVE_ACTIVITIES_ENABLED_SUFFIX = "evsc_live_activities_enabled"
192193

193194
# Persistent notification IDs (fixed → updated in place, never stacked)
194195
# v2.5.0 (issue #35): surfaced when Priority Balancer is disabled while home
@@ -422,21 +423,23 @@
422423
# number (evsc_max_battery_discharge_for_ev) → 66. v2.3.0 (issue #32) adds 1
423424
# always-created number (evsc_night_pv_handoff_threshold) → 67. v2.6.0 (issue #42)
424425
# adds 2 always-created numbers (nighttime sunset/sunrise offsets) → 69.
426+
# v2.7.4 adds 1 always-created switch (live activities enabled) → 70.
425427
# COUPLING (issue #22): the disabled-helper tolerance in
426428
# __init__._async_wait_for_helper_registration assumes this equals the number
427429
# of entities actually created when nothing is disabled. If it drifts above
428430
# reality (cf. v1.6.20), a single user-disabled entity turns the tolerant
429431
# startup path back into a hard ConfigEntryNotReady. Keep this in sync.
430-
TOTAL_INTEGRATION_ENTITIES = 69
432+
TOTAL_INTEGRATION_ENTITIES = 70
431433
# Verified count (v2.3.0): 53 entities when running in PV-only mode.
432434
# Unchanged in v2.1.0: the discharge number is battery-only (skipped in PV-only mode).
433435
# v2.3.0 (issue #32): evsc_night_pv_handoff_threshold is NOT battery-only → +1 → 53.
434436
# v2.6.0 (issue #42): 2 nighttime offset numbers are NOT battery-only → +2 → 55.
437+
# v2.7.4: live activities enabled switch is NOT battery-only → +1 → 56.
435438
# Skipped helpers (13): 2 switches (use_home_battery, preserve_home_battery),
436439
# 3 numbers (home_battery_min_soc, battery_support_amperage, battery_support_sunset_buffer),
437440
# 7 daily home min SOC numbers (Monday–Sunday), 1 sensor (today_home_target).
438441
# Hybrid Mode entities are still created in PV-only mode but stay IDLE (requires soc_home).
439-
TOTAL_INTEGRATION_ENTITIES_NO_BATTERY = 55
442+
TOTAL_INTEGRATION_ENTITIES_NO_BATTERY = 56
440443

441444

442445
def has_home_battery(config: dict) -> bool:

‎custom_components/ev_smart_charger/frontend/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pv_forecast_entity: sensor.pv_forecast_tomorrow
114114
| **Solar Surplus** | check interval, grid import threshold/delay, surplus drop delay, solar max amperage, use home battery, home battery min SOC, battery support amperage, battery support sunset buffer |
115115
| **Hybrid Inverter Mode** (v1.8.0) | `evsc_hybrid_inverter_mode`, `evsc_hybrid_battery_full_threshold`, `evsc_hybrid_probe_duration`, `evsc_hybrid_max_import_duration`, `evsc_hybrid_max_failed_probes` |
116116
| **Safety / Protection** | `evsc_priority_balancer_enabled`, `evsc_smart_charger_blocker_enabled` |
117-
| **Notifications** | `evsc_notify_smart_blocker_enabled`, `evsc_notify_priority_balancer_enabled`, `evsc_notify_night_charge_enabled` |
117+
| **Notifications** | `evsc_notify_smart_blocker_enabled`, `evsc_notify_priority_balancer_enabled`, `evsc_notify_night_charge_enabled`, `evsc_live_activities_enabled` (default OFF) |
118118
| **Logging** | `evsc_trace_logging_enabled`, `evsc_enable_file_logging`, displays current `evsc_log_file_path` |
119119
| **Diagnostics panel** | `evsc_diagnostic`, `evsc_solar_surplus_diagnostic`, `evsc_hybrid_inverter_diagnostic`, `evsc_cached_ev_soc` |
120120

‎custom_components/ev_smart_charger/frontend/ev-smart-charger-dashboard.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const DOMAIN_SUFFIXES = {
124124
notifySmartBlocker: ["switch", "evsc_notify_smart_blocker_enabled"],
125125
notifyPriorityBalancer: ["switch", "evsc_notify_priority_balancer_enabled"],
126126
notifyNightCharge: ["switch", "evsc_notify_night_charge_enabled"],
127+
liveActivities: ["switch", "evsc_live_activities_enabled"],
127128

128129
// ── Logging (v1.3.25 / v1.4.15)
129130
traceLogging: ["switch", "evsc_trace_logging_enabled"],
@@ -487,6 +488,14 @@ const SETTINGS_CATALOG = [
487488
nl: "Melden wanneer Night Smart Charge een sessie start (BATTERY of GRID).",
488489
},
489490
hint: { en: "Filtered by owner presence", it: "Filtrate per presenza del proprietario", nl: "Gefilterd op aanwezigheid eigenaar" } },
491+
{ entityKey: "liveActivities", kind: "toggle",
492+
name: { en: "EV Live Activities", it: "Live Activities EV", nl: "EV Live Activities" },
493+
desc: {
494+
en: "Show EV charging progress on the Companion app Lock Screen / Dynamic Island when supported.",
495+
it: "Mostra l'avanzamento della ricarica EV su Lock Screen / Dynamic Island della Companion app quando supportato.",
496+
nl: "Toon EV-laadvoortgang op het vergrendelscherm / Dynamic Island van de Companion-app wanneer ondersteund.",
497+
},
498+
hint: { en: "Default off", it: "Default off", nl: "Standaard uit" } },
490499
],
491500
},
492501
{

‎custom_components/ev_smart_charger/live_activity_monitor.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def __init__(
4848
self._timer_unsub = None
4949
self._inactive_ticks = 0
5050
self._live_activity_active = False
51+
self._last_enabled = False
5152

5253
async def async_setup(self) -> None:
5354
"""Start the coarse polling monitor."""
@@ -71,6 +72,17 @@ async def async_remove(self) -> None:
7172

7273
async def _async_tick(self, now=None) -> None:
7374
"""Update or clear the Live Activity based on normal charging state."""
75+
enabled = self._mobile_notifier.is_live_activity_enabled()
76+
if not enabled:
77+
if self._last_enabled:
78+
await self._mobile_notifier.clear_ev_charging_live_activity()
79+
self._inactive_ticks = 0
80+
self._live_activity_active = False
81+
self._last_enabled = False
82+
return
83+
84+
self._last_enabled = True
85+
7486
if self._is_boost_or_night_active():
7587
self._inactive_ticks = 0
7688
self._live_activity_active = False

‎custom_components/ev_smart_charger/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
"iot_class": "local_push",
1212
"issue_tracker": "https://github.com/antbald/ha-ev-smart-charger/issues",
1313
"requirements": [],
14-
"version": "2.7.3"
14+
"version": "2.7.4"
1515
}

‎custom_components/ev_smart_charger/strings.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@
452452
"evsc_notify_night_charge_enabled": {
453453
"name": "Notify night charge"
454454
},
455+
"evsc_live_activities_enabled": {
456+
"name": "Live activities"
457+
},
455458
"evsc_enable_file_logging": {
456459
"name": "Enable file logging"
457460
},

‎custom_components/ev_smart_charger/switch.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
DEFAULT_CAR_READY_WEEKEND,
1717
DEFAULT_HYBRID_INVERTER_MODE,
1818
HELPER_HYBRID_INVERTER_MODE_SUFFIX,
19+
HELPER_LIVE_ACTIVITIES_ENABLED_SUFFIX,
1920
HELPER_PRESERVE_HOME_BATTERY_SUFFIX,
2021
HELPER_TRACE_LOGGING_ENABLED_SUFFIX,
2122
HELPER_USE_HOME_BATTERY_SUFFIX,
@@ -64,6 +65,7 @@ async def async_setup_entry(
6465
("evsc_notify_smart_blocker_enabled", "Notify Smart Blocker", "mdi:bell-outline", True),
6566
("evsc_notify_priority_balancer_enabled", "Notify Priority Balancer", "mdi:bell-outline", True),
6667
("evsc_notify_night_charge_enabled", "Notify Night Charge", "mdi:bell-outline", True),
68+
(HELPER_LIVE_ACTIVITIES_ENABLED_SUFFIX, "Live Activities", "mdi:progress-bolt", False),
6769
# Logging switches
6870
("evsc_enable_file_logging", "Enable File Logging", "mdi:file-document-outline", False),
6971
(HELPER_TRACE_LOGGING_ENABLED_SUFFIX, "Trace Logging", "mdi:timeline-text-outline", False),

‎custom_components/ev_smart_charger/translations/en.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@
452452
"evsc_notify_night_charge_enabled": {
453453
"name": "Notify night charge"
454454
},
455+
"evsc_live_activities_enabled": {
456+
"name": "Live activities"
457+
},
455458
"evsc_enable_file_logging": {
456459
"name": "Enable file logging"
457460
},

0 commit comments

Comments
 (0)