Rflink: added support for lights with toggle type (#6521)
* added support for lights with toggle type
* fixed style errors
* introduced tests for the toggle type
it's not passing yet because of an assertionerror at line 407
* updated to reflect tristate of "state"
* Format code according to pep8
Added line break for import that was too long.
* fixed lint, replaced if statement with 'var = bool(test)'
* changed implementation of state check according to bug on 6bceb04ca1 (r106758784)
This commit is contained in:
parent
4e91c65d6e
commit
678f273002
3 changed files with 92 additions and 3 deletions
|
@ -342,3 +342,46 @@ def test_signal_repetitions_cancelling(hass, monkeypatch):
|
|||
assert protocol.send_command_ack.call_args_list[1][0][1] == 'on'
|
||||
assert protocol.send_command_ack.call_args_list[2][0][1] == 'on'
|
||||
assert protocol.send_command_ack.call_args_list[3][0][1] == 'on'
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_type_toggle(hass, monkeypatch):
|
||||
"""Test toggle type lights (on/on)."""
|
||||
config = {
|
||||
'rflink': {
|
||||
'port': '/dev/ttyABC0',
|
||||
},
|
||||
DOMAIN: {
|
||||
'platform': 'rflink',
|
||||
'devices': {
|
||||
'toggle_0_0': {
|
||||
'name': 'toggle_test',
|
||||
'type': 'toggle',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
# setup mocking rflink module
|
||||
event_callback, _, _, _ = yield from mock_rflink(
|
||||
hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
assert hass.states.get('light.toggle_test').state == 'off'
|
||||
|
||||
# test sending on command to toggle alias
|
||||
event_callback({
|
||||
'id': 'toggle_0_0',
|
||||
'command': 'on',
|
||||
})
|
||||
yield from hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get('light.toggle_test').state == 'on'
|
||||
|
||||
# test sending group command to group alias
|
||||
event_callback({
|
||||
'id': 'toggle_0_0',
|
||||
'command': 'on',
|
||||
})
|
||||
yield from hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get('light.toggle_test').state == 'off'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue