Look in my homesystem, you may use BadZombi's timer solution, or see here, as adding the entity's instanceid as a parameter, and then removing it.
Or you may play around with time, like putting the current time into an ini, when you place a bed, and making a timer to check the times in every...