An assembly for controlling access to contents of a container includes a cap configured to close the container when mounted thereon; a plurality of sensors configured to sense environmental, physical and/or temporal conditions on the cap; and a processor configured to process data from one or more of the sensors based upon the sensed environmental, physical and/or temporal conditions and configured to provide an indication to a user of recommended access to the container. In certain embodiments, the assembly also includes an electromechanical locking unit configured to selectively lock the cap onto the container and to unlock the cap from the container to allow access to the container, and the processor is configured to unlock the electromechanical locking unit to allow the cap to be detached from the container upon fulfillment of one or more predetermined environmental, physical and/or temporal conditions.