Skip to content

Add Quality Scale to ElkM1 Integration#152371

Closed
Hodnc wants to merge 6 commits into
home-assistant:devfrom
Hodnc:Add-Elk-M1-Quality-Scale-09-25
Closed

Add Quality Scale to ElkM1 Integration#152371
Hodnc wants to merge 6 commits into
home-assistant:devfrom
Hodnc:Add-Elk-M1-Quality-Scale-09-25

Conversation

@Hodnc
Copy link
Copy Markdown
Contributor

@Hodnc Hodnc commented Sep 15, 2025

Proposed change

Add Quality Scale to the Elk M1 Integration.

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
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format 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.

To help with the load of incoming pull requests:

@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @gwww, @bdraco, mind taking a look at this pull request as it has been labeled with an integration (elkm1) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of elkm1 can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign elkm1 Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@Hodnc Hodnc changed the title Initial Commit - Add Quality Scale to ElkM1 Integration Add Quality Scale to ElkM1 Integration Sep 15, 2025
@Hodnc Hodnc marked this pull request as ready for review September 17, 2025 00:54
@Hodnc Hodnc requested review from a team and bdraco as code owners September 17, 2025 00:54
Copilot AI review requested due to automatic review settings September 17, 2025 00:54
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 Bronze level Quality Scale support to the ElkM1 integration by implementing required Bronze tier rules and updating configuration descriptions for better user experience.

  • Removes ElkM1 from quality scale exemption lists
  • Adds comprehensive quality scale rule configuration file
  • Enhances configuration flow descriptions for better usability

Reviewed Changes

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

File Description
script/hassfest/quality_scale.py Removes elkm1 from Bronze and Silver tier exemption lists
homeassistant/components/elkm1/strings.json Adds data_description fields for all configuration steps
homeassistant/components/elkm1/quality_scale.yaml Creates new quality scale configuration with Bronze rules marked as done
homeassistant/components/elkm1/manifest.json Adds quality_scale field set to bronze level

Copy link
Copy Markdown
Member

@CoMPaTech CoMPaTech left a comment

Choose a reason for hiding this comment

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

Hi @Hodnc - thanks for the contribution - could you also check for the other items on the scale which are already done (and not per se 'todo')? I.e. just looking at the elkm1 contents I see discovery, so presumably that 'gold' item might be done? If we can already mark more 'done' (even without changing the quality_scale from bronze) is still useful to already include?

@home-assistant home-assistant Bot marked this pull request as draft November 5, 2025 18:44
@home-assistant
Copy link
Copy Markdown
Contributor

home-assistant Bot commented Nov 5, 2025

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@Hodnc Hodnc marked this pull request as ready for review December 12, 2025 10:48
@home-assistant home-assistant Bot requested a review from CoMPaTech December 12, 2025 10:48
Copy link
Copy Markdown
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

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

Let's put the things we agree on fixing in the comments and let's merge this and improve from there :)

@@ -0,0 +1,62 @@
rules:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we still have the import flow?

@@ -0,0 +1,62 @@
rules:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How many entries wouldn't have a unique id at this point?

has-entity-name: done
runtime-data: done
test-before-configure: done
test-before-setup: done
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

            try:
                _included(conf[item]["include"], True, config[item]["included"])
                _included(conf[item]["exclude"], False, config[item]["included"])
            except (ValueError, vol.Invalid) as err:
                _LOGGER.error("Config item: %s; %s", item, err)
                return False

Instead of returning False, raise a ConfigEntryError or ConfigEntryNotReady when not recoverable or recoverable respectively

@@ -0,0 +1,62 @@
rules:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

    def _keypad_changed(keypad: Element, changeset: dict[str, Any]) -> None:
        if (keypress := changeset.get("last_keypress")) is None:
            return

        hass.bus.async_fire(
            EVENT_ELKM1_KEYPAD_KEY_PRESSED,
            {
                ATTR_KEYPAD_NAME: keypad.name,
                ATTR_KEYPAD_ID: keypad.index + 1,
                ATTR_KEY_NAME: keypress[0],
                ATTR_KEY: keypress[1],
            },
        )

    for keypad in elk.keypads:
        keypad.add_callback(_keypad_changed)

This could become an event entity, making it more visible for the users

@@ -0,0 +1,62 @@
rules:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

    @property
    def code_format(self) -> CodeFormat | None:
        """Return the alarm code format."""
        return CodeFormat.NUMBER

Can be set to _attr_code_format

@@ -0,0 +1,62 @@
rules:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

extra_state_attributes -> Can these be more entities on its own?

unique-config-entry: done

# Silver
action-exceptions: done
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

    async def async_alarm_disarm(self, code: str | None = None) -> None:
        """Send disarm command."""
        if code is not None:
            self._element.disarm(int(code))

All alarm control panel methods are like this, but what happens when code is None? Is that realistic? If so, we should handle that error. Also, what happens if element.disarm fails?

@@ -0,0 +1,62 @@
rules:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

class ElkSensor(ElkAttachedEntity, SensorEntity):
    """Base representation of Elk-M1 sensor."""

    _attr_native_value: str | None = None

    async def async_counter_refresh(self) -> None:
        """Refresh the value of a counter from the panel."""
        if not isinstance(self, ElkCounter):
            raise HomeAssistantError("supported only on ElkM1 Counter sensors")
        self._element.get()

    async def async_counter_set(self, value: int | None = None) -> None:
        """Set the value of a counter on the panel."""
        if not isinstance(self, ElkCounter):
            raise HomeAssistantError("supported only on ElkM1 Counter sensors")
        if value is not None:
            self._element.set(value)

    async def async_zone_bypass(self, code: int | None = None) -> None:
        """Bypass zone."""
        if not isinstance(self, ElkZone):
            raise HomeAssistantError("supported only on ElkM1 Zone sensors")
        if code is not None:
            self._element.bypass(code)

    async def async_zone_trigger(self) -> None:
        """Trigger zone."""
        if not isinstance(self, ElkZone):
            raise HomeAssistantError("supported only on ElkM1 Zone sensors")
        self._element.trigger()

Wouldn't it make more sense to make this a button entity for each sensor?

docs-use-cases: todo
dynamic-devices: todo
entity-category: done
entity-device-class: done
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ElkPanel ->

    def _element_changed(self, element: Element, changeset: dict[str, Any]) -> None:
        if self._elk.is_connected():
            self._attr_native_value = "Paused" if self._elk.is_paused() else "Connected"
        else:
            self._attr_native_value = "Disconnected"

This can be an enum device class, where all the values are snake_case (would be a breaking change), but with all the options added to _attr_options. This way HA knows what the states can be

appropriate-polling: done
brands: done
common-modules: done
config-flow-test-coverage: done
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would recommend to put this in a common fixture

patch(
            "homeassistant.components.elkm1.async_setup_entry",
            return_value=True,
        ) as mock_setup_entry,

(and maybe the async_setup as well)

@home-assistant home-assistant Bot marked this pull request as draft December 16, 2025 18:02
@github-actions
Copy link
Copy Markdown

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.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

@github-actions github-actions Bot added the stale label Feb 14, 2026
@github-actions github-actions Bot closed this Feb 21, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 22, 2026
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.

5 participants