fix: validate mapping options and add Partial Night state#336
Merged
guerrerotook merged 6 commits intoFeb 26, 2026
Merged
Conversation
When peri_alarm changes between step 1 and step 2 of the options flow, saved mapping values (e.g. PERI_ONLY) may not be in the new options list (STD_OPTIONS). Reset to the appropriate default when this happens. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The migration logic derived mapping defaults from the PERI_alarm checkbox but only set them in the runtime config dict. Without calling async_update_entry, the migrated values were lost on restart, causing the migration to re-run every time. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The config_flow selector expects string values, but STD_DEFAULTS and PERI_DEFAULTS contained SecuritasState enum objects. This caused mismatches when comparing defaults against valid_values (which are strings from state.value). Use .value to store strings directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Create strings.json as the source of truth for translations, synced with en.json. Add missing mappings section to es.json with Spanish translations for the alarm state mapping options step. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Partial Night (ARMNIGHT1 / protomResponse Q) exists in some countries. Rename PARTIAL → PARTIAL_DAY, PARTIAL_PERI → PARTIAL_DAY_PERI, and add PARTIAL_NIGHT and PARTIAL_NIGHT_PERI with their commands and mappings. - Update STD_OPTIONS/PERI_OPTIONS to include the new states - Default Night button to Partial Night (STD) / Partial Night + Peri (PERI) - Use .value strings in defaults for selector compatibility - Create strings.json, sync es.json with mappings and new fields - Update plan doc to correct Q/ARMNIGHT1 documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Explains how Securitas modes map to HA alarm buttons, default mappings for standard and perimeter installations, and the disarm-before-rearm behavior. Notes that Partial Night + Perimeter status code is unknown. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Author
|
@poupounetjoyeux This PR adds back the partial night statuses you asked for |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the alarm state mapping feature introduced in PR #329 by adding validation for mapping options when switching perimeter modes, persisting migrated mappings, and introducing Partial Night alarm states. The changes improve the robustness of the configuration flow and expand support for alarm states that exist in some Securitas/Verisure regions (particularly France).
Changes:
- Added validation to reset alarm state mappings to defaults when switching between STD/PERI perimeter modes if saved mappings are invalid for the new mode
- Modified migration logic to persist converted mapping values to
entry.datato survive HA restarts - Renamed PARTIAL → PARTIAL_DAY and PARTIAL_PERI → PARTIAL_DAY_PERI for clarity
- Added PARTIAL_NIGHT (
Q/ARMNIGHT1) and PARTIAL_NIGHT_PERI (commandARMNIGHT1PERI1, status code unknown) states - Added
strings.jsonas English fallback translation file and synchronized Spanish translations - Fixed typo "alamr" → "alarm" in README
- Documented the known limitation that PARTIAL_NIGHT_PERI status code is unknown and will show as Custom Bypass
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
docs/plans/2026-02-12-configurable-alarm-mapping-design.md |
Updated design documentation to reflect 8 alarm states (added Partial Night variants), updated table with protomResponse codes and API commands, clarified that Partial Night exists in some countries |
custom_components/securitas/translations/es.json |
Added Spanish translations for the mappings step in options flow |
custom_components/securitas/strings.json |
Added new file with English translations as fallback (matches en.json structure) |
custom_components/securitas/securitas_direct_new_api/const.py |
Renamed PARTIAL to PARTIAL_DAY and PARTIAL_PERI to PARTIAL_DAY_PERI; added PARTIAL_NIGHT and PARTIAL_NIGHT_PERI states; added Q protomResponse mapping; changed defaults dicts to use .value strings instead of enum instances |
custom_components/securitas/config_flow.py |
Added _valid_map helper function that validates saved mappings against current perimeter setting and resets to defaults if invalid |
custom_components/securitas/__init__.py |
Added persistence logic to save migrated mapping values to entry.data via async_update_entry |
README.md |
Added comprehensive Alarm State Mapping section documenting all modes, how mapping works, default mappings, and known limitations; fixed typo "alamr" → "alarm" |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
guerrerotook
approved these changes
Feb 26, 2026
Collaborator
Author
|
Thanks @guerrerotook |
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.
This PR commits a few fixes relating to #329 that CoPilot identified (but in the wrong PR #332).
It also adds back the Partial Night and Partial Night Perimeter statuses as these are supported at least by verisure France, as discussed in #335 (comment)
We are missing the status code for partial-night-plus-perimeter so, if somebody sets that, we will have to show the Custom status, as we did before #329 was merged. I've added a note to the README asking anybody in this situation to open an issue so that we can fix this problem.
Summary
entry.dataso they survive restarts.valuestrings in defaults dicts for selector compatibilityQ/ARMNIGHT1) and Partial Night + Perimeter (ARMNIGHT1PERI1) statesstrings.jsonand sync Spanish translationsRelates to #329
Test plan
ARMNIGHT1commandprotomResponsecodes fall back toARMED_CUSTOM_BYPASS🤖 Generated with Claude Code