but how to make the action perform one time only when the state doesn't change?
This doesn't make sense. When would you perform this action if the state doesn't change?
In your case, there is a state change, too open, when the lid is opened, and a state change, to closed, when the lid is closed.
Play the music when the state changes to open. Do nothing when the state changes to closed.