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_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
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_lock_setpoint_status_change(hass, entry, lcn_connection): """Test the lock setpoint sensor changes its state on status received.""" device_connection = get_device_connection(hass, (0, 7, False), entry) address = LcnAddr(0, 7, False) # push status lock setpoint inp = ModStatusVar(address, Var.R1VARSETPOINT, VarValue(0x8000)) await device_connection.async_process_input(inp) await hass.async_block_till_done() state = hass.states.get(BINARY_SENSOR_LOCKREGULATOR1) assert state is not None assert state.state == STATE_ON # push status unlock setpoint inp = ModStatusVar(address, Var.R1VARSETPOINT, VarValue(0x7FFF)) await device_connection.async_process_input(inp) await hass.async_block_till_done() state = hass.states.get(BINARY_SENSOR_LOCKREGULATOR1) assert state is not None assert state.state == STATE_OFF
async def test_pushed_variable_status_change(hass, entry, lcn_connection): """Test the variable sensor changes its state on status received.""" device_connection = get_device_connection(hass, (0, 7, False), entry) address = LcnAddr(0, 7, False) # push status variable inp = ModStatusVar(address, Var.VAR1, VarValue.from_celsius(42)) await device_connection.async_process_input(inp) await hass.async_block_till_done() state = hass.states.get(SENSOR_VAR1) assert state is not None assert float(state.state) == 42.0 # push status setpoint inp = ModStatusVar(address, Var.R1VARSETPOINT, VarValue.from_celsius(42)) await device_connection.async_process_input(inp) await hass.async_block_till_done() state = hass.states.get(SENSOR_SETPOINT1) assert state is not None assert float(state.state) == 42.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
async def test_pushed_ledlogicop_status_change(hass, entry, lcn_connection): """Test the led and logicop sensor changes its state on status received.""" device_connection = get_device_connection(hass, (0, 7, False), entry) address = LcnAddr(0, 7, False) states_led = [LedStatus.OFF] * 12 states_logicop = [LogicOpStatus.NONE] * 4 states_led[5] = LedStatus.ON states_logicop[0] = LogicOpStatus.ALL # push status led and logicop inp = ModStatusLedsAndLogicOps(address, states_led, states_logicop) await device_connection.async_process_input(inp) await hass.async_block_till_done() state = hass.states.get(SENSOR_LED6) assert state is not None assert state.state == "on" state = hass.states.get(SENSOR_LOGICOP1) assert state is not None assert state.state == "all"
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
async def test_pushed_binsensor_status_change(hass, entry, lcn_connection): """Test the binary port sensor 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 binary port "off" inp = ModStatusBinSensors(address, states) await device_connection.async_process_input(inp) await hass.async_block_till_done() state = hass.states.get(BINARY_SENSOR_SENSOR1) assert state is not None assert state.state == STATE_OFF # push status binary port "on" states[0] = True inp = ModStatusBinSensors(address, states) await device_connection.async_process_input(inp) await hass.async_block_till_done() state = hass.states.get(BINARY_SENSOR_SENSOR1) assert state is not None assert state.state == STATE_ON
async def test_pushed_keylock_status_change(hass, entry, lcn_connection): """Test the keylock sensor changes its state on status received.""" device_connection = get_device_connection(hass, (0, 7, False), entry) address = LcnAddr(0, 7, False) states = [[False] * 8 for i in range(4)] # push status keylock "off" inp = ModStatusKeyLocks(address, states) await device_connection.async_process_input(inp) await hass.async_block_till_done() state = hass.states.get(BINARY_SENSOR_KEYLOCK) assert state is not None assert state.state == STATE_OFF # push status keylock "on" states[0][4] = True inp = ModStatusKeyLocks(address, states) await device_connection.async_process_input(inp) await hass.async_block_till_done() state = hass.states.get(BINARY_SENSOR_KEYLOCK) assert state is not None assert state.state == STATE_ON