Skip to content

v1.3.3

Choose a tag to compare

@Geek-MD Geek-MD released this 07 Nov 02:06
95da19a

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.