Template useing device tracker for triggering an automation when any device except named device connects to the network

Hi,

I live in a duplex (airbnb one unit and live in the other) I have two SSID’s for guests and people I know. I have figured out how to setup presence detection for automating my thermostat within my wifi network but how would this be done in the guest wifi network.

What I want to do is set up a template that says “If any device connects to the Guest network except device A and B resume the thermostat program but if only device A and B are connected the Guest network switch to away mode” is this possible? Can anyone point me in the right direction to figuring this out. I cannot seem to find anything about it.

Thanks!