Master slave setup with two conditions

Hi and welcome.

It would be best to export your flow so others can see it. Others may not have zigbee or tplink, so best to add inject nodes holding the output from the devices (i.e the on/off output , captured by a debug node )and the format and values of the input to controll the socket. The more info you can give the easier it is to help. Remember images are ok to see, but text is better as it can be copied and pasted easily.

also when adding code best to follow instructions here so code is no corrupted