Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align manual_mqtt alarm control panel with manual #82368

Closed
wants to merge 18 commits into from

Conversation

bonzini
Copy link
Contributor

@bonzini bonzini commented Nov 19, 2022

Breaking change

Manual MQTT Alarm Control Panel

When going from state "disarmed" to any other (armed) state such as "armed_away", the state will be "arming" instead of "pending" during the transition time as set in the configuration.

When going from an armed state (such as "armed_away") to the "triggered" state the state will still be "pending" during the transition time as set in the configuration (as it was before).

State attribute "pre_pending_state" changed to "previous_state"

State attribute "post_pending_state" changed to "next_state"

config option "pending_time" is renamed to "arming_time", functionality is the same

The time the alarm stays at "pending" when triggered has changed from delay_time of the previous state + arming_time (previously known as pending_time) of the triggered state to only the delay_time of the previous state

This makes the manual MQTT alarm control panel integration consistent with the manual alarm control panel.

Proposed change

The manual_mqtt and manual alarm control panel integrations have diverged. The intention of the two is to be as similar as possible, in fact manual_mqtt documentation leaves most of the detail to manual.

This includes:

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (alarm_control_panel) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of alarm_control_panel can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign alarm_control_panel Removes the current integration label and assignees on the issue, add the integration domain after the command.

@bonzini
Copy link
Contributor Author

bonzini commented Nov 20, 2022

Added more changes. At this point the easiest way to review this is to diff the two components and the corresponding tests, since the only changes basically are related to MQTT.

@bonzini
Copy link
Contributor Author

bonzini commented Nov 28, 2022

@MartinHjelmare a few years ago you reviewed my manual/manual-mqtt pull request...

@bonzini
Copy link
Contributor Author

bonzini commented Nov 30, 2022

Given little attention on this PR, I have opened #82990 with the manual bugfixes. If it is accepted before this one, I will add the relevant commits here as well.

@bonzini bonzini changed the title Align manual_mqtt alarm control panel with manual Draft: Align manual_mqtt alarm control panel with manual Dec 6, 2022
@frenck frenck changed the title Draft: Align manual_mqtt alarm control panel with manual Align manual_mqtt alarm control panel with manual Dec 6, 2022
@bonzini bonzini marked this pull request as ready for review December 19, 2022 16:44
Copy link
Contributor

@jbouwh jbouwh left a comment

Choose a reason for hiding this comment

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

If you want to add new functionality, please register an issue in the UI to notify users and make sure it does not break the config of existing users.
If you want to fix anything, please apply a non breaking fix in a separate PR.
If you want to improve code quality to non related code, do this in a separate PR.

@@ -9,6 +9,9 @@
ATTR_CHANGED_BY: Final = "changed_by"
ATTR_CODE_ARM_REQUIRED: Final = "code_arm_required"

ATTR_PREVIOUS_STATE: Final = "previous_state"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let us not attributes here.

}
if self.state in (STATE_ALARM_PENDING, STATE_ALARM_ARMING):
return {
ATTR_PREVIOUS_STATE: self._previous_state,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it really necessary to change these attributes and break.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately yes, it is. The real motivation for me to do this PR is that I would like to have alarm control panel groups (reviving my old work from #11323), and the group needs some consistency between the devices that they include. While the group code I have written can deal with a control panel that doesn't have previous/next state attributes, the behavior is inferior.

This also justifies moving them to const, because they become standardized for all alarm control panels that want to provide full functionality for groups.

I have created a single large pull request because, more than new functionality I saw this work as fixing the mistakes that led "manual" and "manual MQTT" to become unsynchronized (#10697, #17270, #32950 and #55340). It is really easier to review the combined changes than any split PR, but of course I can split it if you prefer.

To be honest, I did wonder if the "manual MQTT" integration should exist at all. It seems just as easy to do it using a "normal" manual control panel plus a template alarm control panel. But it seems to have a couple hundred users according to the telemetry, so I didn't propose the deprecation route.

@bonzini
Copy link
Contributor Author

bonzini commented Dec 19, 2022

I will open separate pull requests with (to be applied in this order):

[x] #84264: new states and test parametrization (largest and with the worst conflicts)
[ ] the rename of PRE_PENDING to POST_PENDING and PREVIOUS to NEXT (basic requirement for the alarm group)
[ ] the breaking changes to introduce the ARMING state
[ ] RestoreEntity support (this might move earlier depending on how the conflicts look like).
[ ] the other cosmetic changes to the code

I will keep this pull request as "perennial draft" to track the missing changes.

The manual alarm control panel supports ARMED_CUSTOM_BYPASS and ARMED_VACATION.
Bring them over to the MQTT version.
As part of home-assistant#32950, the manual control panel\s state attributes
were renamed from pre_pending_state and post_pending_state to
previous_state and next_state.  Unfortunately, this change was
not applied to manual_mqtt.

I would like to add alarm control panel groups, and the group code
needs some consistency between the devices that they include.

So, bring over the change.
This will be useful to properly restore timers on restart.
Commit 7bfc1d2 made a major change to the
manual alarm panel state machine, but it wasn't brought over to manual
MQTT.  Do it now.
@jbouwh
Copy link
Contributor

jbouwh commented Dec 20, 2022

the breaking changes to introduce the ARMING state

Try to deprecate first to avoid breaking using repairs. Later you can remove the work-a-rounds.

@github-actions
Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Mar 20, 2023
@github-actions github-actions bot closed this Mar 27, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants