Implement ToggleController, RangeController, and ModeController in alexa (#27302)
* Implement AlexaToggleController, AlexaRangeController, and AlexaModeController interfaces. * Implement AlexaToggleController, AlexaRangeController, and AlexaModeController interfaces. * Unkerfuffled comments to please the pydocstyle gods. * Unkerfuffled comments in Tests to please the pydocstyle gods. * Added additional test for more coverage. * Removed OSCILLATING property check from from ModeController. * Added capability report tests for ModeController, ToggleController, RangeController, PowerLevelController. * Update homeassistant/components/alexa/capabilities.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/alexa/capabilities.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Corrected mis-spelling of AlexaCapability class. * Changed instance from method to property in AlexaCapability class. * Refactored to add {entity.domain}.{entity.attribute} to the instance name. * Improved type handling for configuration object. Added additional test for configuration object. * Added Tests for unsupported domains for ModeController and RangeController * Made changes to improve future scaling for other domains. * Split fan range to speed maps into multiple constants.
This commit is contained in:
1 parent
dc3aa43f73
commit
da094e09fa
10 files changed
+1190
-53
No files matched your search
@@ -305,7 +305,7 @@ async def test_report_colored_temp_light_state(hass):
|
||||
|
||||
|
||||
async def test_report_fan_speed_state(hass):
|
||||
"""Test PercentageController reports fan speed correctly."""
|
||||
"""Test PercentageController, PowerLevelController, RangeController reports fan speed correctly."""
|
||||
hass.states.async_set(
|
||||
"fan.off",
|
||||
"off",
|
||||
@@ -333,15 +333,82 @@ async def test_report_fan_speed_state(hass):
|
||||
|
||||
properties = await reported_properties(hass, "fan.off")
|
||||
properties.assert_equal("Alexa.PercentageController", "percentage", 0)
|
||||
properties.assert_equal("Alexa.PowerLevelController", "powerLevel", 0)
|
||||
properties.assert_equal("Alexa.RangeController", "rangeValue", 0)
|
||||
|
||||
properties = await reported_properties(hass, "fan.low_speed")
|
||||
properties.assert_equal("Alexa.PercentageController", "percentage", 33)
|
||||
properties.assert_equal("Alexa.PowerLevelController", "powerLevel", 33)
|
||||
properties.assert_equal("Alexa.RangeController", "rangeValue", 1)
|
||||
|
||||
properties = await reported_properties(hass, "fan.medium_speed")
|
||||
properties.assert_equal("Alexa.PercentageController", "percentage", 66)
|
||||
properties.assert_equal("Alexa.PowerLevelController", "powerLevel", 66)
|
||||
properties.assert_equal("Alexa.RangeController", "rangeValue", 2)
|
||||
|
||||
properties = await reported_properties(hass, "fan.high_speed")
|
||||
properties.assert_equal("Alexa.PercentageController", "percentage", 100)
|
||||
properties.assert_equal("Alexa.PowerLevelController", "powerLevel", 100)
|
||||
properties.assert_equal("Alexa.RangeController", "rangeValue", 3)
|
||||
|
||||
|
||||
async def test_report_fan_oscillating(hass):
|
||||
"""Test ToggleController reports fan oscillating correctly."""
|
||||
hass.states.async_set(
|
||||
"fan.off",
|
||||
"off",
|
||||
{"friendly_name": "Off fan", "speed": "off", "supported_features": 3},
|
||||
)
|
||||
hass.states.async_set(
|
||||
"fan.low_speed",
|
||||
"on",
|
||||
{
|
||||
"friendly_name": "Low speed fan",
|
||||
"speed": "low",
|
||||
"oscillating": True,
|
||||
"supported_features": 3,
|
||||
},
|
||||
)
|
||||
|
||||
properties = await reported_properties(hass, "fan.off")
|
||||
properties.assert_equal("Alexa.ToggleController", "toggleState", "OFF")
|
||||
|
||||
properties = await reported_properties(hass, "fan.low_speed")
|
||||
properties.assert_equal("Alexa.ToggleController", "toggleState", "ON")
|
||||
|
||||
|
||||
async def test_report_fan_direction(hass):
|
||||
"""Test ModeController reports fan direction correctly."""
|
||||
hass.states.async_set(
|
||||
"fan.off", "off", {"friendly_name": "Off fan", "supported_features": 4}
|
||||
)
|
||||
hass.states.async_set(
|
||||
"fan.reverse",
|
||||
"on",
|
||||
{
|
||||
"friendly_name": "Fan Reverse",
|
||||
"direction": "reverse",
|
||||
"supported_features": 4,
|
||||
},
|
||||
)
|
||||
hass.states.async_set(
|
||||
"fan.forward",
|
||||
"on",
|
||||
{
|
||||
"friendly_name": "Fan Forward",
|
||||
"direction": "forward",
|
||||
"supported_features": 4,
|
||||
},
|
||||
)
|
||||
|
||||
properties = await reported_properties(hass, "fan.off")
|
||||
properties.assert_not_has_property("Alexa.ModeController", "mode")
|
||||
|
||||
properties = await reported_properties(hass, "fan.reverse")
|
||||
properties.assert_equal("Alexa.ModeController", "mode", "reverse")
|
||||
|
||||
properties = await reported_properties(hass, "fan.forward")
|
||||
properties.assert_equal("Alexa.ModeController", "mode", "forward")
|
||||
|
||||
|
||||
async def test_report_cover_percentage_state(hass):
|
||||
|
||||
Reference in new issue
Block a user