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 number platform to Matter integration #119770

Merged
merged 14 commits into from
Jun 21, 2024

Conversation

jvmahon
Copy link
Contributor

@jvmahon jvmahon commented Jun 16, 2024

Proposed change

  • Add base support for the number platform to the Matter integration.

  • Adds support to set the LevelControl transition attributes: OnLevel, OnTransitionTime, OffTransitionTime, OnOffTransitionTime (if present) to the discovery schemas of the number platform, marked as CONFIG entities.

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

To help with the load of incoming pull requests:

Add support for setting of the LevelControl transition attributes:  OnLevel, OnTransitionTime, OffTransitionTime, OnOffTransitionTime (if present)
@home-assistant
Copy link

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

Code owner commands

Code owners of matter 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 matter 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.

@MartinHjelmare MartinHjelmare changed the title Support to set LevelControl transition attributes Add Matter LevelControl transition attribute setting Jun 16, 2024
@marcelveldt marcelveldt changed the title Add Matter LevelControl transition attribute setting Add number platform to Matter integration Jun 16, 2024
Copy link
Member

@marcelveldt marcelveldt left a comment

Choose a reason for hiding this comment

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

Thanks @jvmahon !

@marcelveldt
Copy link
Member

Writing the null value to attributes is not working yet (to reset the value) but that is a bug server side: home-assistant-libs/python-matter-server#768

@jvmahon
Copy link
Contributor Author

jvmahon commented Jun 21, 2024

Writing the null value to attributes is not working yet (to reset the value) but that is a bug server side: home-assistant-libs/python-matter-server#768

I think there is also an issue (more of a "feature request") on the core Number entity (https://developers.home-assistant.io/docs/core/entity/number) which does not allow entering a null in the BOX entry type. At least I think it doesn't. There's probably a need for a feature request to allow an "is_nullable" type flag allowing the entry box to be empty so it reports a null (which can then be written to the nullable Matter attribute when writing nulls if fixed).

@marcelveldt
Copy link
Member

Writing the null value to attributes is not working yet (to reset the value) but that is a bug server side: home-assistant-libs/python-matter-server#768

I think there is also an issue (more of a "feature request") on the core Number entity (https://developers.home-assistant.io/docs/core/entity/number) which does not allow entering a null in the BOX entry type. At least I think it doesn't. There's probably a need for a feature request to allow an "is_nullable" type flag allowing the entry box to be empty so it reports a null (which can then be written to the nullable Matter attribute when writing nulls if fixed).

For now I have solve dit by allowing 255 as value, just like the other integrations handle it (zigbee, zwave)
So 255 is mapped to null

@marcelveldt
Copy link
Member

Oh and yeah, I agree that we should have a "nullable" feature on the select platform. Lets add an architecture discussion for that (if there is not yet one already)

tests/components/matter/test_number.py Show resolved Hide resolved
homeassistant/components/matter/strings.json Outdated Show resolved Hide resolved
@frenck frenck merged commit 12f812d into home-assistant:dev Jun 21, 2024
21 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2024
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

The code coverage job failed correctly and should have blocked this from merging.

async def async_set_native_value(self, value: float) -> None:
"""Update the current value."""
matter_attribute = self._entity_info.primary_attribute
sendvalue = int(value)
Copy link
Member

Choose a reason for hiding this comment

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

Please separate words with underscore, send_value.


state = hass.states.get("number.mock_dimmable_light_on_level")
assert state
assert state.state == "20"
Copy link
Member

Choose a reason for hiding this comment

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

We need to test the set value service of the number entity too.

@jvmahon jvmahon deleted the LevelControl-transition-attributes branch July 6, 2024 21:11
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.

4 participants