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

Add Custom mapping of Risco states #39218

Merged
merged 6 commits into from
Aug 28, 2020

Conversation

OnFreund
Copy link
Contributor

@OnFreund OnFreund commented Aug 24, 2020

Proposed change

Enable custom configuration of Risco and HA alarm states. The user can define a two-way mapping - which HA state the entity will be in when Risco is reporting state X, and how to arm Risco when arming the entity in mode Y.
The possible Risco states are:

  • Arm
  • Partial Arm
  • Group A Armed
  • Group B Armed
  • Group C Armed
  • Group D Armed

The possible HA states are:

  • STATE_ALARM_ARMED_AWAY
  • STATE_ALARM_ARMED_CUSTOM_BYPASS
  • STATE_ALARM_ARMED_HOME
  • STATE_ALARM_ARMED_NIGHT

Only HA states that are mapped will be supported by the entity.

This also marks the last PR in the roadmap I laid out in the initial PR for this integration. I do have other minor stuff potentially coming up, like (un)bypassing zones, but nothing major.

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)
  • 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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

Comment on lines +168 to 170
if not risco_state:
_LOGGER.warning("No mapping for mode %s", mode)
return
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure how to cover this with a test. Hypothetically, this condition can't happen, but it seems wise to add this guard to protect against a bug that would cause it to.

Copy link
Contributor

Choose a reason for hiding this comment

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

have you tried initializing the mock entity with options that are missing one of the keys? might that trigger it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any keys that are missing in ha_to_risco mean that the entity wouldn't report those services as supported, thus there's no way to run them...

@ctalkington ctalkington merged commit b14af3e into home-assistant:dev Aug 28, 2020
@OnFreund OnFreund deleted the risco_custom_mapping branch August 28, 2020 06:29
weissm pushed a commit to weissm/core that referenced this pull request Aug 28, 2020
* Custom mapping of Risco states

* More informative error log

* Add alternative Risco terms

* Black formatting
leikoilja pushed a commit to leikoilja/core that referenced this pull request Sep 6, 2020
* Custom mapping of Risco states

* More informative error log

* Add alternative Risco terms

* Black formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants