async def test_pushed_outputs_status_change(hass, entry, lcn_connection): """Test the outputs cover changes its state on status received.""" device_connection = get_device_connection(hass, (0, 7, False), entry) address = LcnAddr(0, 7, False) state = hass.states.get("cover.cover_outputs") state.state = STATE_CLOSED # push status "open" input = ModStatusOutput(address, 0, 100) await device_connection.async_process_input(input) await hass.async_block_till_done() state = hass.states.get("cover.cover_outputs") assert state is not None assert state.state == STATE_OPENING # push status "stop" input = ModStatusOutput(address, 0, 0) await device_connection.async_process_input(input) await hass.async_block_till_done() state = hass.states.get("cover.cover_outputs") assert state is not None assert state.state not in (STATE_OPENING, STATE_CLOSING) # push status "close" input = ModStatusOutput(address, 1, 100) await device_connection.async_process_input(input) await hass.async_block_till_done() state = hass.states.get("cover.cover_outputs") assert state is not None assert state.state == STATE_CLOSING
async def test_pushed_output_status_change(hass, entry, lcn_connection): """Test the output switch changes its state on status received.""" device_connection = get_device_connection(hass, (0, 7, False), entry) address = LcnAddr(0, 7, False) # push status "on" inp = ModStatusOutput(address, 0, 100) await device_connection.async_process_input(inp) await hass.async_block_till_done() state = hass.states.get("switch.switch_output1") assert state.state == STATE_ON # push status "off" inp = ModStatusOutput(address, 0, 0) await device_connection.async_process_input(inp) await hass.async_block_till_done() state = hass.states.get("switch.switch_output1") assert state.state == STATE_OFF
async def test_pushed_output_status_change(hass, entry, lcn_connection): """Test the output light changes its state on status received.""" device_connection = get_device_connection(hass, (0, 7, False), entry) address = LcnAddr(0, 7, False) # push status "on" inp = ModStatusOutput(address, 0, 50) await device_connection.async_process_input(inp) await hass.async_block_till_done() state = hass.states.get("light.light_output1") assert state is not None assert state.state == STATE_ON assert state.attributes[ATTR_BRIGHTNESS] == 127 # push status "off" inp = ModStatusOutput(address, 0, 0) await device_connection.async_process_input(inp) await hass.async_block_till_done() state = hass.states.get("light.light_output1") assert state is not None assert state.state == STATE_OFF
def test_parse_message_percent(pck, expected): """Parse output in percent status message.""" message = f":M000010{pck}" inp = ModStatusOutput.try_parse(message)[0] assert inp.get_output_id() == expected[0] assert inp.get_percent() == expected[1]