Xisuma posted a guide to make a rather advanced system for solo sleeping. Features include thunderstorm detection, player notification, and ability to kick players out of the bed if you want the night to stay.
Preparation commands (underscored are things you can rename to your liking):
/scoreboard objectives add sleep dummy
/scoreboard objectives add KickBed trigger
/gamerule commandBlockOutput false
/gamerule logAdminCommands false
Command blocks (unmarked ones and A blocks are repeat/unconditional/always active, B & C blocks are chain/conditional/always active):
1A) scoreboard players add @a sleep 1 {Sleeping:1b}
1B) scoreboard players enable @a KickBed
2) execute @a[score_sleep_min=1,score_sleep=1] ~ ~ ~ tellraw @a ["",{"selector":"@p"},{"text":" is now sleeping","color":"white","clickEvent":{"action":"run_command","value":"/trigger KickBed set 1"},"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"Click to kick!","color":"red"}]}}}]
3A) scoreboard players set @a[score_sleep_min=1] sleep 0 {Sleeping:0b}
3B) execute @a[score_sleep_min=0] ~ ~ ~ /trigger KickBed set 0
4) execute @p[score_sleep_min=110] ~ ~ ~ /time add 100
5) execute @p[score_sleep_min=230] ~ ~ ~ /weather thunder 1
6A) execute @a[score_sleep_min=1] ~ ~ ~ testfor @a[score_KickBed_min=1]
6B) execute @a[score_sleep_min=1] ~ ~ ~ summon Snowball ~ ~2 ~
6C) scoreboard players set @a KickBed 0
Explanation:
- block chain 1 counts ticks players in beds have been sleeping, and enabled the kick trigger if there is any such player.
- block 2 creates notification for each player who has slept for exactly one tick (so it won't repeat). Notification has some additional JSON voodoo that lets players trigger a command by clicking it.
- block chain 3 clears out sleep score for players who got out of bed and disables the kick trigger
- block 4 fast-forwards the daytime if a player sleeps longer than it'd normally take
- block 5 triggers if player has slept for way too long, indicating there is thunderstorm going on. It cuts the thunderstorm to one more second, letting weather engine come up with something else.
- block chain 6 seeks for sleeping players that have the kick trigger active, and summons snowball above them. Snowball deals 0 damage, but it's still an attack, so players will get up. It then disables the kick trigger again.
2