Revert "Allow Google Assistant relative volume control (#26585)" (#27416)

This reverts commit 95c537bee88fd2db7507024a1e32eb52364facbb.
This commit is contained in:
Paulus Schoutsen 2019-10-10 12:46:40 -07:00 committed by GitHub
parent 9e3005133a
commit 2ab6eb4fa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 55 deletions

View File

@ -1427,9 +1427,6 @@ class VolumeTrait(_Trait):
async def _execute_volume_relative(self, data, params):
# This could also support up/down commands using relativeSteps
relative = params["volumeRelativeLevel"]
# if we have access to current volume level, do a single 'set' call
if media_player.ATTR_MEDIA_VOLUME_LEVEL in self.state.attributes:
current = self.state.attributes.get(media_player.ATTR_MEDIA_VOLUME_LEVEL)
await self.hass.services.async_call(
@ -1442,18 +1439,6 @@ class VolumeTrait(_Trait):
blocking=True,
context=data.context,
)
# otherwise do multiple 'up' or 'down' calls
else:
for _ in range(abs(relative)):
await self.hass.services.async_call(
media_player.DOMAIN,
media_player.SERVICE_VOLUME_UP
if relative > 0
else media_player.SERVICE_VOLUME_DOWN,
{ATTR_ENTITY_ID: self.state.entity_id},
blocking=True,
context=data.context,
)
async def execute(self, command, data, params, challenge):
"""Execute a brightness command."""

View File

@ -1599,35 +1599,6 @@ async def test_volume_media_player_relative(hass):
}
async def test_volume_media_player_relative_no_vol_lvl(hass):
"""Test volume trait support for media player domain."""
trt = trait.VolumeTrait(
hass, State("media_player.bla", media_player.STATE_PLAYING, {}), BASIC_CONFIG
)
assert trt.sync_attributes() == {}
assert trt.query_attributes() == {}
up_calls = async_mock_service(
hass, media_player.DOMAIN, media_player.SERVICE_VOLUME_UP
)
await trt.execute(
trait.COMMAND_VOLUME_RELATIVE, BASIC_DATA, {"volumeRelativeLevel": 2}, {}
)
assert len(up_calls) == 2
down_calls = async_mock_service(
hass, media_player.DOMAIN, media_player.SERVICE_VOLUME_DOWN
)
await trt.execute(
trait.COMMAND_VOLUME_RELATIVE, BASIC_DATA, {"volumeRelativeLevel": -2}, {}
)
assert len(down_calls) == 2
async def test_temperature_setting_sensor(hass):
"""Test TemperatureSetting trait support for temperature sensor."""
assert (