Skip to content

Makes AndroidAuto working#326

Merged
clintongormley merged 4 commits into
guerrerotook:mainfrom
poupounetjoyeux:main
Feb 27, 2026
Merged

Makes AndroidAuto working#326
clintongormley merged 4 commits into
guerrerotook:mainfrom
poupounetjoyeux:main

Conversation

@poupounetjoyeux
Copy link
Copy Markdown
Contributor

In HA Android auto, alarm widget can only activate the armed_away mode :
home-assistant/android#3710

However if like me the technician only configured a night mode, this is a workaround to make it works with Android Auto

@poupounetjoyeux
Copy link
Copy Markdown
Contributor Author

Edit: I need to test it on my car to check if the status also needs to be overriden to allow disarming from Android Auto

@poupounetjoyeux poupounetjoyeux changed the title Add a new option to make the 'Arm Away' button acting as 'Arm Night' Makes AndroidAuto working Jan 31, 2026
@poupounetjoyeux poupounetjoyeux force-pushed the main branch 5 times, most recently from 0635a0d to bbe0eb9 Compare January 31, 2026 10:53
@poupounetjoyeux
Copy link
Copy Markdown
Contributor Author

poupounetjoyeux commented Jan 31, 2026

Following my two other commits, this PR also include a better way to manage PIN check (when pin is not set to allow AndroidAuto to works and ability to set a text pin code)

@poupounetjoyeux
Copy link
Copy Markdown
Contributor Author

Just tested in my car and I confirm all is working from HA and from AndroidAuto 👌

@poupounetjoyeux poupounetjoyeux force-pushed the main branch 2 times, most recently from 88362da to 2a3283e Compare February 5, 2026 14:00
@poupounetjoyeux
Copy link
Copy Markdown
Contributor Author

Will work in harmony with #home-assistant/android/pull/6374 if you want to just be able to arm the alarm from car (with only a code for disarming)

@clintongormley
Copy link
Copy Markdown
Collaborator

Hi @poupounetjoyeux

I think that my PR #329 will solve your problem in a more generic way than adding a special mapping for android. With that PR you'd just be able to configure Away to map to whatever state you prefer in securitas.

I'm unsure about the PIN change. But you may want to try out #329 and if that works for you, then reduce your PR to just the PIN changes

@poupounetjoyeux
Copy link
Copy Markdown
Contributor Author

Hello @clintongormley
I confirm that it will not work because of the bad code format 😅
Same issue with code required for arming
However regarding the amr_away to arm_night mapping it should be enough and your rework seems more generic and so better than mine 👍

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

This PR adds configuration options to improve Home Assistant Android Auto usability for this Securitas integration, primarily by allowing the Android Auto “Arm away” action to trigger “Arm night” instead, and by introducing configurable PIN requirements for arming actions.

Changes:

  • Add new options: map “arm away” to “arm night”, and require PIN for arming.
  • Improve PIN handling in the alarm entity (dynamic code format + translated validation error).
  • Update English translations to surface the new options and error message.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
custom_components/securitas/translations/en.json Adds UI labels for new options and a translated PIN validation error message.
custom_components/securitas/config_flow.py Extends import + options flow to capture the new settings (and exposes PIN in options).
custom_components/securitas/alarm_control_panel.py Implements arm-away→arm-night mapping and PIN validation behavior changes.
custom_components/securitas/__init__.py Adds new config constants/defaults and wires them into config schema + setup.

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

Comment on lines +14 to +16
"code_arm_required": "PIN code is required to arm ?",
"PERI_alarm": "Is there a Perimetral alarm?",
"arm_away_as_arm_night": "Arm away button put the alarm in night mode (usefull if no away mode is configured)",
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

The config/option label has English punctuation/grammar issues (space before ?, and phrasing). Consider changing to something like "Require PIN code to arm?" to be consistent with other UI strings.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

"code": "PIN Code (leave empty for no PIN)",
"code_arm_required": "PIN code is required to arm ?",
"PERI_alarm": "Is there a Perimetral alarm?",
"arm_away_as_arm_night": "Arm away button put the alarm in night mode (usefull if no away mode is configured)",
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

Typo in the translation string: "usefull" should be "useful".

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Comment thread custom_components/securitas/translations/en.json Outdated
Comment on lines 210 to 213
self.config[CONF_CODE] = user_input[CONF_CODE]
self.config[CONF_CODE_ARM_REQUIRED] = user_input[CONF_CODE_ARM_REQUIRED]
self.config[CONF_ARM_AWAY_AS_ARM_NIGHT] = user_input[CONF_ARM_AWAY_AS_ARM_NIGHT]
self.config[CONF_CHECK_ALARM_PANEL] = user_input[CONF_CHECK_ALARM_PANEL]
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

async_step_import reads CONF_CODE_ARM_REQUIRED / CONF_ARM_AWAY_AS_ARM_NIGHT with direct indexing. If an existing config entry is re-imported without these new keys (e.g., older stored entries), this will raise KeyError and abort setup. Use user_input.get(..., DEFAULT_...) (and/or populate defaults before calling the import step) to keep backward compatibility.

Copilot uses AI. Check for mistakes.
Comment on lines +288 to +292
{
vol.Optional(CONF_CODE, default=code): str,
vol.Optional(CONF_CODE, default=EMPTY_CODE): str,
vol.Optional(CONF_CODE_ARM_REQUIRED, default=code_arm_required): bool,
vol.Optional(CONF_PERI_ALARM, default=peri_alarm): bool,
vol.Optional(CONF_ARM_AWAY_AS_ARM_NIGHT, default=arm_away_as_arm_night): bool,
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

In the options flow, CONF_CODE is given a default of EMPTY_CODE. Submitting the options form without re-entering the PIN will persist an empty code and effectively clear the configured PIN (and thus relax validation). Consider defaulting to the existing configured value, or omit CONF_CODE from the options schema and handle PIN changes via a dedicated step/selector so it can’t be unintentionally wiped.

Copilot uses AI. Check for mistakes.
@clintongormley
Copy link
Copy Markdown
Collaborator

@guerrerotook I wouldn't merge this whole PR, the remapping of alarm statuses is handled in a more generic way in #329. The PIN changes would be worth looking at after #329 is merged

@guerrerotook
Copy link
Copy Markdown
Owner

@clintongormley your call. One question, can you merge this pull request yourself? If you think that this is not valid, you can close and open a new one.

@poupounetjoyeux
Copy link
Copy Markdown
Contributor Author

poupounetjoyeux commented Feb 25, 2026

@guerrerotook I wouldn't merge this whole PR, the remapping of alarm statuses is handled in a more generic way in #329. The PIN changes would be worth looking at after #329 is merged

Yeah I think you can start merging #329 then I have sometime tomorrow and friday to rebase and remove the arm_away / arm_night mapping 👍

@clintongormley
Copy link
Copy Markdown
Collaborator

@clintongormley your call. One question, can you merge this pull request yourself? If you think that this is not valid, you can close and open a new one.

What do you mean by me merging the PR? Do you mean reworking it for your review? Because I don't have merge rights on this repo. I'd be happy to do so, although @poupounetjoyeux sounds like he's up for redoing it as well.

… Night'"

This reverts commit c129d68

Rebase on top of main
@poupounetjoyeux
Copy link
Copy Markdown
Contributor Author

@clintongormley & @guerrerotook,

Following our discussion on #335, I think that you can please reconsider this PR?

This is the final brick to make android auto working 👍

I rebased on top of all other fixes and just tested it locally and can confirm it's working

Thanks by advance

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


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

Comment thread custom_components/securitas/config_flow.py Outdated
Comment on lines +243 to +247
translation_domain=DOMAIN,
translation_key="invalid_pin_code",
translation_placeholders={
"entity_id": self.entity_id,
},
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

ServiceValidationError references translation_key="invalid_pin_code", but there is no corresponding translation entry in the integration’s translation files. Add an exceptions.invalid_pin_code translation (and ensure placeholders like entity_id are defined/used) so Home Assistant can render a proper error message.

Suggested change
translation_domain=DOMAIN,
translation_key="invalid_pin_code",
translation_placeholders={
"entity_id": self.entity_id,
},
message=f"Invalid PIN code for alarm entity {self.entity_id}",

Copilot uses AI. Check for mistakes.
Comment thread custom_components/securitas/translations/en.json
Comment thread custom_components/securitas/alarm_control_panel.py Outdated
clintongormley and others added 3 commits February 27, 2026 12:47
- Add missing translation for ServiceValidationError (invalid_pin_code)
- Fix label phrasing: "PIN code is required to arm?" -> "Require PIN code to arm"
- Fix docstring grammar in _check_code_for_arm_if_required
- Default CONF_CODE in options to existing value to prevent silent PIN wipe
- Simplify code_arm_required lookup using existing _get() helper
- Change DEFAULT_CODE_ARM_REQUIRED to False (arm without PIN by default)
- Sync strings.json and es.json with new keys
- Update README with PIN code and arm-required documentation

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clintongormley
Copy link
Copy Markdown
Collaborator

I've updated the README and translations, and I've changed the default for "Require PIN to arm" to FALSE to avoid the breaking change.

Thanks for the PR @poupounetjoyeux !

@poupounetjoyeux
Copy link
Copy Markdown
Contributor Author

poupounetjoyeux commented Feb 27, 2026

I've updated the README and translations, and I've changed the default for "Require PIN to arm" to FALSE to avoid the breaking change.

Thanks for the PR @poupounetjoyeux !

Again, True is the default behavior but if you prefer not impacting on my side 👌

Thank for merge and other fixes

@clintongormley clintongormley merged commit 5b8a2d9 into guerrerotook:main Feb 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants