Skip to content

Matter Speaker volume LevelControl #149490

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

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from
Open

Conversation

lboue
Copy link
Contributor

@lboue lboue commented Jul 26, 2025

Proposed change

Matter Speaker for discussion #348.
It exposes a volume slider using the LevelControl cluster CurrentLevel attribute.
I removed the OnLevel selector as the specs ares not very clear about this for speakers and it not really usefull.

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue: discussion #348
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

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

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.

@lboue lboue changed the title Matter Speaker Volume LevelControl Matter Speaker Jul 26, 2025
@lboue lboue changed the title Volume LevelControl Matter Speaker Matter Speaker volume LevelControl Jul 26, 2025
@lboue lboue marked this pull request as ready for review July 26, 2025 18:12
@lboue lboue requested a review from a team as a code owner July 26, 2025 18:12
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'On level',
Copy link
Member

Choose a reason for hiding this comment

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

What does "On level" represent on the speaker?

Copy link
Contributor Author

@lboue lboue Aug 5, 2025

Choose a reason for hiding this comment

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

It represents the default volume level when the speaker is unmuted.
I agree that the implementation of the speaker type with the Levelcontrol cluster is not the most intuitive.
The cluster is primarily used for dimmable lamps, but it is included in the Matter specifications for other devices such as pumps, etc.

Copy link
Member

Choose a reason for hiding this comment

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

What's the difference between this volume level and the other volume level?

Copy link
Contributor Author

@lboue lboue Aug 6, 2025

Choose a reason for hiding this comment

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

It works the same way as a light:

  • Level Attribute: The current volume you can choose when the speaker is on.
  • OnLevel Attribute: The volume when the speaker is turned unmuted.

Specs

OnLevel Attribute

This attribute SHALL indicate the value that the CurrentLevel attribute is set to when the OnOff
attribute of an On/Off cluster on the same endpoint is set to TRUE, as a result of processing an
On/Off cluster command. If the OnLevel attribute is not implemented, or is set to the null value, it
has no effect. For more details see Effect of On/Off Commands on the CurrentLevel attribute.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Do we explain this somewhere? I would not have understood what it does from the current name only.

This is a side note, that we don't need to address here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Very good point as I've been struggling with finding a good translation for "On level" before, because in German that does differ depending on what device type we're talking about.

So currently "On level" can show up under Configuration for lights, speakers and others?

Copy link
Contributor Author

@lboue lboue Aug 7, 2025

Choose a reason for hiding this comment

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

The value of the OnLevel attribute is null, which I don't think should be displayed, but there is a strange implementation that replaces the value with 255.

# use 255 to indicate that the value should revert to the default
device_to_ha=lambda x: 255 if x is None else x,
ha_to_device=lambda x: None if x == 255 else int(x),

Yes, in principle, this can appear for all types that use the LevelControl cluster. Perhaps this implementation should be restricted to light types only, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

The zha integration also implements on_level as a number entity. Here the German translation was changed to "Einschalthelligkeit" ("brightness level when turned on") by a user in 2024.

It always makes me nervous when I see such a differing wording because while adding clarity in the correct context it could be complete nonsense if it also shows up in other areas.

So if you could set different translations depending on the device type having this as "Default brightness" (if restricted to lights) or "Default volume" here would be really helpful.

Copy link
Contributor Author

@lboue lboue Aug 7, 2025

Choose a reason for hiding this comment

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

So if you could set different translations depending on the device type having this as "Default brightness" (if restricted to lights) or "Default volume" here would be really helpful.

I removed it as the specs ares not very clear about this for speakers and it not really usefull.

Copy link
Contributor

Choose a reason for hiding this comment

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

Very good, then we can revisit the "On level" setting for lights at some later date!

@MartinHjelmare MartinHjelmare marked this pull request as draft August 5, 2025 21:25
@lboue lboue marked this pull request as ready for review August 5, 2025 21:54
@marcelveldt
Copy link
Member

Shouldn't we just implement the media player platform for Matter speakers first?

@lboue
Copy link
Contributor Author

lboue commented Aug 7, 2025

Shouldn't we just implement the media player platform for Matter speakers first?

Hello Marcel,

Could it work if we only add there features for MediaPlayerEntity?

VOLUME_MUTE	Entity volume can be muted.
VOLUME_SET	Entity volume can be set to specific levels.
VOLUME_STEP	Entity volume can be adjusted up and down.

Do you know of any brands that have implemented this Matter speakers device type? I couldn't find anything on the CSA website https://csa-iot.org/csa-iot_products/.

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