Releases: andbad/HA_PowerControl
Release list
v4.2.3
What's Changed
- fix: suspended power not moved after load reordered in dashboard by @andbad in #92
- fix: customized dashboard reset after reboot if take control is enabled by @andbad in #90
- fix: version in integration config by @andbad in #87
- chore(deps): update pytest-homeassistant-custom-component requirement from >=0.13.206 to >=0.13.345 in the homeassistant group across 1 directory by @dependabot[bot] in #93
- chore(deps): update pytest-homeassistant-custom-component requirement from >=0.13.345 to >=0.13.346 in the homeassistant group by @dependabot[bot] in #96
- fix: replace deprecated async_track_state_change with async_track_state_change_event by @r0bb10 in #94
- 4.2.3 by @andbad in #97
New Contributors
Full Changelog: v4.2.2...v4.2.3
v4.2.2
v4.2.1
🚀 New Features (Feat)
- Dashboard Access Control via Config Flow: Added the
dashboard_user_controlledoption (internal keyCONF_DASHBOARD_REQUIRE_ADMIN) to the initial setup wizard. This allows hiding or showing the automatically generated Lovelace dashboard sidebar panel for non-admin users. #84 - New installations default:
True(Visible to Admins only). - Backward compatibility: To preserve existing behavior and prevent disruptions, upgraded installations retain unlocked visibility for all users (
False). - Localization: Updated translation strings across all 5 supported languages (EN, IT, DE, FR, ES) to include the labels for the new dashboard option.
🐛 Bug Fixes (Fix)
- Resolved Load Shedding Block on Fresh Installs (
enabled: False): Identified and fixed a critical regression present in versions 4.1.0 and 4.2.0. The analyzed logs clearly showed that when installed from scratch, the integration set the global state toenabled: Falseat runtime. This occurred due to a missing native activation key or an incorrect fallback logic during the initial loading ofentry.data(whereas on upgrades, the value correctly persisted asTruefrom v4.0.0). Restored the proper active default state at boot time to allow the normal execution of the shedding algorithm and arming timers. - Manifest version: version showed not updated #87
- Switch in dashboard: incorrect name #86
- Legacy Notify: It is possible to select legacy notification entities #85
What's Changed
- Dev by @andbad in #74
- chore(deps): bump the pytest group with 2 updates by @dependabot[bot] in #77
- chore(deps): bump actions/checkout from 4 to 7 by @dependabot[bot] in #75
- chore(deps): bump actions/setup-python from 5 to 6 by @dependabot[bot] in #76
- chore(deps): update pytest-homeassistant-custom-component requirement from >=0.13 to >=0.13.340 in the homeassistant group by @dependabot[bot] in #78
- 4.1.0 by @andbad in #80
- 4.2.0 by @andbad in #83
- chore(deps): update pytest-homeassistant-custom-component requirement from >=0.13 to >=0.13.342 in the homeassistant group across 1 directory by @dependabot[bot] in #82
- 4.2.1 by @andbad in #88
New Contributors
- @dependabot[bot] made their first contribution in #77
Full Changelog: https://github.com/andbad/HA_PowerControl/commits/v4.2.1
v4.2.0 - Take Control
Added
- Dashboard user-controlled mode — new option in the setup wizard ("Take control of the dashboard"). When enabled, the dashboard is generated on first install but never overwritten on subsequent upgrades.
- On upgrade, if a newer dashboard version is available and user-controlled mode is active, a persistent notification is shown asking whether to regenerate the dashboard. The notification warns that all customisations will be lost and offers two actions: Update dashboard or Skip (suppressed until the next upgrade).
- Pressing the button entity
button.power_control_regenerate_dashboard(visible only in user-controlled mode) triggers the same confirmation notification before regenerating. - New service
power_control.regenerate_dashboard— regenerates the dashboard immediately, bypassing the confirmation flow (useful in automations). - New constants:
CONF_DASHBOARD_USER_CONTROLLED,CONF_DASHBOARD_SKIPPED_VERSION,NOTIF_ID_REGEN_CONFIRM,SERVICE_REGENERATE_DASHBOARD. - New helper
async_dashboard_exists()indashboard.py.
What's Changed
- Dev by @andbad in #74
- chore(deps): bump the pytest group with 2 updates by @dependabot[bot] in #77
- chore(deps): bump actions/checkout from 4 to 7 by @dependabot[bot] in #75
- chore(deps): bump actions/setup-python from 5 to 6 by @dependabot[bot] in #76
- chore(deps): update pytest-homeassistant-custom-component requirement from >=0.13 to >=0.13.340 in the homeassistant group by @dependabot[bot] in #78
- 4.1.0 by @andbad in #80
- 4.2.0 by @andbad in #83
- chore(deps): update pytest-homeassistant-custom-component requirement from >=0.13 to >=0.13.342 in the homeassistant group across 1 directory by @dependabot[bot] in #82
Full Changelog: https://github.com/andbad/HA_PowerControl/commits/v4.2.0
v4.1.0
What's Changed
Features
- Anti-flap protection — a load that is shed more than
FLAP_MAX_SHEDS(5) times within a 10-minute rolling window is automatically blocked (keep_off=True) to prevent oscillation.shed_timestampsstored asdeque(maxlen=6)for bounded memory use. - Per-load cooldown (
min_off_sec) — each load can be configured with a minimum number of seconds it must remain off before the coordinator attempts to restore it. Exposed as aNumberSelector(0–3600 s, step 30) in the config/options flow. - Retry on switch failure —
_call_switch()retriesturn_on/turn_offup to 2 times with a 0.5 s delay before giving up. On failure the load state is rolled back (suspended_powerrestored to its pre-call value). - HA bus events —
power_control_load_shedandpower_control_load_restoredare fired on every successful shed/restore, carryingload_name,load_index,switch, and power data. Also fired byforce_stop_loadandforce_start_loadservice handlers. set_thresholdsservice — runtime override of immediate and delayed thresholds without touching persistent config. Threshold sensors now read fromcoord.thresholdsso the dashboard reflects the override immediately. #72- Dynamic load icon badge —
PowerControlLoadSensorreturns a dynamiciconproperty:mdi:cancel(keep_off),mdi:power-plug-off(suspended),mdi:power-plug-outline(unavailable),mdi:power-plug(active). - Load shed history card — a
history-graphcard trackingsuspended_powerfor each load (3-hour window) added to the generated dashboard. - Dashboard version tied to manifest —
DASHBOARD_VERSIONis now derived frommanifest.json(major * 10000 + minor * 100 + patch). Every integration version bump triggers an automatic dashboard rebuild on the next HA start; no more manual constant increments. - Config attributes on
current_powersensor — timing and notify config values exposed ascfg_ *attributes, eliminating the-placeholder rendered by HA for missing attributes in the settings card.
Bug Fixes
- B1 —
async_restore_statenow uses the entity registry (er.async_get) to resolve the currententity_idfrom the stableunique_id. Renames and load reorders no longer break suspended-power restore across restarts. - B2 —
_watchdog_manual_restartclearsshed_timestampswhen a manually restarted load is detected, preventing stale anti-flap counts. - B3 —
force_stop_loadservice handler now uses_call_switch(retry + rollback) and fires thepower_control_load_shedevent, consistent with the automatic shed path. - B4 —
force_start_loadclearsshed_timestampsandkeep_offbefore turning the load on, and firespower_control_load_restored. - B5 — Anti-flap trigger changed from
>=to>FLAP_MAX_SHEDS for correct "strictly more than N sheds" semantics. - B6 —
rebuild_loadsnow preservessuspended_power,shed_timestamps, andkeep_offacross load reorders and options-flow updates (matched by switch entity_id). - B7 — Master switch
_attr_namechanged from"Attivo"(Italian) to"Active". - N3 —
force_stop_loadusescoord._get_conf(CONF_NOTIFY_ENTITY)instead ofconfig_entry.data.get(...), picking up options-flow changes at runtime. - N4 — In
handle_move_load, dashboard rebuild now happens beforeasync_request_refreshso the coordinator poll sees the updated load order. - N5 —
async_restore_stateis called afterasync_forward_entry_setupsso the entity registry is populated when the restore runs. Previously it always returned no results. - N6 —
_under_threshold_sinceis preserved (not reset) when the only reason no load was restored is a temporary skip (min_off_seccooldown or insufficient headroom). It is reset only when all suspended loads are permanently blocked (keep_off/auto_restart=False). - Dashboard timer card — replaced the
—em-dash placeholder with the localisedtimer_idlestring, preventing some HA Markdown renderers from misinterpreting it as a list marker. - Settings card dash —
"attribute": "_pc_blank"rows replaced with realcfg_ *attributes onsensor.power_control_current_power, eliminating the-HA renders for missing attributes. #71 - Load renamed — Resolved an issue where renaming a load during reconfiguration caused a mismatch between the auto-generated dashboard and the actual entity_id of suspension and restart sensors #73
Refactoring & Optimisations
- R2 — All reads of coordinator config values consolidated to
_get_conf()throughout_shed_one_load,_restore_one_load,async_check_and_stop/start, and service handlers. Options-flow changes are now reflected immediately everywhere. - R3 —
shed_timestampstype annotation updated todeque [float]. - O2 —
shed_timestampschanged fromlisttodeque(maxlen=FLAP_MAX_SHEDS+1). Old-timestamp pruning still uses the rolling-window check;maxlencaps memory use without extra allocations. - O3 —
_STRINGS_CACHE.clear()called at the start of each_build_dashboard_configso language changes are picked up on the next rebuild. - O4 — Suspended-power sensor slugs computed once per load in the main dashboard loop and passed to
_build_shed_history_card, eliminating duplicateslugifycalls. - R1 —
_call_switchdefaultretry_delay_sreduced from 2.0 s to 0.5 s, cutting worst-case coordinator block time from 4 s to 1 s per failing switch.
Translations
- Full English translation of all user-facing strings and entity names applied in a previous session; this session fixed the remaining Italian residual (
switch._attr_name = "Attivo"→"Active"). shed_history_titlekey added to all five language files (EN, IT, DE, FR, ES).
Testing
-
pytest suite expanded from 122 to 148 passing tests.
-
New test classes:
TestCallSwitch,TestAntiFlap,TestCustomEvents,TestLoadSensorIcon,TestPerLoadCooldown,TestN5N6Regressions,TestBugFixes. -
YAML integration test suite (
test_package.yaml) updated: stale Italian entity IDs fixed, 5 new scripts added (T18–T22) coveringset_thresholdsoverride/reset, anti-flap,min_off_seccooldown, andmove_loadpriority change.test_pc_resetextended to callforce_start_loadon all loads and reset threshold overrides between tests. -
pytest.ini— addedasyncio_default_fixture_loop_scope = functionto silence pytest-asyncio 1.4 deprecation warning. -
requirements_test.txt— bumped minimum versions:pytest>=9.1,pytest-asyncio>=1.4,pytest-homeassistant-custom-component==0.13.205(last release supporting Python 3.12). -
CI workflow (
tests.yml) — added--tb=shortfor richer failure output.
Full Changelog: https://github.com/andbad/HA_PowerControl/commits/v4.1.0
v4.0.1
Added
-
Migration Documentation (#70): Restored and updated the documentation details in the README regarding the migration process from YAML package configurations (v3.70) to the new integration platform.
-
Dynamic Threshold Services (#72): Introduced new integration services (power_control.set_thresholds) allowing users to dynamically overwrite immediate and delayed power thresholds via automations without altering persistent configurations.
Fixed
-
Dashboard Formatting & Reordering (#69): Replaced unnecessary unit formatting symbols ("W") with placeholders where appropriate, and fixed dashboard card issues when reordering loads using up/down arrows.
-
Entity Naming and Formatting Duplications (#71): Resolved a bug that caused duplicated separation characters (__) in suspended power entity IDs due to spaces in instance or sensor names. Fixed a file corruption issue affecting sensor data visualization.
-
Load Renaming Synchronization (#73): Fixed a bug in the reconfiguration wizard where renaming a load caused a mismatch between the auto-generated dashboard and the underlying entity_id (e.g., suspended power and auto-restart sensors), ensuring entity IDs now correctly align after a rename.
Full Changelog: https://github.com/andbad/HA_PowerControl/commits/v4.0.1
v4.0 A new Hope
A long time ago in a configuration folder far, far away... we relied on complex YAML files and custom scripts to balance our power loads. But those days are gone.
This release marks the official transition of this project from a legacy YAML package to a native Home Assistant integration, now available via HACS.
Why this migration?
- Modern Integration: The original YAML package implementation is no longer maintained and has become difficult to manage with Home Assistant's evolving architecture.
- Easier Installation & Updates: Moving to a native integration allows for seamless installation, configuration via the UI (Config Flow), and effortless future updates through HACS.
- Better Performance & Stability: Rewriting the logic as a proper integration removes the reliance on external python scripts and complex manual YAML configurations, ensuring a more robust load control management.
- Automatic Dashboard: to give you complete control over your power management, the integration now automatically creates a dedicated dashboard panel, conveniently accessible from your Home Assistant sidebar on the left.
- Translations & Localization: the integration's strings have been automatically translated into English, German, Spanish, and French. Since these are automated translations, corrections and additional language contributions are highly welcome via Pull Requests!
If you are still using the old pc.yaml and python scripts, I highly recommend restoring balance to your smart home by removing them and migrating to this new integration.