Google assistant openclose (#39612)

* Make sure we set discreteOnlyOpenClose for binary sensors

* Mark switches that are assumed state as commandOnlyOnOff

* Drop stray extra line

* Fix pylint error

Co-authored-by: springstan <46536646+springstan@users.noreply.github.com>
This commit is contained in:
Joakim Plateandspringstan authored and GitHub committed 2020-09-03 18:32:57 +02:00
1 parent 8818a5ab6c
commit d128443a2a
3 files changed
+20 -3

No files matched your search

@@ -795,7 +795,10 @@ async def test_device_class_binary_sensor(hass, device_class, google_type):
"agentUserId": "test-agent",
"devices": [
{
"attributes": {"queryOnlyOpenClose": True},
"attributes": {
"queryOnlyOpenClose": True,
"discreteOnlyOpenClose": True,
},
"id": "binary_sensor.demo_sensor",
"name": {"name": "Demo Sensor"},
"traits": ["action.devices.traits.OpenClose"],
@@ -208,6 +208,11 @@ async def test_onoff_switch(hass):
assert trt_off.query_attributes() == {"on": False}
trt_assumed = trait.OnOffTrait(
hass, State("switch.bla", STATE_OFF, {"assumed_state": True}), BASIC_CONFIG
)
assert trt_assumed.sync_attributes() == {"commandOnlyOnOff": True}
on_calls = async_mock_service(hass, switch.DOMAIN, SERVICE_TURN_ON)
await trt_on.execute(trait.COMMAND_ONOFF, BASIC_DATA, {"on": True}, {})
assert len(on_calls) == 1
@@ -2022,7 +2027,10 @@ async def test_openclose_binary_sensor(hass, device_class):
BASIC_CONFIG,
)
assert trt.sync_attributes() == {"queryOnlyOpenClose": True}
assert trt.sync_attributes() == {
"queryOnlyOpenClose": True,
"discreteOnlyOpenClose": True,
}
assert trt.query_attributes() == {"openPercent": 100}
@@ -2032,7 +2040,10 @@ async def test_openclose_binary_sensor(hass, device_class):
BASIC_CONFIG,
)
assert trt.sync_attributes() == {"queryOnlyOpenClose": True}
assert trt.sync_attributes() == {
"queryOnlyOpenClose": True,
"discreteOnlyOpenClose": True,
}
assert trt.query_attributes() == {"openPercent": 0}