The Automation Command Mapping has parameters for Enabled States and Visible States. These values dictate when/how a button is displayed in common areas such as Ticket, Order, Payment, etc. So if your button is mapped to a common area, you will need States to control it.
However, the Mappings have no effect on an Automation Command Button Widget on a Custom/Layout Entity Screen. That is controlled by the Widget Settings.
If I understand you should just be able to use entity name for that entity type tag/expression as a constraint for is null or is not null to tell wether there is an entity selected of that type.
Where is this command?
How do you mean entity selected?
If selected relates to ticket you can just do {ENTITY NAME:xxx} and if selected for ticket will have value, if not or no ticket will be null.
Where is it? On pos/ticket screen?
You’ll need to set a ticket state as part of an entity changed rule.
I have one for each entity type which sets a state of eg RoomSelected=True.
That one I use to change an account post or room post button, by setting a state of false on ticket created and mapping account post to that state and the room post to true.