Set entity state local only

Hi !

I would like to restrict action on an entity to local only.
For example, I have a smart plug with switch.mysmartplug entity and an entity card for this in lovelace.
My wife and I are using HA Companion on our smartphone and I would like that we can switch this entity state only when we are at home (trying to use it elsewhere must me impossible).

So I’m wondering how this could me possible ?

To know if the person who try to switch the entity is at home, I think it could be with Wifi network detection or with the person entity localisation…