mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Patch for Alexa percentage_step to precision (#58062)
* speed_step must be an integer and a divider of 100 * use percentage_step in tests to test patch * test with not supported percentage_step * undo change in test_capabilities * Use a default precision of one not percentage_step * typo 2 * Update tests/components/alexa/test_smart_home.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/alexa/capabilities.py Co-authored-by: Erik Montnemery <erik@montnemery.com> Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
parent
4736bf3c32
commit
a679ebcee7
@ -1535,7 +1535,9 @@ class AlexaRangeController(AlexaCapability):
|
||||
labels=["Percentage", AlexaGlobalCatalog.SETTING_FAN_SPEED],
|
||||
min_value=0,
|
||||
max_value=100,
|
||||
precision=percentage_step if percentage_step else 100,
|
||||
# precision must be a divider of 100 and must be an integer; set step
|
||||
# size to 1 for a consistent behavior except for on/off fans
|
||||
precision=1 if percentage_step else 100,
|
||||
unit=AlexaGlobalCatalog.UNIT_PERCENT,
|
||||
)
|
||||
return self._resource.serialize_capability_resources()
|
||||
|
@ -365,7 +365,7 @@ async def test_fan(hass):
|
||||
assert appliance["endpointId"] == "fan#test_1"
|
||||
assert appliance["displayCategories"][0] == "FAN"
|
||||
assert appliance["friendlyName"] == "Test fan 1"
|
||||
# Alexa.RangeController is added to make a van controllable when no other controllers are available
|
||||
# Alexa.RangeController is added to make a fan controllable when no other controllers are available
|
||||
capabilities = assert_endpoint_capabilities(
|
||||
appliance,
|
||||
"Alexa.RangeController",
|
||||
@ -402,6 +402,39 @@ async def test_fan(hass):
|
||||
)
|
||||
|
||||
|
||||
async def test_fan2(hass):
|
||||
"""Test fan discovery with percentage_step."""
|
||||
|
||||
# Test fan discovery with percentage_step
|
||||
device = (
|
||||
"fan.test_2",
|
||||
"on",
|
||||
{
|
||||
"friendly_name": "Test fan 2",
|
||||
"percentage": 66,
|
||||
"supported_features": 1,
|
||||
"percentage_step": 33.3333,
|
||||
},
|
||||
)
|
||||
appliance = await discovery_test(device, hass)
|
||||
|
||||
assert appliance["endpointId"] == "fan#test_2"
|
||||
assert appliance["displayCategories"][0] == "FAN"
|
||||
assert appliance["friendlyName"] == "Test fan 2"
|
||||
# Alexa.RangeController is added to make a fan controllable when no other controllers are available
|
||||
capabilities = assert_endpoint_capabilities(
|
||||
appliance,
|
||||
"Alexa.RangeController",
|
||||
"Alexa.PowerController",
|
||||
"Alexa.EndpointHealth",
|
||||
"Alexa",
|
||||
)
|
||||
|
||||
power_capability = get_capability(capabilities, "Alexa.PowerController")
|
||||
assert "capabilityResources" not in power_capability
|
||||
assert "configuration" not in power_capability
|
||||
|
||||
|
||||
async def test_variable_fan(hass):
|
||||
"""Test fan discovery.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user