The material "playpiano. . . " copied from wikipedia** makes some sense, but its certainty seems slightly overstated. That is, a connection with "Yan, Tan, Tethera" is a reasonable hypothesis but no one has offered any proof it WAS used.
**http://en.wikipedia.org/wiki/Counting_sheep
But, more important
1) the answer does not explain what in the world "Yan Tan Tethera" IS!
2) neither the answer, nor the wikipedia article gives any particular REASON for connecting Yan Tan Tethera with the attemp to cure INSOMNIA.
So, let me try:
1) "Yan Tan Tethera" is a set of numbers drawn from the old "Cumbrian" language of Northern England. This languguage, a relative of Welsh, died out sometime between the 11th and 13th centuries. BUT the use of these numbers for counting sheep continued up till about 1910.
http://en.wikipedia.org/wiki/Yan_Tan_Tethera
Some further info on the system, and a number of variations on it:
http://www.slaidburn.org.uk/counting_sheep.htm
Note that the system only counts to TWENTY. At that point one would use some sort of marker (set apart a stone, make a notch), then start over. (The marks could be multiplied at the end.) This repetitiveness MAY be of importance.
2) But why connect this with overcoming INSOMNIA?
In fact, we don't have a firmly established connection... only surmise. The articles that speak of a connection are frustrating in that they only speak of a (possible) connection, without further explanation.
I suspect the notion is that the very REPETITIVENESS of this counting system -- one to twenty, then back again -- has something to do with the idea of using it for falling asleep. So the emphasis was likely on repeating the set of numbers by rote rather than "counting" per se. (It does seem that this kind of mindless repetition of a shorter sequence --almost a mantra-- might be more effective in calming one than would be counting ever higher. And for one who was always counting sheep as part of their job this might come easily!)
But there DOES seem to be an odd twist here. Those who were SUPPOSED to keep track of and count the sheep dared NOT fall asleep. (Just think of Little Boy Blue".) Perhaps then there was an intentional irony when "count sheep" was first suggested as a cure for insomnia.
Further discussions of yan, tan, tethera -
http://www.languagehat.com/archives/002031.php
http://crookedtimber.org/2004/03/02/counting-in-swaledale