Skip to content

Releases: Geek-MD/HA_Daily_Counter

v1.4.1

17 Feb 12:08
c0f1553

Choose a tag to compare

🔧 Critical Bug Fix: OptionsFlow AttributeError

This release fixes a critical error that prevented users from accessing the options/configuration menu for existing integrations.

Fixed

  • AttributeError Fix: Fixed "property 'config_entry' of 'OptionsFlowHandler' object has no setter" error
  • OptionsFlow Initialization: Corrected OptionsFlowHandler.__init__() to follow Home Assistant's OptionsFlow pattern
  • Configuration Access: Users can now access the options menu without errors

Technical Details

  • Removed manual config_entry parameter from OptionsFlowHandler.__init__()
  • The config_entry property is automatically provided by Home Assistant's OptionsFlow base class
  • Updated async_step_init() to initialize counters from self.config_entry.options on first call
  • The config_entry property is read-only and should not be assigned in __init__

Who Should Upgrade?

All users should upgrade to v1.4.1 immediately if experiencing errors when trying to configure existing integrations, especially:

  • "AttributeError: property 'config_entry' of 'OptionsFlowHandler' object has no setter" errors
  • HTTP 500 errors when clicking "Configure" on an integration
  • Unable to add, edit, or delete counters through the options flow

Installation

  1. Update via HACS or manually install v1.4.1
  2. Restart Home Assistant
  3. Configuration menu should now work without errors

v1.4.0

17 Feb 06:21
f9ce753

Choose a tag to compare

🔧 Critical Bug Fix: Error 500 During Reconfiguration + Code Structure Improvements

This release fixes HTTP 500 errors that could occur during integration configuration and reconfiguration, applying lessons learned from the Battery Devices Monitor integration. Additionally, the code structure has been refactored to follow Home Assistant best practices.

Fixed

  • Error 500 Prevention: Added comprehensive error handling throughout the config flow to prevent HTTP 500 errors
  • Empty Entity List Handling: Fixed crash when no entities are available in the domain filter
  • Safe Schema Creation: All form schema creation now wrapped in try-except blocks with safe fallback schemas
  • Robust Entity Filtering: Added error handling for individual entity filtering operations
  • Better Error Logging: Added debug and error logging throughout the config flow for easier troubleshooting

Changed

  • 🏗️ Code Structure (Best Practice): Renamed classes following professional integration standards:
    • HADailyCounterConfigFlowFlowHandler
    • HADailyCounterOptionsFlowOptionsFlowHandler
    • Consolidated both classes into single config_flow.py file (removed separate options_flow.py)
    • Matches structure used by Battery Devices Monitor and other professional integrations
  • Enhanced async_step_user() with comprehensive error handling and fallback schema
  • Enhanced async_step_another_trigger() with multiple layers of error protection:
    • Input processing wrapped in try-except
    • Entity filtering with individual error handling
    • Empty entity list detection with safe fallback
    • Schema creation with comprehensive fallback
  • Enhanced async_step_finish() with error handling and informational logging
  • Updated version to 1.4.0 in manifest.json
  • Modernized type hints to use native Python syntax (dict[str, Any] instead of Dict[str, Any])

Technical Details

  • Applied Battery Devices Monitor pattern: defensive programming with try-except blocks
  • All user input processing now safely handles exceptions
  • Empty dropdown prevention: provides safe fallback when no entities available
  • Form schema creation failures now return minimal functional schemas instead of crashing
  • Added _LOGGER for consistent debug and error logging throughout config flow
  • File structure now follows Home Assistant integration best practices with both flow handlers in single file

Who Should Upgrade?

All users should upgrade to v1.4.0 to ensure stable configuration and reconfiguration experience, especially when:

  • Adding multiple triggers to a counter
  • Using domain or text filters
  • Working with limited entity availability
  • Reconfiguring existing integrations

Installation

  1. Update via HACS or manually install v1.4.0
  2. Restart Home Assistant
  3. Configuration and reconfiguration should now work smoothly without 500 errors

v1.3.9

11 Dec 02:20
294e316

Choose a tag to compare

✨ New Feature: Counter Reconfiguration via Options Flow

This release adds the ability to edit and reconfigure existing counters directly through the Home Assistant UI, without having to delete and recreate them.

Added

  • Edit Counter Option: New "Edit counter" action in the options flow menu
  • 🔄 Reconfigure Trigger Entity: Ability to change the entity that triggers the counter
  • 🔄 Reconfigure Trigger State: Ability to change the state that increments the counter
  • 🔄 Automatic Reload: Integration automatically reloads when configuration changes are saved
  • 📋 Current Values Display: Shows current configuration before making changes in the edit flow

Changed

  • Updated __init__.py to register an update listener that reloads the integration when options are modified
  • Enhanced options_flow.py with new edit steps: async_step_select_edit, async_step_edit_trigger_entity, and async_step_edit_trigger_state
  • Updated all translation files (en.json, es.json, strings.json) with new edit-related strings
  • Updated version to 1.3.9 in manifest.json

Technical Details

  • Added async_reload_entry function in __init__.py to handle config entry reloads
  • Registered update listener in async_setup_entry to detect option changes and trigger reload
  • Modified HADailyCounterOptionsFlow class to track editing state with _selected_edit_index and _editing_counter
  • Edit flow preserves counter ID to maintain entity continuity

How to Use

  1. Go to Settings → Devices & Services
  2. Find your HA Daily Counter integration
  3. Click "Configure" on any existing counter entry
  4. Select "Edit counter" from the action menu
  5. Choose which counter you want to edit
  6. Update the trigger entity or trigger state
  7. The integration will automatically reload with the new configuration

v1.3.8

10 Dec 15:36
18c78a7

Choose a tag to compare

🔧 Critical Bug Fix Release

This release fixes the persistent migration error that continued to affect users even after v1.3.7.

Fixed

  • Root Cause Fixed: Resolved persistent "Flow handler not found for entry" error by properly registering ConfigFlow with Home Assistant
  • ✅ Updated HADailyCounterConfigFlow to use modern ConfigFlow registration syntax: class HADailyCounterConfigFlow(config_entries.ConfigFlow, domain=DOMAIN)
  • ✅ Added async_migrate_entry function in __init__.py for better config entry migration handling
  • ✅ All existing counters now load properly after restart
  • ✅ Options menu now accessible for all config entries

Who should upgrade?

All users experiencing "Flow handler not found" errors should upgrade to v1.3.8 immediately to restore full functionality.

Technical Details

  • The root cause was that the ConfigFlow class used old-style domain registration (domain = DOMAIN as class attribute) instead of the modern approach (domain=DOMAIN as class parameter)
  • In Home Assistant 2021.11+, ConfigFlow classes must register by passing domain as a parameter to the parent class
  • v1.3.7 added async_get_options_flow but didn't fix the underlying registration issue
  • This fix ensures proper ConfigFlow registration with Home Assistant's flow handler registry

Installation

  1. Update via HACS or manually install v1.3.8
  2. Restart Home Assistant
  3. Verify all counters load properly and options menu is accessible

v1.3.7

10 Dec 14:53
34639a7

Choose a tag to compare

🔧 Critical Bug Fix Release

This release fixes a critical migration error introduced in v1.3.6 that prevented existing counters from working properly.

Fixed

  • Critical Migration Error: Resolved "Flow handler not found for entry" error that caused all existing counters to be disabled after upgrading to v1.3.6
  • ✅ Added missing async_get_options_flow static method to HADailyCounterConfigFlow class to properly link the options flow handler
  • ✅ Existing config entries now work correctly and counters are no longer disabled after upgrade

Who should upgrade?

All users who upgraded to v1.3.6 should upgrade to v1.3.7 immediately to restore functionality to their existing counters.

Technical Details

  • The issue occurred because Home Assistant could not find the options flow handler for existing config entries
  • The config_flow.py had a HADailyCounterConfigFlow class but was missing the async_get_options_flow static method
  • This method is required to connect the config flow to the HADailyCounterOptionsFlow class defined in options_flow.py
  • This fix ensures backward compatibility with existing installations

Installation

  1. Update via HACS or manually install v1.3.7
  2. Restart Home Assistant
  3. Your existing counters should now be enabled and working

v1.3.6

10 Dec 02:12
1899e39

Choose a tag to compare

HA Daily Counter v1.3.6 — 2025-12-10

🐛 Bug Fixes

  • Fixed mypy type checking error in config_flow.py related to domain parameter
    • Changed domain from class inheritance parameter to class attribute
    • Resolves error: "Unexpected keyword argument 'domain' for 'init_subclass' of 'object'"
    • Ensures compatibility with Python 3.11+ and mypy 1.10.0+

🔧 Technical Changes

  • Updated HADailyCounterConfigFlow class definition to use domain as a class attribute instead of a class parameter
  • All code passes mypy type checking with zero errors
  • All code passes ruff linting with zero warnings

📝 Breaking Changes

None - fully backward compatible with existing configurations

v1.3.5

09 Dec 19:26
704289e

Choose a tag to compare

HA Daily Counter v1.3.5 — 2025-12-09

🎉 New Features

  • Added domain selection dropdown in configuration flow to filter entities by type (binary_sensor, sensor, automation, script, input_boolean, input_number, input_select)
  • Integration now supports monitoring automations and scripts in addition to sensors
  • Added text filter field in additional trigger step to search entities by name

✨ Improvements

  • Moved logic operator selection (AND/OR) from first step to second step for better UX
  • Logic operator now appears only when adding the first additional trigger (second sensor)
  • Subsequent triggers automatically use the same logic operator
  • Entity selector now dynamically filters based on selected domain type
  • Optimized state lookups to avoid redundant hass.states.get() calls

🐛 Bug Fixes

  • Fixed potential AttributeError when entity state name is None
  • Added null-safe handling for entity state names in trigger list

🔧 Technical Changes

  • Updated translation files (en, es) with new field labels
  • All code passes linting (ruff) and type checking (mypy)
  • Security scan clean (CodeQL - 0 alerts)

📝 Breaking Changes

None - fully backward compatible with existing configurations

v1.3.3

07 Nov 02:06
95da19a

Choose a tag to compare

HA Daily Counter v1.3.3 — 2025-11-07

Summary

Bug fixes and improvements to the configuration flow, type-stub/mypy compatibility fixes, and better compatibility with recent Home Assistant releases. Adds a single global logic selector (AND / OR) used to combine multiple triggers created during setup.

Added

  • Add a logic selector (AND / OR) in the first step of the configuration flow. This value is stored in the config entry as logic and is applied to all triggers added afterward.
    • Default logic: OR.

Changed

  • Configuration flow behavior:
    • If the "add_another" checkbox is NOT checked at any step, the flow now ends immediately and a config entry is created with the collected triggers.
    • If "add_another" is checked, the flow enters a repeatable step to add more sensors until the user unchecks the box.
    • The logic selector is shown only in the initial form (after the checkbox) and is not shown in the repeatable "add trigger" forms.
  • Additional-triggers UI:
    • For repeatable trigger-adding steps the implementation now uses a Select dropdown built from filtered entity IDs rather than attempting to pass a dynamic "options" list into EntitySelectorConfig.
    • Rationale: this keeps the runtime behavior while maintaining static typing compatibility with homeassistant stubs (avoids a TypedDict error).
  • Stored config entry data shape:
    • data["triggers"] now contains a list of trigger objects: { "id": "<uuid>", "entity": "<entity_id>", "state": "<state>" }
    • data["logic"] contains the selected logic operator: "AND" or "OR".

Fixed

  • Fixed a bug where the flow did not finish and create the entry when the "add_another" box was not checked.
  • Fixed multiple mypy/type-checking errors in CI:
    • Removed unsupported translation_key arguments from async_show_form calls (stubs).
    • Use SelectSelectorMode.DROPDOWN instead of bare strings for selector mode.
    • Avoid passing unsupported options key to EntitySelectorConfig (use SelectSelector for dynamic lists instead).
    • Fixed typing around hass.config_entries.async_forward_entry_setups / async_forward_entry_unloads by locally casting to Any to preserve compatibility across Home Assistant versions and avoid stub errors.
    • Removed unnecessary type: ignore comments flagged by mypy.

Compatibility / Migration notes

  • New config entries created with v1.3.3 include the logic field. If you have existing config entries created by earlier versions:
    • Integrations or code expecting logic should treat missing logic as OR by default.
    • No automatic migration tool is included in this release; if you want to backfill existing entries, update them manually or run a small migration script that sets logic: "OR" for entries missing the field.
  • UI difference in repeatable trigger step:
    • The repeatable step uses a dropdown (SelectSelector) of entity_ids filtered to the domain of the first selected entity and excluding already-chosen entities.
    • If you prefer the EntitySelector-style autocomplete/picker for that step, it can be restored but will require either a small mypy suppression or a change to the stubs; the current approach prioritizes CI/type-safety.

Developer notes

  • The following changes were made to resolve mypy issues:
    • Remove translation_key parameter usage from calls to async_show_form.
    • Use SelectSelectorMode.DROPDOWN (enum) instead of strings.
    • Replace invalid EntitySelectorConfig(options=...) usage with a SelectSelector constructed from SelectOptionDict entries.
    • Use cast(Any, hass.config_entries) around forward/unload entry calls to avoid typing errors with different HA versions.
  • Tests / CI:
    • After applying the changes, run the pipeline locally or in CI:
      • pip install mypy==1.10.0
      • mypy --config-file mypy.ini
    • Confirm no mypy errors remain.

Notes for users

  • How to test the new flow:
    1. Install or update the custom component files and restart Home Assistant.
    2. Go to Settings → Integrations → Add integration → HA Daily Counter.
    3. Step 1 (Initial): enter Name, select first entity, select state, choose whether to Add another, and choose the logic (AND/OR, default OR).
      • If you do not check "Add another", the flow should finish and create the entry immediately.
    4. If you check "Add another", you will see repeated forms that let you pick additional entities (filtered by domain), select state, and optionally add more.
    5. After finishing, review the created config entry: it will include the triggers list and the chosen logic.
  • Default behavior: if logic is missing for any older config entry, treat it as OR.

Security

  • No security-sensitive changes in this release.

Credits

  • Changes and fixes by Geek-MD and contributors.

v1.3.2

03 Nov 17:21
dfb64d2

Choose a tag to compare

🆕 HA Daily Counter v1.3.2

🐞 Fixes

  • Fixed hacs.json and manifest.json to fully comply with HACS integration requirements.
  • Added CONFIG_SCHEMA using cv.config_entry_only_config_schema(DOMAIN) to satisfy Hassfest validation rules.
  • Reorganized imports in __init__.py to comply with Ruff E402 (“imports must be at the top of the file”).
  • Added missing import for DOMAIN in counter.py, resolving Ruff F821 (“undefined name 'DOMAIN'”).
  • Corrected device_info method typing to match Home Assistant’s DeviceInfo | None standard, ensuring Mypy passes cleanly.
  • Verified that all modules pass Ruff and Mypy with zero errors or warnings.

⚙️ Code Quality

  • Improved consistency and readability across all modules.
  • All imports sorted, typing hints added, and file headers aligned with Home Assistant best practices.

🧩 Result

The integration is now fully compliant with HACS, Hassfest, Ruff, and Mypy.
All counters and entities load correctly, historical statistics remain intact,
and users can safely upgrade without losing functionality or data.

v1.3.1

15 Oct 19:02
99dfca0

Choose a tag to compare

🆕 HA Daily Counter v1.3.1

🐞 Fixes

  • Fixed startup crash when loading counters
    Resolved KeyError: 'trigger_entity' caused by configurations using the newer multi-trigger format.
    The integration now seamlessly supports both schemas:

    • Legacy schema: trigger_entity + trigger_state
    • Multi-trigger schema: triggers + logic
      ensuring backward compatibility and stable migration between versions.
  • Improved entity initialization

    • Prevents crashes when configuration data is incomplete or malformed.
    • Adds warnings for invalid configurations without interrupting setup.
    • Guarantees that all counters correctly create and restore their entities at startup.
  • Stable restoration and reset behavior

    • Keeps state_class: total_increasing for full statistics continuity.
    • Maintains historical data and state restoration after restarts.
    • No unit-of-measurement changes, ensuring compatibility with recorded statistics.

⚙️ Code Quality

  • Cleaned unused imports and validated Ruff and Mypy compliance (no warnings or errors).
  • Improved defensive programming in the constructor (__init__) for better resilience.
  • Preserved identical logic for counting, resetting, and daily scheduling.

🎨 Visual Updates

  • Updated visual assets for improved clarity and consistency with Home Assistant:
    • icon.png
    • icon@2x.png
    • logo.png
    • logo@2x.png

🧩 Result

The integration is now fully stable and backward compatible.
All counters and entities load correctly, previous statistics remain intact,
and users can safely upgrade without losing history or functionality.