Пример #1
0
async def test_pushed_relay_status_change(hass, entry, lcn_connection):
    """Test the relay light changes its state on status received."""
    device_connection = get_device_connection(hass, (0, 7, False), entry)
    address = LcnAddr(0, 7, False)
    states = [False] * 8

    # push status "on"
    states[0] = True
    inp = ModStatusRelays(address, states)
    await device_connection.async_process_input(inp)
    await hass.async_block_till_done()

    state = hass.states.get("light.light_relay1")
    assert state is not None
    assert state.state == STATE_ON

    # push status "off"
    states[0] = False
    inp = ModStatusRelays(address, states)
    await device_connection.async_process_input(inp)
    await hass.async_block_till_done()

    state = hass.states.get("light.light_relay1")
    assert state is not None
    assert state.state == STATE_OFF
Пример #2
0
async def test_pushed_relays_status_change(hass, entry, lcn_connection):
    """Test the relays cover changes its state on status received."""
    device_connection = get_device_connection(hass, (0, 7, False), entry)
    address = LcnAddr(0, 7, False)
    states = [False] * 8

    state = hass.states.get("cover.cover_relays")
    state.state = STATE_CLOSED

    # push status "open"
    states[0:2] = [True, False]
    input = ModStatusRelays(address, states)
    await device_connection.async_process_input(input)
    await hass.async_block_till_done()

    state = hass.states.get("cover.cover_relays")
    assert state is not None
    assert state.state == STATE_OPENING

    # push status "stop"
    states[0] = False
    input = ModStatusRelays(address, states)
    await device_connection.async_process_input(input)
    await hass.async_block_till_done()

    state = hass.states.get("cover.cover_relays")
    assert state is not None
    assert state.state not in (STATE_OPENING, STATE_CLOSING)

    # push status "close"
    states[0:2] = [True, True]
    input = ModStatusRelays(address, states)
    await device_connection.async_process_input(input)
    await hass.async_block_till_done()

    state = hass.states.get("cover.cover_relays")
    assert state is not None
    assert state.state == STATE_CLOSING