Add flexible entity condition support for code slots#785
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #785 +/- ##
==========================================
+ Coverage 95.45% 96.02% +0.57%
==========================================
Files 29 29
Lines 2397 2516 +119
Branches 83 83
==========================================
+ Hits 2288 2416 +128
+ Misses 109 100 -9
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
84728ea to
6d2381a
Compare
e701fbb to
d4b863d
Compare
5 tasks
932ee94 to
688a7c2
Compare
5 tasks
688a7c2 to
d0a238b
Compare
Replace CONF_CALENDAR with CONF_ENTITY_ID that supports multiple entity types (calendar, binary_sensor, switch, schedule, input_boolean) as slot conditions. A state of 'on' means access is granted, matching existing calendar behavior. Features: - Config flow entity selector with multi-domain support - Automatic migration from CONF_CALENDAR to CONF_ENTITY_ID (v1 -> v2) - Rich calendar display preserved (event summary, end time, next event) - Domain-specific icons for different entity types - Clickable condition entities open more-info dialog - State tracking with fallback for late-registering entities Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
For schedule entities, show next state change time: - "Until 5:00 PM" when schedule is active - "Starts at 9:00 AM" when schedule is inactive - Includes day prefix for non-today events (tomorrow, Mon, etc.) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When a calendar condition is inactive, fetch the next upcoming event and display "Next access" with relative time and event summary. - Add async _get_next_calendar_event() to fetch events via calendar.get_events - Pass calendar_next_event through subscription handler - Add calendar_next to ConditionEntityInfo type - Update _renderConditionEntity to pass calendar_next to calendar renderer Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add TestGetConditionEntityData class with 11 tests for different entity domains - Add TestGetNextCalendarEvent class with 8 tests for calendar event fetching - Replace string literals with constants throughout websocket.py and tests - Use CALENDAR_DOMAIN, SERVICE_GET_EVENTS, STATE_ON/OFF/UNKNOWN/UNAVAILABLE - Use ATTR_ENTITY_ID for dictionary key access - Add test entity ID constants for cleaner test code - Move _LOGGER to top of websocket.py module - Use split_entity_id() for domain extraction instead of string operations Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update the code_slot step description to clearly explain that a slot is active when all conditions are met: the condition entity is 'on' AND number of uses (if configured) is greater than 0. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add input_boolean, schedule, and template to after_dependencies since these are now supported entity domains for slot conditions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Improve test coverage for provider implementations: - zwave_js.py: 82% → 99% coverage - Client state checks (not ready, not connected, driver not ready) - Push subscription retry logic (deferred, retry handler, cleanup) - Value update filters (non-usercode events, slot 0, empty values) - Exception handling (cache errors, refresh errors, disconnection) - Hard refresh triggers for missing/unknown slots - _base.py: 91% → 95% coverage - __eq__ with non-BaseLock objects - Event firing with State and dict source data - Deferred push subscription when config entry not loaded - Config entry state listener same-state handling Overall coverage: 95.28% → 97.40% Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- const.py: Set ATTR_CALENDAR_NEXT_START and ATTR_CALENDAR_NEXT_SUMMARY to reference the base constants instead of duplicating string values - binary_sensor.py: Capture old entity ID before updating subscription so debug log correctly shows "old -> new" transition Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
d0a238b to
7ab5ce3
Compare
Keep fixtures and conftest for future use. Tests restored to baseline from main branch (before any PR-specific changes). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
22849f5 to
6d26dbf
Compare
Frontend changes: - Fix hasConditions check to include condition_entity field - Unify condition entity rendering across all domain types (calendar, schedule, input_boolean, switch, binary_sensor) - Add domain badge (Calendar, Schedule, Toggle, etc.) for clarity - Consistent click behavior: all entities open more-info dialog - Improved status text: "Not blocking" / "Blocking access" - Calendar shows: Event name, started time, end time, next event preview - Schedule shows: end/start time with date context - Remove duplicate CSS classes (calendar-* and entity-condition-*) - Fix active state icon color to green for visual clarity Backend changes: - Add start_time to calendar condition entity data Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
f131729 to
b34358a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Breaking change
calendarhas been replaced withentity_idas a configuration option. Whilecalendaronly supported calendar entities,entity_idsupportscalendar,binary_sensor,switch,schedule, andinput_booleanfor more flexibility - users can use a template binary sensor to control PIN access with any logic they want.Existing config entries will automatically be migrated to use the new key. Any automations or scripts that rely on the original
calendarkey will need to be updated to useentity_id.Proposed change
Replace
CONF_CALENDARwith flexibleCONF_ENTITY_IDthat supports multiple entity types as slot conditions:calendar- existing calendar support with rich event displaybinary_sensor- on/off state controls accessswitch- on/off state controls accessschedule- Home Assistant schedule entitiesinput_boolean- simple on/off togglesA state of
onmeans access is granted, matching existing calendar behavior.Capabilities
Backend:
CONF_CALENDARtoCONF_ENTITY_ID(config entry v1 → v2)Frontend:
Known Limitations
Type of change
Additional information
🤖 Generated with Claude Code