Fix climate device actions (#28660)

* limit climate device actions

* update test

* use supported_features for device_action

* Fix tests

* user support_features for device_condition
This commit is contained in:
SukramJ authored and Paulus Schoutsen committed 2019-11-25 11:12:00 -08:00
1 parent ea6417bea3
commit 9a5dc848c9
4 files changed
+67 -9

No files matched your search

@@ -53,6 +53,7 @@ async def test_get_conditions(hass, device_reg, entity_reg):
const.ATTR_PRESET_MODES: [const.PRESET_HOME, const.PRESET_AWAY],
},
)
hass.states.async_set("climate.test_5678", "attributes", {"supported_features": 17})
expected_conditions = [
{
"condition": "device",
@@ -73,6 +74,38 @@ async def test_get_conditions(hass, device_reg, entity_reg):
assert_lists_same(conditions, expected_conditions)
async def test_get_conditions_hvac_only(hass, device_reg, entity_reg):
"""Test we get the expected conditions from a climate."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id,
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
)
entity_reg.async_get_or_create(DOMAIN, "test", "5678", device_id=device_entry.id)
hass.states.async_set(
f"{DOMAIN}.test_5678",
const.HVAC_MODE_COOL,
{
const.ATTR_HVAC_MODE: const.HVAC_MODE_COOL,
const.ATTR_PRESET_MODE: const.PRESET_AWAY,
const.ATTR_PRESET_MODES: [const.PRESET_HOME, const.PRESET_AWAY],
},
)
hass.states.async_set("climate.test_5678", "attributes", {"supported_features": 1})
expected_conditions = [
{
"condition": "device",
"domain": DOMAIN,
"type": "is_hvac_mode",
"device_id": device_entry.id,
"entity_id": f"{DOMAIN}.test_5678",
}
]
conditions = await async_get_device_automations(hass, "condition", device_entry.id)
assert_lists_same(conditions, expected_conditions)
async def test_if_state(hass, calls):
"""Test for turn_on and turn_off conditions."""
hass.states.async_set(