A sensor tracks your head movements on the pillow. If you sleep well your head does not move much.
The pillow compares the data with previous data and tells you on an LCD display in the morning if you slept well or should take power naps during the day.
Lofty and Tomy released in 2004 a doll called Yumel. Yumel also tracks your sleep pattern and can talk. The creepy doll tells you to go to bed early and stuff like that.The pillow will come to the market in September for about 45,000 yen (~$390).
More details on Nikkei.Net (Subscription). See also the Lofty site (Japanese).