Implement relative volume adjustments for the command_volume_level
notification command
#4056
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances the
command_volume_level
notification command to support both absolute and relative volume adjustments. Introducing a boolean parameter,relative_volume
, allows users to specify whether the provided value is an absolute volume level or a relative adjustment to the current volume. Omitting or setting the parameter tofalse
preserves the original absolute volume behavior.The motivation behind these changes is to make changing the volume as responsible as possible. When I tried to set up an automation for a Zigbee music controller remote to control music playback on an Android device through HA using notification commands, I encountered some difficulties: the volume sensors don't update instantly, so if I wanted to handle multiple successive volume change actions from the remote, these steps were required in the automation:
command_volume_level
notification command with the new absolute volumecommand_update_sensors
notification command, so a potential successive volume change can be handled with the same steps.And the last step made it pretty slow. It can be much faster if the automation doesn't have to wait for the volume sensor to be updated.
This is how the YAML of a service call using this functionality looks like:
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#