mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Filter int in fan speed_list when yielding RangeController in Alexa (#31375)
* Allow for int in fan speed_list. * Test for int in fan speed_list. * prevent yielding preset for int labels.
This commit is contained in:
parent
a958418ef1
commit
e796de6c59
@ -1386,11 +1386,15 @@ class AlexaRangeController(AlexaCapability):
|
||||
precision=1,
|
||||
)
|
||||
for index, speed in enumerate(speed_list):
|
||||
labels = [speed.replace("_", " ")]
|
||||
labels = []
|
||||
if isinstance(speed, str):
|
||||
labels.append(speed.replace("_", " "))
|
||||
if index == 1:
|
||||
labels.append(AlexaGlobalCatalog.VALUE_MINIMUM)
|
||||
if index == max_value:
|
||||
labels.append(AlexaGlobalCatalog.VALUE_MAXIMUM)
|
||||
|
||||
if len(labels) > 0:
|
||||
self._resource.add_preset(value=index, labels=labels)
|
||||
|
||||
return self._resource.serialize_capability_resources()
|
||||
|
@ -669,7 +669,7 @@ async def test_fan_range(hass):
|
||||
{
|
||||
"friendly_name": "Test fan 5",
|
||||
"supported_features": 1,
|
||||
"speed_list": ["off", "low", "medium", "high", "turbo", "warp_speed"],
|
||||
"speed_list": ["off", "low", "medium", "high", "turbo", 5, "warp_speed"],
|
||||
"speed": "medium",
|
||||
},
|
||||
)
|
||||
@ -705,7 +705,7 @@ async def test_fan_range(hass):
|
||||
|
||||
supported_range = configuration["supportedRange"]
|
||||
assert supported_range["minimumValue"] == 0
|
||||
assert supported_range["maximumValue"] == 5
|
||||
assert supported_range["maximumValue"] == 6
|
||||
assert supported_range["precision"] == 1
|
||||
|
||||
presets = configuration["presets"]
|
||||
@ -737,8 +737,10 @@ async def test_fan_range(hass):
|
||||
},
|
||||
} in presets
|
||||
|
||||
assert {"rangeValue": 5} not in presets
|
||||
|
||||
assert {
|
||||
"rangeValue": 5,
|
||||
"rangeValue": 6,
|
||||
"presetResources": {
|
||||
"friendlyNames": [
|
||||
{"@type": "text", "value": {"text": "warp speed", "locale": "en-US"}},
|
||||
@ -767,6 +769,17 @@ async def test_fan_range(hass):
|
||||
payload={"rangeValue": 5},
|
||||
instance="fan.speed",
|
||||
)
|
||||
assert call.data["speed"] == 5
|
||||
|
||||
call, _ = await assert_request_calls_service(
|
||||
"Alexa.RangeController",
|
||||
"SetRangeValue",
|
||||
"fan#test_5",
|
||||
"fan.set_speed",
|
||||
hass,
|
||||
payload={"rangeValue": 6},
|
||||
instance="fan.speed",
|
||||
)
|
||||
assert call.data["speed"] == "warp_speed"
|
||||
|
||||
await assert_range_changes(
|
||||
|
Loading…
x
Reference in New Issue
Block a user