Skip to content

fix: PIN code handling improvements#345

Merged
guerrerotook merged 1 commit into
guerrerotook:mainfrom
clintongormley:fix/pin-code-improvements
Feb 27, 2026
Merged

fix: PIN code handling improvements#345
guerrerotook merged 1 commit into
guerrerotook:mainfrom
clintongormley:fix/pin-code-improvements

Conversation

@clintongormley
Copy link
Copy Markdown
Collaborator

@clintongormley clintongormley commented Feb 27, 2026

Summary

Follow-up fixes to #326 (AndroidAuto / PIN code feature):

  • PIN can now be cleared: Use suggested_value instead of default for the PIN field in the options flow, so clearing the field actually removes the PIN instead of silently restoring it
  • Defense-in-depth for arm without PIN: _check_code_for_arm_if_required now skips the PIN check when no PIN is configured, even if code_arm_required is stale True in the config
  • Default changed: code_arm_required defaults to False (don't require PIN to arm)
  • Clearer label: "Also require PIN code (if any) to arm alarm" makes the dependency on having a PIN explicit
  • Missing translation: Added exceptions.invalid_pin_code to strings.json, en.json, and es.json so ServiceValidationError renders properly
  • Docstring fix: Grammar correction in _check_code_for_arm_if_required

Test plan

  • Set a PIN, verify it's required to disarm
  • With PIN set and "require PIN to arm" unchecked, verify arming works without PIN
  • With PIN set and "require PIN to arm" checked, verify arming requires PIN
  • Clear the PIN in options, verify no PIN is required for any action
  • With no PIN and "require PIN to arm" checked, verify arming still works without PIN prompt

🤖 Generated with Claude Code

Relates to #326

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Follow-up fixes to the Securitas Direct integration’s PIN code feature (introduced/modified in #326), focusing on making PIN clearing work correctly in the options flow and hardening arm/disarm PIN enforcement behavior.

Changes:

  • Update options flow PIN field to use suggested_value (so clearing the field can persist) and ensure a missing submission clears the stored PIN.
  • Adjust arm-time PIN checking to skip validation when no PIN is configured.
  • Update UI labels and add/ensure exception translation strings for invalid PIN errors.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
custom_components/securitas/config_flow.py Options flow: make PIN value “suggested” (not forced) and normalize missing PIN input to an explicit empty value.
custom_components/securitas/alarm_control_panel.py Arm-time PIN check now bypasses when no PIN is configured; uses translated ServiceValidationError for invalid PIN.
custom_components/securitas/strings.json Update label text for code_arm_required and include exception translation for invalid PIN.
custom_components/securitas/translations/en.json English translation updates for the code_arm_required label and invalid PIN exception message.
custom_components/securitas/translations/es.json Spanish translation updates for the code_arm_required label and invalid PIN exception message.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread custom_components/securitas/alarm_control_panel.py
@clintongormley clintongormley marked this pull request as draft February 27, 2026 12:28
- Use suggested_value instead of default for PIN field in options flow,
  allowing users to clear the PIN by emptying the field
- Skip PIN check for arming when no PIN is configured (defense-in-depth)
- Change default for code_arm_required to False (arm without PIN by default)
- Clarify label: "Also require PIN code (if any) to arm alarm"
- Add missing translation for invalid_pin_code ServiceValidationError
- Fix docstring grammar in _check_code_for_arm_if_required
- Sync strings.json and es.json with new keys

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clintongormley clintongormley force-pushed the fix/pin-code-improvements branch from 7448b94 to 11ac519 Compare February 27, 2026 12:29
@clintongormley clintongormley marked this pull request as ready for review February 27, 2026 12:30
@guerrerotook guerrerotook merged commit 3e1fb2a into guerrerotook:main Feb 27, 2026
3 checks passed
@clintongormley clintongormley deleted the fix/pin-code-improvements branch February 27, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants