The template sensor is a good idea, the other option is to lock the switch with the Lovelace restriction card.