Makes AndroidAuto working#326
Conversation
|
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 |
0635a0d to
bbe0eb9
Compare
|
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) |
|
Just tested in my car and I confirm all is working from HA and from AndroidAuto 👌 |
88362da to
2a3283e
Compare
|
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) |
|
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 |
|
Hello @clintongormley |
There was a problem hiding this comment.
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.
| "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)", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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)", |
There was a problem hiding this comment.
Typo in the translation string: "usefull" should be "useful".
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
| 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] |
There was a problem hiding this comment.
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.
| { | ||
| 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, |
There was a problem hiding this comment.
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.
|
@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 |
|
@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. |
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 👍 |
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. |
5900f4c to
af6d5bf
Compare
… Night'" This reverts commit c129d68 Rebase on top of main
60194db to
ab85ac7
Compare
|
@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 |
There was a problem hiding this comment.
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.
| translation_domain=DOMAIN, | ||
| translation_key="invalid_pin_code", | ||
| translation_placeholders={ | ||
| "entity_id": self.entity_id, | ||
| }, |
There was a problem hiding this comment.
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.
| 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}", |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
- 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]>
|
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 |
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