Add requirements to execute entity

Not sure if this is possible, but could additional requirements be added within Home Assistant in order to execute a function of an entity? E.g. to unlock a door, the command must be executed from the trusted device, or the device must be present. I recognize that this is a bit of an extreme edge case, but was curious if this capability existed.