Enable Google Assistant OnOffTrait for climate devices that support them (#18544)
* Enable Google Assistant OnOffTrait for climate devices that support them This commit enables the OnOffTrait for climate devices that have the SUPPORT_ON_OFF feature. I have tested this locally with a Sensibo device which supports ON_OFF and a nest device that does not. * Update trait.py * Add tests for onoff_climate * Add OnOff trait to climate.heatpump * Add on status to heatpump in google_assistant tests
This commit is contained in:
parent
2f07e92cc2
commit
02309cc318
4 changed files with 49 additions and 1 deletions
|
@ -388,6 +388,47 @@ async def test_onoff_media_player(hass):
|
|||
}
|
||||
|
||||
|
||||
async def test_onoff_climate(hass):
|
||||
"""Test OnOff trait support for climate domain."""
|
||||
assert trait.OnOffTrait.supported(climate.DOMAIN, climate.SUPPORT_ON_OFF)
|
||||
|
||||
trt_on = trait.OnOffTrait(hass, State('climate.bla', STATE_ON),
|
||||
BASIC_CONFIG)
|
||||
|
||||
assert trt_on.sync_attributes() == {}
|
||||
|
||||
assert trt_on.query_attributes() == {
|
||||
'on': True
|
||||
}
|
||||
|
||||
trt_off = trait.OnOffTrait(hass, State('climate.bla', STATE_OFF),
|
||||
BASIC_CONFIG)
|
||||
|
||||
assert trt_off.query_attributes() == {
|
||||
'on': False
|
||||
}
|
||||
|
||||
on_calls = async_mock_service(hass, climate.DOMAIN, SERVICE_TURN_ON)
|
||||
await trt_on.execute(trait.COMMAND_ONOFF, {
|
||||
'on': True
|
||||
})
|
||||
assert len(on_calls) == 1
|
||||
assert on_calls[0].data == {
|
||||
ATTR_ENTITY_ID: 'climate.bla',
|
||||
}
|
||||
|
||||
off_calls = async_mock_service(hass, climate.DOMAIN,
|
||||
SERVICE_TURN_OFF)
|
||||
|
||||
await trt_on.execute(trait.COMMAND_ONOFF, {
|
||||
'on': False
|
||||
})
|
||||
assert len(off_calls) == 1
|
||||
assert off_calls[0].data == {
|
||||
ATTR_ENTITY_ID: 'climate.bla',
|
||||
}
|
||||
|
||||
|
||||
async def test_dock_vacuum(hass):
|
||||
"""Test dock trait support for vacuum domain."""
|
||||
assert trait.DockTrait.supported(vacuum.DOMAIN, 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue